tree-sitter-c-sharp
C# grammar for tree-sitter
What it is and what it does
tree-sitter-c-sharp is a language grammar binding that plugs C# parsing into the tree-sitter incremental parsing framework. It translates the Roslyn C# grammar into tree-sitter's format, with adaptations to handle preprocessor directives, syntax fragments, and edge cases where the two parsing technologies differ. The result is a fast, incremental parser that builds abstract syntax trees for C# code without external dependencies.
You use it by installing the package and importing the language binding. It's designed for tools that need to analyze, transform, or highlight C# syntax—editors, linters, code generators, or language servers—where incremental re-parsing on edits is valuable. The package supports C# 1 through 13.0, with a documented exception for `async`, `var`, and `await` as identifiers in certain contexts.
Use it for:
- Build a C# code linter or style checker that re-parses only changed sections on each edit.
- Implement syntax highlighting or code folding in an editor or IDE plugin using incremental parsing.
- Generate C# AST data for static analysis, refactoring tools, or code generation pipelines.
- Create a language server protocol implementation for C# with incremental parsing support.
- Parse C# code fragments (snippets, REPL input) without requiring a full compilation context.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a C# language parser for tree-sitter, enabling incremental syntax analysis and parsing of C# code from versions 1 through 13.0.
Yes. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and fills a specific need for incremental C# parsing in the tree-sitter ecosystem. Install it if you're building tools that parse or analyze C# code and want fast, dependency-light syntax tree generation. The medium install friction is offset by broad platform support and zero runtime dependencies.
Install
tree-sitter-c-sharp on PyPI
pip
pip install tree-sitter-c-sharpuv
uv add tree-sitter-c-sharppoetry
poetry add tree-sitter-c-sharpInstalling tree-sitter-c-sharp
Before you install
Medium install friction due to precompiled wheels across multiple platforms (macOS, Linux, Windows, ARM64), but no runtime dependencies and active maintenance with a recent release.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install tree-sitter-c-sharp
from tree_sitter_c_sharp import language
Requires Python 3.9 or later; tree-sitter core library must be installed separately.
Verify before relying
- Whether the parser handles all C# 13.0 features or only those explicitly tested in the grammar
- Performance characteristics for large codebases or real-time parsing scenarios
- Compatibility with specific tree-sitter versions or API stability guarantees
- How to instantiate and use the language binding with tree-sitter's Parser interface
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 122 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,740,479/month — #1,439 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_c_sharp-0.23.5-cp310-abi3-macosx_10_9_x86_64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-macosx_11_0_arm64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-musllinux_1_2_aarch64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-musllinux_1_2_x86_64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-win_amd64.whl; tree_sitter_c_sharp-0.23.5-cp310-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, c-sharp
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-cProvides a C language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-cssProvides a CSS grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-language-packProvides pre-compiled tree-sitter parsers for…
permissive · top 5,000 on PyPI
tree-sitter-goProvides a Go language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-cppProvides a C++ language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-phpProvides a PHP language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-kotlinProvides a Kotlin language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-jsonProvides a JSON grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI