@willbooster/tree-sitter-c-sharp 7.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,22 +29,19 @@ Known gaps:
29
29
 
30
30
  - `var` and `await` cannot be used as identifiers everywhere they are valid
31
31
 
32
- ## Upgrading to version 6
32
+ ## Syntax trees
33
33
 
34
- Type tests use `is_pattern_expression`; `is_expression` is no longer emitted. The `lvalue_expression` and
35
- `non_lvalue_expression` supertypes have been replaced by the shared expression grammar. Update queries to use
36
- `expression` and the concrete expression nodes. Constant patterns can contain a direct `conditional_access_expression`
37
- child. Conditional access includes its complete dependent chain and, for conditional assignment, the assignment in its
38
- `consequence` field. Tuple-shaped patterns such as `x is (1, 2)` use `recursive_pattern` with a
39
- `positional_pattern_clause` instead of `constant_pattern` with a `tuple_expression`.
40
- The contextual type names `nint` and `nuint` use `identifier` nodes instead of `predefined_type`.
34
+ Type tests use `is_pattern_expression`. Queries can use `expression` and its concrete expression nodes.
35
+ Constant patterns can contain a direct `conditional_access_expression` child.
36
+ Conditional access includes its complete dependent chain and, for conditional assignment, the assignment in its `consequence` field.
37
+ Tuple-shaped patterns such as `x is (1, 2)` use `recursive_pattern` with a `positional_pattern_clause`.
38
+ The contextual type names `nint` and `nuint` use `identifier` nodes.
41
39
 
42
40
  ## Usage
43
41
 
44
42
  The npm package ships `tree-sitter-c_sharp.wasm` for
45
43
  [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
46
- browsers, and Cloudflare Workers. The parser carries the ABI number of WillBooster/tree-sitter, so it loads only with
47
- that runtime. Use version 2.0.24 or later; upstream's runtime rejects it. Install the runtime alongside the grammar when using
44
+ browsers, and Cloudflare Workers. The parser uses WillBooster ABI 6 and loads only with that runtime. Use version 7.0.18 or later within major version 7; upstream's runtime rejects it. Install the runtime alongside the grammar when using
48
45
  the Wasm parser; it remains an optional peer for consumers that only use the grammar source or queries.
49
46
 
50
47
  In Node.js and Bun, load it from the package:
@@ -92,12 +89,12 @@ Their external tokens and serialized scanner state must match.
92
89
 
93
90
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-c-sharp) and on
94
91
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
95
- fuzzed with. Use runtime 2.0.24 or later:
92
+ fuzzed with. Use runtime 7.0.18 or later within major version 7:
96
93
 
97
94
  ```toml
98
95
  [dependencies]
99
- tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.24" }
100
- tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "6" }
96
+ tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.18" }
97
+ tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "8" }
101
98
  ```
102
99
 
103
100
  ```rust
@@ -110,61 +107,16 @@ parser.set_language(&tree_sitter_c_sharp::LANGUAGE.into())?;
110
107
  ```sh
111
108
  mise install
112
109
  bun install --frozen-lockfile
110
+ bun playwright install chromium
113
111
  bun run build/ci
112
+ bun run verify
114
113
  bun run test
115
- script/parse-examples
116
114
  cargo test
