Skip to content

refactor(#358): route C# using directives through shared import captures - #420

Open
LaimaWu wants to merge 1 commit into
redhat-et:mainfrom
LaimaWu:refactor/csharp-import-capture-358
Open

LaimaWu wants to merge 1 commit into
redhat-et:mainfrom
LaimaWu:refactor/csharp-import-capture-358

Conversation

@LaimaWu

@LaimaWu LaimaWu commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

C# using directives currently use a separate AST walk. This moves them onto the shared import.path capture with a minimal CSharp normaliser, and removes csharpUsingTarget and its directiveTargetOf branch.
Existing behaviour is preserved for written targets, directive sites and ordering, duplicate directives, static/global forms, dependency edges, and bindings. The existing using X = … alias gap remains pinned by a known-gap test; alias migration stays in slice 2b after the maintainer-owned shared binds channel. No shared binding API is added here.
One disclosure/cache behaviour change matches the precedent from Python #382: at container depths 257/258, import-free deep containers (including a top-level using followed by a deep empty container) no longer mark the file extract-partial and may reuse the whole-file cache. A real using beyond the bound is still cut, disclosed as partial, and not captured. Dependency output remains byte-identical across the boundary fixtures.
Parser identity moves from 196 to 198 (rich 199); cache record format 36 and quality scheme 22 are unchanged.
Validation against main 939dbb6, head 193d69b:

  • langidentitycheck: 214 SAME / 0 DIFF / 0 EMPTY / 0 ERROR across five corpora, including Serilog and untouched-language itsdangerous; 339/339 language-predicate ratchet.
  • Quality delta: regressions=0, gating=0.
  • ASAN: 9/9 relevant gates pass, plus ASAN smoke.
  • C# target/site/order, alias-gap, mutation controls, capture-mechanism, and depth/cache checks pass.
  • Serilog fresh/cold/warm differential and XML checks pass.
  • qschemetrip/parser identity and the 16-file scope audit pass.
    Part of Shared import-capture vocabulary instead of ~21 per-language import extractors #358 — C# slice 1a.

Summary by CodeRabbit

  • Improvements
    • C# using directives are now recognized as imports, improving dependency reporting while preserving directive locations and ordering.
    • Deeply nested containers without imports no longer trigger partial-extraction warnings or prevent whole-cache reuse.
  • Limitations
    • Imports beyond the supported nesting limit are still not captured, and aliases such as using X = Foo.Bar are not yet reported under the alias name.

Move using directives onto @import.path and the CSharp normaliser, retaining targets, sites, order, flags and existing alias behaviour. Remove the redundant extractor; leave bindings to slice 2b.

Pin the shared-capture depth disclosure/cacheability exception, add real-input mutation controls, and advance parser identity to 186 with its quality mirror. No shared binding API changes.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: redhat-et/ripwire/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2a9eee1-79db-4ea4-a7ca-9f8b701cecb1
📥 Commits

Reviewing files that changed from the base of the PR and between 939dbb6 and 193d69b.

⛔ Files ignored due to path filters: 4
  • test/csharpimportcapfix/Imports.cs is excluded by !test/*fix/**
  • test/csharpimportcapfix/Types.cs is excluded by !test/*fix/**
  • test/langidentity/manifest.tsv is excluded by !**/*.tsv
  • test/qschemetrip.hash is excluded by !test/*.hash
📒 Files selected for processing: 12
  • CHANGELOG.md
  • CONTRIBUTING.md
  • prompts/help-wanted/visual-basic-language.md
  • queries/csharp/tags.scm
  • src/ingest_cache.h
  • src/ingest_importcap.h
  • src/ingest_relations.h
  • src/quality.h
  • test/childwalkscalecheck.sh
  • test/csharpcheck.sh
  • test/csharpimportcap.py
  • test/qschemetripcheck.sh

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

C# using_directive imports now enter shared @import.path capture and C# normalization instead of relation-walk extraction. Parser-version metadata and tests for imports, cache consistency, and depth boundaries are updated. Documentation records preserved behavior and the remaining alias-binding gap.

Changes: C# Import Capture

Layer / File(s) Summary
Capture and normalize C# imports
queries/csharp/tags.scm, src/ingest_importcap.h, src/ingest_relations.h, test/csharpimportcap.py, test/csharpcheck.sh, test/childwalkscalecheck.sh
C# using_directive nodes use @import.path and normaliseCSharpImport; the relation-walk extraction branch is removed. Tests check dependency rows, use-sites, cache consistency, and the capture contract.
Depth boundaries and parser cache
src/ingest_cache.h, src/quality.h, test/csharpimportcap.py, test/qschemetripcheck.sh, CHANGELOG.md, CONTRIBUTING.md, prompts/help-wanted/visual-basic-language.md
Parser-version metadata changes to 198. Tests cover depths 254–258 and check import rows and partial-extraction disclosure. Documentation records the deep-container behavior, cache-format values, and alias-binding gap.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: barefootski, joyful-ii-v-i

Merge Risk: ⚪ Minimal · up to 193d6

The C# import migration appears ready to merge after normal checks; no outstanding behavior or cache risk was established.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: routing C# using directives through shared import captures.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

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