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

Seems that // comments cause trouble #53

Closed daveyostcom closed 5 years ago

daveyostcom commented 5 years ago

Please see line 50 in this example.

JonathanMagnan commented 5 years ago

Hello @daveyostcom ,

Thank you for reporting.

We will look at it.

Best Regards,

Jonathan

JonathanMagnan commented 5 years ago

Hello @daveyostcom ,

Did you success to reproduce this issue outside of Fiddle?

That issue is caused by Fiddle that uses only "\n" instead of "\r\n" for new line. A simple string.split doesn't work either: https://dotnetfiddle.net/eoHJ2q

var text = @"
// Take out this comment, and it works. Leave it in and the output is a blank line.
X + Y";

var lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
Console.Write(lines.Count()); // 1 in Fiddle, 3 in Visual Studio

Since we are the co-owner of Fiddle, I guess the issue is still on our side ;)

We will look at it and try to deploy a new version of Fiddle with this fix in 2 weeks.

daveyostcom commented 5 years ago

Happens in Rider on Mac.

JonathanMagnan commented 5 years ago

Oh damn, you are right.

The end line is not the same in every OS. So I guess we will need to fix both.

Fiddle and C# Eval

JonathanMagnan commented 5 years ago

Hello @daveyostcom ,

A new version is now available.

Your Fiddle is now working as expected: https://dotnetfiddle.net/ZE67wT

The issue has been fixed only in the C# Eval Expression, a fix for Fiddle will be provided on the next released.