Skip to content

Remove or reconnect the unused C# qualified constant-pattern helper #5353

Description

@Widthdom

Problem and priority

P3 — posting order 10/10. Audit candidates: D10.

The private 17-line helper IsCSharpQualifiedConstantPatternReferenceSite has only its declaration in the indexed repository. Verify its intended role and either remove obsolete code or restore a demonstrably missing call path in one small PR.

Reproduction and evidence

dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll unused --actionable --exclude-tests --json --compact --limit 30 --db .cdidx/codeindex.db
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search IsCSharpQualifiedConstantPatternReferenceSite --exact-substring --json --search-fields path,line,snippet --limit 30 --db .cdidx/codeindex.db

The actionable unused query and MCP unused_symbols both identify the helper with medium confidence. The exact-substring search returns only its declaration at src/CodeIndex/Indexer/References/Languages/CSharpReferenceExtractor.QualifiedPatterns.cs:98 (lines 98–114 in the audited checkout).

Implementation instructions and cautions

  • Check the current source and Git history before deciding whether the helper is obsolete; indexed absence is not proof of language-level dead code.
  • Recheck conditional/generated/test and any string/reflection-based use. If the helper has no real consumer, remove only that member and leave live constant-pattern/reference logic intact.
  • If history instead establishes a missing necessary call, demonstrate the wrong reference behavior and reconnect the smallest correct path with a focused regression test.
  • Keep this scoped to this helper and its intended behavior. Do not turn it into a broad dead-code sweep, new analyzer, extraction redesign or unsupported performance claim.

Acceptance and validation

  • Compile with the repository's warnings-as-errors policy and run the affected C# qualified/constant-pattern reference tests.
  • Preserve positive/negative constant-pattern and member-read cases. Add a behavioral regression only if behavior changes; do not add a test that merely asserts the private name was deleted.
  • Record whether the result is behavior-preserving cleanup or a restored missing path, with the supporting evidence.

Prior issues

Follow-up to closed #5328 (four different declaration-only members) and its earlier cleanup #5283. The prior #5328 targets were AppendDependencyGeneratedFilter, TryCountTopLevelParameters, IsLexicalPathEqualOrParent and DefaultReadBufferSize. This is an additional remaining helper, not evidence that any deleted member returned.

Baseline and delivery

Observed during the 2026-09-12 dogfood audit on macOS arm64, using repository-built cdidx 1.49.0 / Debug net8.0 at 36f2e68cb0d7f17bc9591d01ad3045abe870da9b. The build passed with zero warnings/errors. The root database and workspace-manifest freshness checks were healthy, with index and reference-graph completeness true. Counts/timings describe that checkout. Validation during discovery used focused CLI/MCP/LSP reproductions, not the full test suite.

Implement one focused PR for this issue. Follow AGENT_GUIDE.md and the relevant workflows, use the repository-built cdidx for discovery, preserve supported .NET 8/.NET 9 and cross-platform behavior, and avoid new runtime dependencies outside repository policy. Add focused behavioral tests for changed contracts, update affected help/documentation, and include a bilingual changelog.d/unreleased/ fragment for user-visible changes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .NET codeenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions