Skip to content

feat(shims): suppress SHIM001 for consumer-bridged types (#69 follow-up)#141

Merged
ChrisonSimtian merged 1 commit into
mainfrom
feature/69-shim001-suppress-handbridged
May 24, 2026
Merged

feat(shims): suppress SHIM001 for consumer-bridged types (#69 follow-up)#141
ChrisonSimtian merged 1 commit into
mainfrom
feature/69-shim001-suppress-handbridged

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Summary

Cleans up the 20 SHIM001 warnings left over from session 4 (the 10 CI host singleton hand-bridges × 2 referenced-assembly paths).

The TransitionShimGenerator now pre-walks the consuming compilation's own namespaces under the target shim prefix and collects FQNs of every top-level public type the consumer has hand-written. When the canonical-side walk would emit a shim for a type whose target FQN already exists in that set, the generator silently defers to the hand-bridge — no source emitted, no SHIM001 diagnostic.

Why no annotation?

Considered an explicit [assembly: SkipShimForCanonical(typeof(...))] marker. Rejected because:

  • The generator already auto-discovers everything from the canonical assembly walk; symmetry says consumer-side hand-writes should be auto-discovered too.
  • The hand-bridge file itself is the source of truth — adding a parallel attribute would risk drift.
  • Implicit detection works for the CI hosts (session 4) AND the existing NukeBuild hand-bridge in Nuke.Common.NukeBuild.cs and any future hand-bridges with zero ceremony.

A canonical name + arity match via INamedTypeSymbol.MetadataName keeps arity-correctness for generics.

Live impact

Before this PR (the Nuke.Common shim build):

Kind Count
enum 76
no-accessible-ctor 28
delegate 14
struct 4
ambiguous-across-assemblies 4
sealed-class 2

After:

Kind Count Change
enum 76
no-accessible-ctor 8 −20 (the 10 CI hosts × 2 paths)
delegate 14
struct 4
ambiguous-across-assemblies 4
sealed-class 2

The 4 remaining unique no-accessible-ctor types — AbsolutePath, AzureKeyVault, MSBuildProject, DelegateDisposable — are the natural session-5 candidates.

Verification

  • New generator test SkipsCanonicalTypesAlreadyHandBridgedByConsumer covers both the sealed-class case (would otherwise warn) and the regular-class case (would otherwise emit). Both should be silent when a hand-bridge exists.
  • 6/6 Fallout.SourceGenerators.Tests pass — no snapshot regression on the existing 5.
  • Nuke.Common shim builds clean (0 errors) with the 20 CI host SHIM001 warnings now silent.
  • tests/Nuke.Common.Shim.Tests still builds clean.

Test plan

  • CI green
  • Live shim build: confirm the 10 CI host SHIM001 warnings are gone
  • Existing NukeBuild hand-bridge is also auto-discovered (no behavior change there since the canonical name is FalloutBuild, not NukeBuild — different name, no collision)

🤖 Generated with Claude Code

The TransitionShimGenerator pre-pass now walks the consuming compilation's
own namespaces and collects FQNs of every top-level public type under the
target shim prefix. When the canonical-side walk would emit (or warn-skip) a
type whose target FQN already exists in that set, the generator silently
defers to the hand-written bridge — no source emitted, no SHIM001.

Drops 20 of the live SHIM001 warnings on the Nuke.Common shim build (the 10
CI host singletons × 2 referenced-assembly paths from session 4). Remaining
SHIM001 counts: 76 enum, 14 delegate, 8 no-accessible-ctor (4 unique:
AbsolutePath, AzureKeyVault, MSBuildProject, DelegateDisposable), 4 struct,
4 ambiguous-across-assemblies, 2 sealed-class (GlobbingOptionsAttribute).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ChrisonSimtian
ChrisonSimtian merged commit 139fe6b into main May 24, 2026
1 check passed
@ChrisonSimtian
ChrisonSimtian deleted the feature/69-shim001-suppress-handbridged branch May 24, 2026 03:16
ChrisonSimtian added a commit that referenced this pull request May 24, 2026
…types (#69 session 5) (#142)

DelegateDisposable falls in the no-accessible-ctor bucket (private ctor), but
unlike the other 3 candidates it exposes its full surface via public static
factories (CreateBracket × 2, SetAndRestore). A static-class shim re-exposing
those factories actually helps real consumers — the factories return the
canonical IDisposable, so calls flow through naturally.

For the other 3 no-accessible-ctor types, hand-bridges would be empty or
decorative:
- AbsolutePath: dominant consumer usage is implicit string/AbsolutePath
  conversion and operator/ — neither can be carried by a static-class shim
- AzureKeyVault, MSBuildProject: zero public statics, framework-constructed
  only; nothing to re-expose

These three are documented as fallout-migrate rename targets in a new
"What's NOT covered (and won't be)" README section.

Drops 2 SHIM001 warnings (DelegateDisposable × 2 referenced-assembly paths)
via the suppression mechanism from #141. Remaining no-accessible-ctor types
in the live build (AbsolutePath, AzureKeyVault, MSBuildProject) are exactly
the three documented fallout-migrate targets.

Co-authored-by: Claude Opus 4.7 (1M context) <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.

1 participant