Skip to content

Fix CS0436 on Release builds: host wrapper attributes in Reactor.Wrappers.Abstractions - #602

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 2 commits into
mainfrom
alzollin/wrappers-abstractions-cs0436
Jun 17, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 2 commits into
mainfrom
alzollin/wrappers-abstractions-cs0436

Conversation

@azchohfi

Copy link
Copy Markdown
Collaborator

Fixes #601.

Problem

ADO Release builds fail with CS0436 in Reactor.AppTests.Host (the pipelines pass -p:TreatWarningsAsErrors=true). The wrapper generator emitted its authoring marker attributes into every compilation via RegisterPostInitializationOutput; because src/Reactor also runs the generator, the internal copies landed in Reactor.dll and leaked through InternalsVisibleTo into Reactor.AppTests.Host (which also runs the generator), colliding with the locally generated copy. Harmless warning in Debug, fatal under warnings-as-errors.

Fix

Host the 13 authoring attributes ([GenerateReactorWrapper], [WrapControlled], …) in a dedicated assembly src/Reactor.Wrappers.Abstractions (public types, IsPackable=false) referenced by every consumer; the generator no longer emits them and binds them by metadata name. One definition → nothing to collide.

  • Reactor.csproj references it PrivateAssets="all" and bundles the DLL into the package lib/ via a _BundleWrappersAbstractions (BuildOutputInPackage) target — so no phantom NuGet dependency, and the package stays self-contained (same pattern the repo already uses to bundle its analyzer DLLs into Reactor).
  • The 3 in-repo authoring consumers (AppTests.Host, WctControls, Reactor.Tests) reference the project directly — PrivateAssets blocks transitive flow (verified: without it, WctControls fails with 57× CS0246).
  • Removed the AttributeSource const + post-init registration from the generator.
  • Marked DescriptorOnlyProofControl partial — a latent CsWinRT1028 that the CS0436 compile failure had been masking.
  • Updated spec 058 §3 / §15.7 (the old "IVT collision — NOT A PROBLEM" claim was the exact wrong assumption) and added a regression test.

Verification

  • Reactor.AppTests.Host Release/x64 with -p:TreatWarningsAsErrors=true: 0 warnings, 0 errors (was 13× CS0436).
  • WctControls (non-IVT consumer) Release/warnings-as-errors: clean.
  • All WrappersGenerator unit tests pass, incl. the new Generator_DoesNotEmit_TheAuthoringAttribute and the reflection-based DescriptorSilentDropGuardTests.
  • dotnet pack src/Reactor: Reactor.Wrappers.Abstractions.dll lands in lib/net10.0-windows10.0.22621/ exactly once, and the .nuspec has no Reactor.Wrappers.Abstractions dependency.

Note: the attribute fidelity was confirmed via a semantic diff against the deleted generator AttributeSource — identical ctor signatures, properties, AttributeUsage/AllowMultiple; the only change is internal sealed → public sealed.

…ions

The wrapper generator emitted its authoring marker attributes into every
compilation via RegisterPostInitializationOutput. Because src/Reactor runs the
generator, the internal copies landed in Reactor.dll and leaked through
InternalsVisibleTo into Reactor.AppTests.Host (which also runs the generator),
where the locally generated copy collided with the imported one (CS0436). This
was a harmless warning in Debug but failed ADO Release builds, which pass
-p:TreatWarningsAsErrors=true.

Move the 13 authoring attributes into a dedicated assembly,
src/Reactor.Wrappers.Abstractions (public types, IsPackable=false), referenced
by every consumer; the generator no longer emits them and binds them by metadata
name. With a single definition there is no duplicate to collide.

- Reactor references it PrivateAssets="all" and bundles the DLL into the package
  lib/ via a BuildOutputInPackage target (no phantom NuGet dependency).
- In-repo consumers (AppTests.Host, WctControls, Reactor.Tests) reference it
  directly, since PrivateAssets blocks transitive flow.
- Mark DescriptorOnlyProofControl partial (a latent CsWinRT1028 unmasked once the
  CS0436 compile failure cleared).
- Update spec 058 (the old "IVT collision - NOT A PROBLEM" claim) + add a
  regression test that the generator no longer emits the attribute.

Fixes #601

Co-authored-by: Copilot <[email protected]>
…eferences

The CI Pack step runs `dotnet pack --no-build`. The _BundleWrappersAbstractions
target used DependsOnTargets="ResolveReferences", which forced reference
resolution at pack time and invoked the Build target on the analyzer
project-references under NoBuild -> NETSDK1085.

The abstractions DLL is a runtime reference, so the (already completed) build
copied it into $(TargetDir); read it directly from there instead. Works under a
NoBuild pack and still bundles the DLL into lib/ exactly once (verified).

Co-authored-by: Copilot <[email protected]>
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit a22ac9a into main Jun 17, 2026
17 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the alzollin/wrappers-abstractions-cs0436 branch June 17, 2026 23:39
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.

CS0436 on ADO Release builds: wrapper-generator marker attributes collide via InternalsVisibleTo

1 participant