Repository navigation
Load Stunts analyzers and generator under the .NET Framework compiler - #364
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes analyzer and source generator loading (
CS8032/BC42376) when building with the .NET Framework-hosted C# and VB compilers (csc.exe/vbc.exeof Visual Studio or the compiler toolset package).StuntGeneratorAttributederives fromValidationAttribute, so loadingStunts.dllrequiresSystem.ComponentModel.Annotations. The .NET Framework compiler resolves analyzer dependencies only from analyzer references, so every Stunts analyzer andStuntGeneratorfailed withCS8032(BC42376in VB) and no stunts were generated.Changes
src/Stunts.Package/Stunts.targets: adds the existingtools\5.0\System.ComponentModel.Annotations.dllas an<Analyzer>item at evaluation time (outsideResolveCompileTimeStunts, so analyzers also load when compile-time stunts are off) whenRoslynCompilerTypeisFrameworkorFrameworkPackage, or whenRoslynCompilerTypeis empty under full MSBuild (.NET 8SDK / non-SDK projects). No new files or folders are added to the package.src/Acceptance/framework-compiler.ps1: verifiesCompiledAot,Dynamic, andDynamic.Basicagainst the packed packages with Visual Studio's MSBuild (RoslynCompilerType=Framework,UseSharedCompilation=false,-warnaserror:CS8032;BC42376), asserts the Frameworkcsc.exe/vbc.exewas used, and executes/tests each consumer..github/workflows/build.yml: adds aframework-compilerjob onwindows-latestrunningsrc/Acceptance/framework-compiler.ps1.AGENTS.md: documents the.NET Framework compilerbehavior, whyMicrosoft.Bcl.HashCodeis omitted, and the CI check.This pull request was created by CodeAlta.