tree-sitter-c-sharp
tree-sitter-c-sharp copied to clipboard
C# Grammar for tree-sitter
``` var a = new ArrayList() { #if DEBUG Capacity = 3 #else Capacity = 4 #endif }; ``` Actual: ``` (compilation_unit [0, 8] - [7, 10] (global_statement [0, 8]...
```csharp var R = A < X >> B; ``` Actual: Interpreted as `A > B` (equals_value_clause [0, 6] - [0, 18] (binary_expression [0, 8] - [0, 18] (generic_name [0,...
```csharp var a = new object(); var b = a?.ToString(); ``` Actual: invocation_expression with a conditional_access_expression. ``` (equals_value_clause [9, 14] - [9, 29] (invocation_expression [9, 16] - [9, 29] (conditional_access_expression...
``` using System; public class HelloWorldVar { public static void Main() { int var = 3; Console.WriteLine(var + 1); } } ``` ```sh $ tree-sitter parse Program.cs ... Program.cs 0...
``` var a = (Int32)(1); ``` Actual: (equals_value_clause (invocation_expression (parenthesized_expression (identifier)) (argument_list (argument (integer_literal)))))))))) Expected: (equals_value_clause (cast_expression (identifier) (parenthesized_expression (integer_literal)))))))))
The test in [expressions.txt](https://github.com/tree-sitter/tree-sitter-c-sharp/blob/master/corpus/expressions.txt#L1940-L1960) is incorrect: ``` ===================================== Conditional access expression with simple member access ===================================== if ((p as Person[])?[0]._Age != 1) { } --- (compilation_unit (global_statement (if_statement (binary_expression (member_access_expression...
Fixes #236
`scoped ref var x = ref y` Docs can be found here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/declarations#scoped-ref
They seem to still be adding features to C# 11. Docs can be found here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/file
x || x?.C; Parsed as `(x || x)?.C` instead of `x || (x?.C)`. Actual: ``` (compilation_unit [0, 0] - [1, 0] (global_statement [0, 0] - [0, 10] (expression_statement [0, 0]...