Repository navigation
Fix #820: Extraction hardening for csharp - #880
Merged
Merged
Conversation
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]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of the extraction-hardening epic (#813). Closes #820.
Hardens all four extraction gauntlets (
func_start,args,class_start,_dependency_capture) for csharp pertests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and surfaced three real bugs:class_starthad 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_startalso 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_capturewas 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 forusing 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 viacrucible_check.py --update --yes.Test plan
pytest tests/extraction/languages/test_csharp.py(44 new tests) — run via barepytestfrom an unrelated CWD to reproduce CI's invocation stylepytest tests/core_engine/ tests/extraction/ -q— 3576 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailedpython tests/tools/audit_check.py— clean (only the pre-existing, already-trackedguidestar_lens.pymypy findings, unrelated to this change)python tests/tools/crucible_check.py— PASS on both venvs after re-blessingtests/extraction/languages/test_csharp.py🤖 Generated with Claude Code