Skip to content

Commit 3fc1d5e

Browse files
committed
Repair build and consolidate focused review fixes
A prior fix batch was interrupted mid-change, leaving the tree broken (JsonLanguage delegated to LanguagePack without the project reference). This restores a green build and consolidates the coherent fixes: - JsonLanguage/Grammars.Json now resolve the grammar via LanguagePack (chained LanguageNotAvailableException instead of a bare DllNotFound), and reference TreeSitter.LanguagePack so the grammar lib ships. - Parser.Parse throws InvalidOperationException when no language is set; null is reserved for timeout/cancellation (test updated to match). - build-native.ps1 excludes the 3 WASM-only symbols from the synthesized .def (they are compiled out of the default no-WASM engine build). - build-native.sh hard-fails when codesign is unavailable on macOS. - QueryCursor asserts the should-not-happen capture-array invariant. Build 0/0; 381 tests pass (incl. a hermetic run with grammar caches removed). https://claude.ai/code/session_01S3hwvd2oz6cntXmB3G6Yf1
1 parent 685cf5e commit 3fc1d5e

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

grammars/TreeSitter.Grammars.Json/TreeSitter.Grammars.Json.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424

2525
<ItemGroup>
2626
<ProjectReference Include="..\..\src\TreeSitter\TreeSitter.csproj" />
27+
<!-- JsonLanguage resolves the grammar by name via LanguagePack; this reference
28+
also makes the json grammar native lib ship transitively (LanguagePack packs
29+
the grammar libs under runtimes/<rid>/native/). -->
30+
<ProjectReference Include="..\..\src\TreeSitter.LanguagePack\TreeSitter.LanguagePack.csproj" />
2731
</ItemGroup>
2832

2933
<!--
3034
Dev/test convenience: copy the JSON grammar native lib next to this assembly so
3135
the resolver's AssemblyDirectory probe finds libtree-sitter-json.so during
32-
`dotnet run`/`dotnet test`. Pack="false": shipping payload travels with the core
33-
package's runtimes/<rid>/native assets.
36+
`dotnet run`/`dotnet test`. Pack="false": the shipping payload travels with the
37+
TreeSitter.LanguagePack package's runtimes/<rid>/native assets (referenced above).
3438
-->
3539
<ItemGroup>
3640
<None Include="$(RepoRoot)native/$(NETCoreSdkPortableRuntimeIdentifier)/libtree-sitter-json.*"

tests/TreeSitter.Tests/ParserTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ public void TrySetLanguage_null_throws()
4545
}
4646

4747
[Fact]
48-
public void Parse_without_language_returns_null()
48+
public void Parse_without_language_throws_InvalidOperation()
4949
{
5050
using var parser = new Parser();
51-
Assert.Null(parser.Parse("{}"));
52-
Assert.Null(parser.Parse("{}"u8));
51+
// Parsing with no language set is a programming error (distinct from a
52+
// null return, which is reserved for timeout/cancellation).
53+
Assert.Throws<InvalidOperationException>(() => parser.Parse("{}"));
54+
Assert.Throws<InvalidOperationException>(() => parser.Parse("{}"u8));
5355
}
5456

5557
[Fact]

0 commit comments

Comments
 (0)