tree-sitter-c-sharp
tree-sitter-c-sharp copied to clipboard
c# 11 raw string literals
per docs, these are valid and invalid cases starting with c# 11
// valid
x = $"""The point "{X}, {Y}" is {Math.Sqrt(X * X + Y * Y)} from the origin""";
x = $"""The point ""{X}, {Y}"" is {Math.Sqrt(X * X + Y * Y)} from the origin""";
x = $""""The point """{X}, {Y}""" is {Math.Sqrt(X * X + Y * Y)} from the origin"""";
x = $$"""The point {{{X}}, {{Y}}} is {{Math.Sqrt(X * X + Y * Y)}} from the origin""";
// invalid
x = $"The point "{X}, {Y}" is {Math.Sqrt(X * X + Y * Y)} from the origin";
x = $""The point ""{X}, {Y}"" is {Math.Sqrt(X * X + Y * Y)} from the origin"";
x = $"""The point """{X}, {Y}""" is {Math.Sqrt(X * X + Y * Y)} from the origin""";
x = $$"""The point {{X}, {{Y}}} is {{Math.Sqrt(X * X + Y * Y)}} from the origin""";
also take a look at 'what's new in c# 11' series: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11#raw-string-literals
tree-sitter doesn't handle valid cases.
I'm planning on tackling the C# 11 features next week :)
cool. we still have time until november when c# 11 will officially released (as part of .net 7 release). using preview 3 of .net 7 let us play with it.
here is another one "utf-8 string literals" (https://github.com/dotnet/csharplang/blob/main/proposals/utf8-string-literals.md)
following five are equal:
byte[] utf8String;
utf8String = new byte [] { 97, 98, 99 };
utf8String = new byte [] {
(byte)'a', (byte)'b', (byte)'c' };
// new in c# 11
utf8String = "abc";
utf8String = "abc"u8; // tree-sitter has issue with the new 'u8' suffix
utf8String = "abc"U8; // tree-sitter has issue with the new 'U8' suffix
u8 suffix name is case insensitive like other constant suffix (f/F for float, d/D for double and m/M for decimal)
I think the u8 feature is yet to be confirmed - neither of those u8 suffixes work in the latest VS/.NET SDK preview bits (VS 2022 Preview 5, .NET 7 SDK 7.0 preview 3)

i am using preview 4 (second column https://github.com/dotnet/installer#table) with <LangVersion>Preview<LangVersion> in csproj.
Just updated to preview 4 and still having the same issue. I'm going to leave utf-8 support for now until things are further along.
ok. for reference, i can run it locally with daily build (first column from installer table) and here is an example running on sharplab.