Add Microsoft.Net.Compilers.Toolset reference so the internal source generator loads#5041
Merged
tig merged 1 commit intogui-cs:developfrom Apr 21, 2026
Merged
Conversation
Adds the Microsoft.Net.Compilers.Toolset package reference to align the Roslyn compiler version with the Terminal.Gui.Analyzers.Internal source generator. The analyzer targets Microsoft.CodeAnalysis.CSharp 5.3.0, but without this toolset, MSBuild uses the SDK-bundled Roslyn 5.0.0 host which refuses to load analyzers targeting a newer compiler. This caused warning CS9057 and 233 CS1061 errors about missing FastHasFlags/FastIsDefined/AsInt32/AsUInt32 members because the EnumExtensionMethodsGenerator was silently skipped.
This was referenced May 4, 2026
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.
Problem
On
develop(currently956ba448b), a cleandotnet restore && dotnet build --configuration Debug --no-restorefails with 233CS1061errors about missingFastHasFlags,FastIsDefined,AsInt32, andAsUInt32members onMouseFlags,ViewportSettingsFlags,ViewArrangement,DimAutoStyle,KeyCode, and others. Those members are emitted byEnumExtensionMethodsGeneratorinTerminal.Gui.Analyzers.Internal.The build also prints this warning, which is the actual cause:
The analyzer project is compiled against
Microsoft.CodeAnalysis.CSharp5.3.0 (pinned inDirectory.Packages.props), butTerminal.Gui.csprojdoes not referenceMicrosoft.Net.Compilers.Toolset, so MSBuild falls back to the Roslyn 5.0.0 host bundled with the .NET SDK (10.0.100 through at least 10.0.104). That host refuses to load analyzers targeting a newer compiler, the generator is silently dropped, and the solution fails to build.Microsoft.Net.Compilers.Toolset5.3.0 is already pinned inDirectory.Packages.propsand already used byTests/AppTestHelpers.XunitHelpers/AppTestHelpers.XunitHelpers.csproj. It just never got wired intoTerminal.Gui.csprojwhen the generator was introduced in 12eae5e.Fix
Add the toolset
PackageReferencealongside the analyzerProjectReferenceinTerminal.Gui/Terminal.Gui.csproj:This is the officially documented remedy for
CS9057(see the Roslyn wiki's NuGet packages page: "Installing this package overrides the compiler toolset installed in MSBuild"). The package is dev-only, soPrivateAssets="all"keeps it out of consumers ofTerminal.Gui.Verification
After the change, on .NET SDK 10.0.104:
$ dotnet build --configuration Debug --no-restore ... Build succeeded. 0 Warning(s) 0 Error(s)No more
CS9057, generator loads, solution builds clean.To pull down this PR locally: