镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

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

LaimaWu wants to merge 3 commits 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

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: redhat-et/ripwire/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 51ddfb20-688b-4ce0-ba0b-2b4f7e80fb74

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@joyful-ii-V-I

Copy link
Copy Markdown
Collaborator

Thank you, @LaimaWu, this is a careful slice. What stood out when we ran it: the one-line (using_directive) @import.path capture mirrors the Go arm, so the directive site (including a leading global) stays exactly where the old walk put it, and deleting csharpUsingTarget plus the directiveTargetOf branch leaves the C# path with one reader instead of two. We compared base and head over 17 C# corpora (ccxt's C# tree, ansible, meson, and the in-repo fixtures) at 13 argv each, 221 in all, plus non-C# repos, and the output is byte-identical (the langidentity harness agrees: 228 same, 0 different, and the language-predicate ratchet stays at 339). test/csharpimportcap.py is the part we most liked: the --legacy mode lets the same arms run against the old binary, so they pin existing behaviour rather than describing the new code; the alias known-gap is pinned by exact rows (and C4 mutates real source to prove the checker can go red); and the 254-258 depth matrix checks the cache file's inode across cold and warm runs, so the disclosure change is measured, not just asserted. Dropping the CSharp arm turns four arms red. Quality-delta is 0 and ASan is clean on the C# gates.

What is left is small and mechanical, so we'll do it ourselves as a maintainer commit on your branch (you enabled maintainer edits), keeping your commits and credit:

  • merge the latest main (the 0.6.8 release moved kParserVer to 206); we tried it, and the only conflicts are CHANGELOG, src/ingest_cache.h, src/quality.h and the qschemetrip pin;
  • renumber the parser tag above main and re-pin test/qschemetrip.hash;
  • move the CHANGELOG entry under [Unreleased], above the new 0.6.8 section.

Two optional nits we can fold in at the same time unless you'd rather: the NodeField::Type early return in normaliseCSharpImport is never taken on the pinned grammar (deleting it passes every arm), so either a one-line "grammar-bump insurance" comment or drop it; and a few comments still list the old language set (src/ingest_sidecap.h near the "as of #358" sentence, src/lintrules.h near the captureIncludes history, the B16 line alignment in childwalkscalecheck.sh).

If you'd prefer to do the merge yourself, just say so and we'll wait. Thanks again for taking slice 1a for C#. The shared import path keeps getting simpler with each language you move onto it.

joyful-ii-V-I and others added 2 commits October 21, 2026 12:45
Mechanical resolution of the five conflicts: kParserVer 214 (rich 215), above
main 206 and the train-32a numbers 212/213; quality.h mirror with it;
qschemetrip.hash re-derived with UPDATE_GOLDEN=1 (RE-PIN LOG entry on top);
CHANGELOG entry kept under [Unreleased] above 0.6.8 and credited to @LaimaWu.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ments, B16 alignment

Optional nits from review: keep the NodeField::Type early return in
normaliseCSharpImport with a one-line note (never taken on the pinned grammar);
captureTagsFacts, captureIncludes-history and ingest_relations header comments
now name C# as moved to the shared capture; align the B16 line in
childwalkscalecheck.sh; fill the hash in the qschemetripcheck RE-PIN LOG line.
No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

2 participants