Skip to content

C# language adapter: Roslyn token-stream hashing + dotnet test runner - #95

Merged
davet47 merged 1 commit into
mainfrom
csharp-adapter
Jul 26, 2026
Merged

C# language adapter: Roslyn token-stream hashing + dotnet test runner#95
davet47 merged 1 commit into
mainfrom
csharp-adapter

Conversation

@davet47

@davet47 davet47 commented Jul 26, 2026

Copy link
Copy Markdown
Owner

What

Adds C# as the fifth language adapter behind the LanguageAdapter seam: .cs impls now hash and verify like Go/TS/Java ones.

  • Hashing: cshash/CsHash.cs is compiled once per SDK version with the .NET SDK's own csc.dll against its own bundled Microsoft.CodeAnalysis* assemblies — no NuGet package, no network (the SDK has no single-file source launcher pre-.NET 10, so the cached one-time compile stands in for Java's). The hash is the definition's trivia-free, length-prefixed, CRLF-normalised token stream: formatting/comment/XML-doc edits never move it, signature/body changes always do. Qualnames match the Java grammar (Type, Type.Member, Outer.Inner.Member, Type.Type for ctors; overloads hash together).
  • Runner: dotnet test on the root project/solution with the VSTest FullyQualifiedName~ contains-filter (xUnit, NUnit, MSTest all ride it). Node ids read like Java's: tests/CalcTests.cs::TotalSums, class from the file stem, nested classes in the runtime Outer+Inner spelling. Summaries capped at 40 tokens; build errors are tests_failed_to_run, never a stack trace.
  • Identity: dotnet <sdk-version> + deps suffix over packages.lock.json / Directory.Packages.props; config key {"dotnet": "..."}.

Contract

LanguageAdapter's routing invariant now names .cs; agent-derived, so status went confirmed → inferred — flip on review (hashloom status lists it). Contract hash unchanged (invariant edits are hash-free, #19), so nothing invalidated. hashloom verify --radius LanguageAdapterok: true.

DoD

  • uv run pytest: 277 passed, coverage 87.4% (floor 85) — 18 new tests incl. a real xUnit e2e through api.verify (pass → cached-pass, fail summary, build error), plus a fresh-cache recompile test so the csc-compile path is covered regardless of cache state
  • bench/benchmark.py: 5.4x (≥5x)
  • CI: setup-dotnet 9 added (tests skip gracefully without an SDK, like the other languages)

Follow-ups filed as ISSUES.md #23: examples/csharp-* project, live NUnit/MSTest fixtures, xunit-v3/MTP output parsing.

🤖 Generated with Claude Code

…, dotnet test runner

- .cs routes to CSharpAdapter; hash helper compiled once per SDK version
  with the SDK's bundled Roslyn (no packages, no network), cached in the
  user cache dir keyed by SDK version + helper source
- dotnet test with the VSTest FullyQualifiedName~ filter (xUnit/NUnit/
  MSTest); file-stem class convention, Outer+Inner nested spelling
- identity: dotnet <sdk-version> + deps suffix over packages.lock.json /
  Directory.Packages.props
- LanguageAdapter contract: .cs added to the routing invariant, status
  confirmed -> inferred pending review (hash unchanged: invariants are
  hash-free)
- CI installs the .NET 9 SDK; ISSUES.md #23 files the example-project and
  NUnit/MSTest/MTP live-coverage follow-ups
@davet47
davet47 merged commit 6056518 into main Jul 26, 2026
10 checks passed
@davet47
davet47 deleted the csharp-adapter branch July 26, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant