Skip to content

fix(analyzers): match ByteSize by simple name and resolve it in the fix - #179

Merged
e128 merged 1 commit into
mainfrom
fix/e128080-bytesize-namespace
Nov 17, 2026
Merged

e128 merged 1 commit into
mainfrom
fix/e128080-bytesize-namespace

Conversation

@e128

@e128 e128 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Executive Summary

E128080 exempted only the fully qualified Pug.Core.Classes.ByteSize name. After a consumer moved the type to another namespace, the rule fired on ByteSize's own unit properties and forced a pragma. E128082 used the same probe, so the cast rule stopped matching the moved type.

The type is now matched by simple name in any namespace. The E128080 code fix also hardcoded the retired namespace, so it resolved the type at fix time instead: canonical name first, then a global-namespace walk for a type named ByteSize with a static FromBytes.

Code Changes

  • ByteSizeType.Is matches a type named ByteSize, whatever its namespace. E128080 and E128082 share it.
  • ByteSizeForDataSizeCodeFixProvider resolves the type in the compilation, adds the resolved namespace as a using, and qualifies FromBytes with the resolved name.
  • Package version bumped to 3.1.5. README install snippet and both rule descriptions updated.
  • Lode register closed, helper contract corrected, and the failure recorded in the symbol lookup and code fix pattern docs.

Tests and Tooling

  • New regression tests: moved-namespace exemption, a neighbouring type still reports, E128082 on a moved type, and the fixer emitting the resolved namespace.
  • scripts/check.sh --all passes: shell, analyzer release, format, build, test.
  • scripts/internal/analyzer-release-check.sh is clean. scripts/readme-table-diff.sh --analyzer reports no drift. README audit is clean.

Review Guide

  • src/E128.Analyzers/Design/ByteSizeType.cs is the whole rule-side change.
  • ByteSizeForDataSizeCodeFixProvider.ResolveByteSizeType and FindByteSizeType are the fixer-side change.
  • Tests in the three ByteSize test files name each scenario.

Rollback

Revert the commit. The rule returns to the full namespace match and the fixer to the hardcoded namespace.

E128080 exempted only Pug.Core.Classes.ByteSize, so a namespace move made
the rule fire on the type's own unit properties. E128082 shared the probe.
Match ByteSize by simple name, whatever its namespace.

The E128080 code fix hardcoded the retired namespace. Resolve the type in
the compilation, add the resolved namespace as a using, and qualify
FromBytes with the resolved name. Bump the package to 3.1.5.
@e128
e128 merged commit 25beb6d into main Nov 17, 2026
2 checks passed
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