This is the Brokk-owned and independently maintained fork of
tree-sitter/tree-sitter-c-sharp,
a C# grammar for Tree-sitter.
Brokk maintains this fork for use in its code-intelligence tooling and publishes
the Rust package as
brokk-tree-sitter-c-sharp.
It may intentionally diverge from upstream to support correctness and language
coverage required by Brokk.
Add the Brokk-maintained Rust crate to your project:
cargo add brokk-tree-sitter-c-sharp@=0.23.6Or add it directly to Cargo.toml:
[dependencies]
brokk-tree-sitter-c-sharp = "=0.23.6"The grammar is based upon the Roslyn grammar with changes in order to:
- Deal with differences between the parsing technologies
- Work around some bugs in that grammar
- Handle
#if,#else,#elif,#endifblocks - Support syntax highlighting/parsing of fragments
- Simplify the output tree
- Reduce parser state count and complexity
- Be in-line with tree-sitter's convention where applicable
Comprehensively supports C# 1 through 14.0 with the following exceptions:
-
varandawaitcannot be used as identifiers everywhere they are valid - File-based apps preprocessor directives (
#:property,#:package,#:sdk,#:project) are not yet recognized
- Official C# 8 Draft Language Spec provides chapters that formally define the language grammar.
- Roslyn C# language grammar export
- SharpLab (web-based syntax tree playground based on Roslyn)