zzzprojects / Eval-Expression.NET

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

Feature Request: Support raw string literal #141

Open cesaryuan opened 1 year ago

cesaryuan commented 1 year ago

Hi, is it impossible to implement the Raw string literal syntax imported in C# 11.

It is very useful with multiple line strings with quotes and brackets. Here is an example:

int veryCold = -30;
int comfortable = 20;
// using newer Raw string literal syntax
string jsonString1 =
    $$"""
    {
        "TemperatureRanges" : {
            "Cold" : {
                "High": {{comfortable}},
                "Low": {{veryCold}}
            }
        }
    }
    """;
// older method
string jsonString2 =
$@"{{
    ""TemperatureRanges"" : {{
        ""Cold"" : {{
            ""High"": {comfortable},
            ""Low"": {veryCold}
        }}
    }}
}}";

It is obvious that the raw string literal syntax is cleaner and more concise. Hope you can consider it, thanks!

JonathanMagnan commented 1 year ago

Hello @cesaryuan ,

Thank you for reporting, we will look very soon at this one.

Best Regards,

Jon

JonathanMagnan commented 1 year ago

Hello @cesaryuan ,

Just to update you, it will take us a little bit more time than expected due to work overload.

But this one is definitely something that we hope to release soon.

Best Regards,

Jon

cesaryuan commented 1 year ago

Thanks for your attention!

cesaryuan commented 6 months ago

Just want to know the progress 😊

JonathanMagnan commented 6 months ago

Hello @cesaryuan ,

Sorry for the long reply; I was on vacation.

There is currently no update for this one.

I hope we will eventually get it done, but at this moment, our backlog is still too full to add it.

Best Regards,

Jon

JonathanMagnan commented 1 month ago

Hello @cesaryuan ,

I have good news for you ;) We just release the v6.2.0: https://github.com/zzzprojects/Eval-Expression.NET/releases/tag/v6.2.0

As you will see in our release notes, we added the full support of Raw string literals and Interpolated raw string literals

This was surely harder than I initially thought, but it should have worked out great.

Keep in mind you can also use them within our library with single quote to make it easier to read/write. You can see your example here: https://dotnetfiddle.net/P8uoqs

If you have the chance to test it, let us know if everything is working.

Best Regards,

Jon