Skip to content

Fix #820: Extraction hardening for csharp - #880

Merged
squid-protocol merged 1 commit into
mainfrom
feature/820-extraction-hardening-csharp
Jul 31, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feature/820-extraction-hardening-csharp

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Part of the extraction-hardening epic (#813). Closes #820.

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for csharp per tests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and surfaced three real bugs:

  • class_start had the same missing-generic-step-over bug already seen in java (Extraction hardening: java #816) and python (Extraction hardening: python #818): no generic-parameter step-over between the class/interface/etc. name and the base-list : check, so ANY generic type with a base list (class Foo<T> : Base<T> {, extremely common) silently lost the entire base-list capture even though the name still matched fine.
  • class_start also needed a companion fix no prior language required: a primary-constructor parameter-list step-over (record Foo<T>(T Value) : Base<T>, C# 9+ records / C# 12 primary constructors on classes and structs, mainstream and common) — the constructor's (...) was equally unconsumed between the generics and the base-list check, independently of the generic-parameter fix.
  • _dependency_capture was entirely missing support for using-alias directives (using Alias = Target;, common for shortening long generic types or disambiguating identically-named types from different namespaces) — no match at all, not just a dirty capture. The alias target itself also needed its own generic-suffix step-over (using StringList = List<string>;, the primary real-world reason alias directives exist).

Also documents a known, unfixed architectural limitation (out of scope for a single-language pass, tracked in the epic): func_start/_dependency_capture's Mode-B string-shielding gap reproduces on C# verbatim strings (@"...") and C# 11+ raw string literals — now confirmed on a fifth language.

Differential Scan

Ran python tests/tools/crucible_check.py: the only diff across the ~80-repo corpus is a real Roslyn corpus file (CSharpSyntaxTree.cs), which now correctly detects a dependency edge for using InternalSyntax = Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax; — exactly the alias-directive shape this fixes, previously invisible. Confirmed no other language/file is affected. Golden masters re-blessed for this on-target, expected change via crucible_check.py --update --yes.

Test plan

  • pytest tests/extraction/languages/test_csharp.py (44 new tests) — run via bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3576 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed
  • python tests/tools/audit_check.py — clean (only the pre-existing, already-tracked guidestar_lens.py mypy findings, unrelated to this change)
  • python tests/tools/crucible_check.py — PASS on both venvs after re-blessing
  • Migrated csharp's cases out of the four monolithic dict files into tests/extraction/languages/test_csharp.py
  • Epic Epic: Harden the four extraction gauntlets (function/args/class/dependency) per language #813 and the methodology doc updated with the new findings (recurring bug classes 22-23)

🤖 Generated with Claude Code

Hardens all four extraction gauntlets for csharp. This was a fresh sweep
(no pre-flagged known finding) and surfaced three real bugs:

- class_start had the same missing-generic-step-over bug already seen in
  java (#816) and python (#818): no generic-parameter step-over between
  the class/interface/etc. name and the base-list `:` check, so ANY
  generic type with a base list (`class Foo<T> : Base<T> {`, extremely
  common) silently lost the entire base-list capture even though the
  name still matched fine.

- class_start also needed a companion fix no prior language required: a
  primary-constructor parameter-list step-over (`record Foo<T>(T Value)
  : Base<T>`, C# 9+ records / C# 12 primary constructors on classes and
  structs, mainstream and common) -- the constructor's `(...)` was
  equally unconsumed between the generics and the base-list check,
  independently of the generic-parameter fix.

- _dependency_capture was entirely missing support for using-alias
  directives (`using Alias = Target;`, common for shortening long
  generic types or disambiguating identically-named types from
  different namespaces) -- no match at all, not just a dirty capture.
  The alias target itself also needed its own generic-suffix step-over
  (`using StringList = List<string>;`, the primary real-world reason
  alias directives exist).

Verified via crucible_check.py: a real Roslyn corpus file
(CSharpSyntaxTree.cs) gained a newly-detected dependency edge for
`using InternalSyntax = Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;`
-- exactly the alias-directive shape this fixes, previously invisible.
Confirmed no other language/file affected. Golden masters re-blessed for
this on-target, expected change.

Also documents a known, unfixed limitation: func_start/_dependency_capture's
Mode-B string-shielding gap reproduces on C# verbatim strings (@"...")
and C# 11+ raw string literals -- now confirmed on a FIFTH language.

Migrates csharp's test cases out of the four monolithic dict files into
tests/extraction/languages/test_csharp.py, and updates the epic +
methodology doc with the new findings (recurring bug classes 22-23:
class_start's generic-step-over bug recurring across three unrelated
languages, and _dependency_capture missing an entire statement shape
rather than just a character).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit a4bdc95 into main Jul 31, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the feature/820-extraction-hardening-csharp branch July 31, 2026 03:54
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.

Extraction hardening: csharp

1 participant