diff --git a/Data_Eval/Data_Eval/Data_Eval.csproj b/Data_Eval/Data_Eval/Data_Eval.csproj
index 4ae4925..0efc75c 100644
--- a/Data_Eval/Data_Eval/Data_Eval.csproj
+++ b/Data_Eval/Data_Eval/Data_Eval.csproj
@@ -7,7 +7,7 @@
true
false
Data_Eval.snk
- 2.5.0
+ 2.6.0
diff --git a/Data_Eval/Data_Eval/Data_Eval.nuspec b/Data_Eval/Data_Eval/Data_Eval.nuspec
index 356dbfc..43b2d8e 100644
--- a/Data_Eval/Data_Eval/Data_Eval.nuspec
+++ b/Data_Eval/Data_Eval/Data_Eval.nuspec
@@ -2,7 +2,7 @@
Data.Eval
- 2.5.0
+ 2.6.0
Data.Eval
Bruce Dunwiddie
shriop
@@ -10,8 +10,8 @@
https://github.com/bruce-dunwiddie/data-eval
false
.Net Library for Evaluating Expressions at Runtime
- Added basic support for anonymous classes.
- Copyright © 2020
+ Cache compilation exceptions to speed up looped exception creation.
+ Copyright © 2023
eval expression evaluator compile
diff --git a/Data_Eval/Data_Eval/Evaluator.cs b/Data_Eval/Data_Eval/Evaluator.cs
index eb66ab4..3e5734b 100644
--- a/Data_Eval/Data_Eval/Evaluator.cs
+++ b/Data_Eval/Data_Eval/Evaluator.cs
@@ -281,6 +281,11 @@ private void Init(
if (alreadyCompiled)
{
execution = compiledTypes[classText];
+
+ if (execution.Exception != null)
+ {
+ throw execution.Exception;
+ }
}
else
{
@@ -297,11 +302,24 @@ private void Init(
Compiler compiler = new Compiler();
- Type newType = compiler.Compile(
- classText,
- references,
- "EvalAssembly",
- "CustomEvaluator");
+ Type newType;
+
+ try
+ {
+ newType = compiler.Compile(
+ classText,
+ references,
+ "EvalAssembly",
+ "CustomEvaluator");
+ }
+ catch (CompilationException ex)
+ {
+ execution.Exception = ex;
+
+ compiledTypes[classText] = execution;
+
+ throw;
+ }
execution.Constructor = new DefaultClassConstructorExpression().GetFunc(
newType);
@@ -549,6 +567,8 @@ private sealed class Execution
public Func