117
115
  ```
118
116
 
119
- `script/tree-sitter` (also `bun run tree-sitter`) runs the tree-sitter CLI of WillBooster/tree-sitter at the runtime
120
- version locked in `Cargo.lock`, so the parser is generated, built, tested, and fuzzed with the generator and the
121
- runtime this package ships. The first run downloads that CLI from its GitHub Release into `.tmp/`, or builds it with
122
- `cargo` (with the `cmake` that `mise.toml` pins) when the download fails or the release has no binary that runs here.
123
-
124
- `bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and Git-tracked
125
- files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar, scanner source,
126
- `tree-sitter.json`, a corpus case, or a tracked example,
127
- regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
128
- Profiles in `.tmp/generation-profiles/` are temporary and must not be committed. `bun run build-wasm`, `bun run build/ci`,
129
- and the release build regenerate the parsers before compiling them.
130
-
131
- The tracked `examples/JsonWriter.cs` and `examples/JsonSerializerInternalWriter.cs` are verbatim MIT-licensed
132
- snapshots from Newtonsoft.Json commit `52fa3aef1f2cadcd3a3f874251eddc98d3efbbaa`, under `Src/Newtonsoft.Json/`
133
- and its `Serialization/` directory respectively. Refresh these training inputs independently of the clone pins in
134
- `script/parse-examples` so changing a test checkout does not change profile training.
135
-
136
- `bun run test` runs:
137
-
138
- - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
139
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
140
- edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
141
- `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
142
- - a check that the C# files under `examples/` that fail to parse are exactly those listed in
143
- `script/known-failures.txt`. Inputs include Git-tracked generation examples and pinned clones. The first run fetches the pinned repositories listed in
144
- `script/parse-examples`. After adding, removing, or changing an example, changing the grammar, or moving a pin,
145
- run `script/parse-examples` and review the failure-list diff before committing;
146
- - a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes linear time
147
- (ten times the lines take about ten times the CPU time, under a ceiling), since consumers parse files while they are
148
- being edited. It loads the Wasm build through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after
149
- regenerating the parser;
150
- - a check that `package.json` and `Cargo.lock` test the same runtime version (`test/unit/runtimeVersion.test.ts`);
151
- - checks that the Wasm build parses C# with @willbooster/web-tree-sitter in Chromium (`test/unit/browser.test.ts`,
152
- which needs Chromium installed once by `bunx playwright install chromium`) and in Cloudflare Workers with and without
153
- `nodejs_compat` (`test/unit/workers.test.ts`).
154
-
155
- The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
156
- by every checkout; `script/fuzz-corpus` builds a per-run parser in `.tmp/fuzz` and deletes it afterwards. `mise.toml`
157
- sets `TREE_SITTER_LIBDIR` to `.tmp/tree-sitter-lib` as well, so other `tree-sitter` commands run in the checkout use
158
- this checkout's parser too.
159
-
160
- `cargo test` also replays edits that `tree-sitter fuzz` found to break incremental parsing on runtimes without the
161
- fixes of willbooster-tree-sitter.
162
-
163
- CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the
164
- parser with libFuzzer and sanitizers on the willbooster-tree-sitter runtime locked in `Cargo.lock`
165
- (`.github/workflows/robustness.yml`).
166
-
167
- ### References
117
+ - [Parser generation and validation](docs/development.md): read before changing grammar inputs, runtime versions, examples, or reproducing an incremental parsing failure.
118
+
119
+ ## References
168
120
 
169
121
  - [C# language specification](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/readme)
170
122
  - [Official C# 8 Draft Language Spec](https://github.com/dotnet/csharpstandard/tree/draft-v8/standard) provides
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -48,7 +48,7 @@
48
48
  "@willbooster/oxfmt-config": "1.2.2",
49
49
  "@willbooster/oxlint-config": "1.4.8",
50
50
  "@willbooster/wb": "22.26.1",
51
- "@willbooster/web-tree-sitter": "2.0.27",
51
+ "@willbooster/web-tree-sitter": "7.0.18",
52
52
  "conventional-changelog-conventionalcommits": "10.4.1",
53
53
  "lefthook": "2.2.1",
54
54
  "oxfmt": "0.72.0",
@@ -62,7 +62,7 @@
62
62
  "wrangler": "4.149.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "@willbooster/web-tree-sitter": "^2.0.24"
65
+ "@willbooster/web-tree-sitter": "^7.0.18"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -29,7 +29,7 @@
29
29
  }
30
30
  ],
31
31
  "metadata": {
32
- "version": "7.0.0",
32
+ "version": "8.0.0",
33
33
  "license": "MIT",
34
34
  "description": "C# grammar for tree-sitter",
35
35
  "authors": [