Skip to content

Load Stunts analyzers and generator under the .NET Framework compiler - #364

Merged
kzu merged 1 commit into
mainfrom
dev/framework
Nov 29, 2026
Merged

kzu merged 1 commit into
mainfrom
dev/framework

Conversation

@kzu

@kzu kzu commented Nov 29, 2026

Copy link
Copy Markdown
Member

Summary

Fixes analyzer and source generator loading (CS8032 / BC42376) when building with the .NET Framework-hosted C# and VB compilers (csc.exe / vbc.exe of Visual Studio or the compiler toolset package).

StuntGeneratorAttribute derives from ValidationAttribute, so loading Stunts.dll requires System.ComponentModel.Annotations. The .NET Framework compiler resolves analyzer dependencies only from analyzer references, so every Stunts analyzer and StuntGenerator failed with CS8032 (BC42376 in VB) and no stunts were generated.

Changes

  • src/Stunts.Package/Stunts.targets: adds the existing tools\5.0\System.ComponentModel.Annotations.dll as an <Analyzer> item at evaluation time (outside ResolveCompileTimeStunts, so analyzers also load when compile-time stunts are off) when RoslynCompilerType is Framework or FrameworkPackage, or when RoslynCompilerType is empty under full MSBuild (.NET 8 SDK / non-SDK projects). No new files or folders are added to the package.
  • src/Acceptance/framework-compiler.ps1: verifies CompiledAot, Dynamic, and Dynamic.Basic against the packed packages with Visual Studio's MSBuild (RoslynCompilerType=Framework, UseSharedCompilation=false, -warnaserror:CS8032;BC42376), asserts the Framework csc.exe/vbc.exe was used, and executes/tests each consumer.
  • .github/workflows/build.yml: adds a framework-compiler job on windows-latest running src/Acceptance/framework-compiler.ps1.
  • AGENTS.md: documents the .NET Framework compiler behavior, why Microsoft.Bcl.HashCode is omitted, and the CI check.

This pull request was created by CodeAlta.

Under the .NET Framework compilers (csc.exe and vbc.exe of Visual Studio
or the compiler toolset package), every Stunts analyzer and
StuntGenerator failed with CS8032 (BC42376 in Visual Basic) because
StuntGeneratorAttribute derives from ValidationAttribute and
System.ComponentModel.Annotations was not among the analyzer references.
Because CS8032 is a warning, builds succeeded with no generated stunts.

Stunts.targets now adds tools\5.0\System.ComponentModel.Annotations.dll
as an Analyzer item when RoslynCompilerType is Framework or
FrameworkPackage, or when RoslynCompilerType is empty under full MSBuild
(e.g. .NET 8 SDK or non-SDK projects). The item sits outside
ResolveCompileTimeStunts so the analyzers also load when compile-time
stunts are disabled, and adds no new files to the package.

Also adds src/Acceptance/framework-compiler.ps1 and a framework-compiler
CI job on windows-latest that compiles CompiledAot, Dynamic, and
Dynamic.Basic with Visual Studio's MSBuild and RoslynCompilerType=Framework
treating CS8032/BC42376 as errors, and documents the behavior in AGENTS.md.

Co-authored-by: CodeAlta <noreply@codealta.io>
@kzu kzu added the bug Something isn't working label Nov 29, 2026
@kzu
kzu enabled auto-merge (rebase) November 29, 2026 18:11
@kzu
kzu merged commit 86c0c4b into main Nov 29, 2026
7 checks passed
@kzu
kzu deleted the dev/framework branch November 29, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant