zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
449 stars 86 forks source link

The parser should give error messages at least as good as from the C# compiler. #55

Closed daveyostcom closed 5 years ago

daveyostcom commented 5 years ago

This is really unusable:

Run-time exception (line 116): Object reference not set to an instance of an object.

Stack Trace:

[System.NullReferenceException: Object reference not set to an instance of an object.] at .(ExpressionScope , SyntaxNode ) at .(ExpressionScope , SyntaxNode , Expression , Boolean ) at .(ExpressionScope , SyntaxNode , Expression , Boolean ) at .(ExpressionScope , SyntaxNode , Expression , Boolean ) at Z.Expressions.CodeCompiler.CSharp.ExpressionParser.ParseSyntax(ExpressionScope scope, SyntaxNode node, Type resultType) at .[](EvalContext , String , IDictionary2 , Type , EvalCompilerParameterKind , Boolean , Boolean ) at Z.Expressions.Eval.Compile(String code, IDictionary2 parameterTypes) at Program.evalDemo5() :line 116 at Program.testEval() :line 22 at Program.Main() :line 11

JonathanMagnan commented 5 years ago

Hello @daveyostcom ,

Please provide the code that raises this error and we will improve it. We have improved a lot of error message in the past and we keep improving them as we get it.

Best Regards,

Jonathan

daveyostcom commented 5 years ago

Here's an error message from this example:

Run-time exception (line 116): Object reference not set to an instance of an object.

Stack Trace:

[System.NullReferenceException: Object reference not set to an instance of an object.] at .(ExpressionScope , SyntaxNode ) at .(ExpressionScope , SyntaxNode , Expression , Boolean ) at .(ExpressionScope , SyntaxNode , Expression , Boolean ) at .(ExpressionScope , SyntaxNode , Expression , Boolean ) at Z.Expressions.CodeCompiler.CSharp.ExpressionParser.ParseSyntax(ExpressionScope scope, SyntaxNode node, Type resultType) at .[](EvalContext , String , IDictionary2 , Type , EvalCompilerParameterKind , Boolean , Boolean ) at Z.Expressions.Eval.Compile(String code, IDictionary2 parameterTypes) at Program.evalDemo5() :line 116 at Program.testEval() :line 22 at Program.Main() :line 11

JonathanMagnan commented 5 years ago

Thank you,

I have assigned this task to one of my developers. We usually try to add a few more every time.

Best Regards,

Jonathan

JonathanMagnan commented 5 years ago

Hello @daveyostcom ,

Unfortunately, it looks you updated your Fiddle to a working one.

So my developer is not able to investigate your error as there is currently no error in the provided Fiddle.

Could you create a new one that shows the error?

Best Regards,

Jonathan

daveyostcom commented 5 years ago

Here you go: parser error from private base class field

JonathanMagnan commented 5 years ago

Thank you ;)

JonathanMagnan commented 5 years ago

Hello @daveyostcom ,

A new version has been released.

Some error message such as this one has been improved:

Run-time exception (line 114): valueBase is inaccessible due to its protection level. At position 71 near "valueBase; x1 + x2

Best Regards,

Jonathan

daveyostcom commented 5 years ago

Thanks