Skip to content

Restore cross-file partial-class usage detection in unused analysis #4834

Description

@Widthdom

Summary

unused again marks private fields as actionable-unused when their uses live in sibling files of the same partial class. Current examples include endLineExplicit, outputFormatExplicit, and _hasIssueMetadataColumns.

Audit ID: R-01. Reproduced with v1.40.3 at 404db09489c305f17d94f37026e00564d3ac527a.

Existing issue relationship

This is a direct regression of closed #3673 (“Fix unused analysis for partial-class handlers and field-like symbols”). The current reproduction must not be discarded merely because that issue was completed.

Expected behavior

Unused analysis must aggregate references across the logical partial type before declaring a field unused.

PR scope

Keep this to cross-file partial-family reachability and the three representative fields as one root cause. Do not create per-field fixes or suppress by name.

Implementation guide for Codex 5.6 sol xhigh

  • Add a two/three-file partial-class fixture with used and truly unused private fields, including nested partial types.
  • Resolve logical partial-family membership before usage classification; do not rely on same-file ranges or folded names alone.
  • Preserve conservative behavior for reflection/config suspects and for unrelated same-named types.
  • Verify compact, JSON, by-bucket, and actionable filters against the same fixture.
  • Add regression tests, run full net8/net9, and add a bilingual changelog fragment referencing Fix unused analysis for partial-class handlers and field-like symbols #3673.

Acceptance criteria

  • The three current fields are not reported unused.
  • A genuinely unreferenced private field in the same partial family remains actionable.
  • Unrelated same-named partial types do not share references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .NET codebugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions