Fix RS1038 build errors in analyzer and source generator projects - #48
Open
cobriensr wants to merge 1 commit into
Open
Fix RS1038 build errors in analyzer and source generator projects#48cobriensr wants to merge 1 commit into
cobriensr wants to merge 1 commit into
Conversation
Godot.Analyzers and Godot.SourceGeneration set EnforceExtendedAnalyzerRules and import the shared Godot.Common.CodeAnalysis code, which references Microsoft.CodeAnalysis.CSharp.Workspaces. RS1038 reports this as an error because Workspaces is not available during command-line compilation, which breaks the build from a clean checkout. Godot.Analyzers genuinely needs Workspaces for its code-fix providers (which run in the IDE where Workspaces is available), and Godot.SourceGeneration inherits the reference through the shared code without using any Workspaces APIs. Suppress RS1038 in both projects with an explanatory comment, matching the existing convention already used in Godot.UpgradeAssistant.Providers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Building the repository from a clean checkout (
build.cmd/build.sh) with the pinned .NET SDK fails withRS1038errors inGodot.AnalyzersandGodot.SourceGeneration:Both projects set
EnforceExtendedAnalyzerRulesand import the sharedGodot.Common.CodeAnalysiscode, which referencesMicrosoft.CodeAnalysis.CSharp.Workspaces. RS1038 flags this because the Workspaces assembly is not available during command-line compilation.Fix
Suppress
RS1038in both projects with an explanatory comment, matching the convention already used inGodot.UpgradeAssistant.Providers:Godot.Analyzersgenuinely needs Workspaces for its code-fix providers (CodeFixers/), which run in the IDE where Workspaces is available.Godot.SourceGenerationinherits the reference through the shared code but does not use any Workspaces APIs, so the reference is harmless during command-line compilation.Alternative considered
I also tried moving the Workspaces reference out of the shared
Godot.Common.CodeAnalysis.projitems(so the source generator would not reference Workspaces at all). This resolves RS1038, but removing that reference also removes a version anchor and the dependency graph falls back to a very old, .NET Framework-onlyMicrosoft.CodeAnalysis.CSharp.Workspaces 1.0.1, producingNU1701errors. A proper split of the shared analysis code (so analyzers and code fixes live in separate assemblies) would be a larger change.Testing
Verified locally on Windows with .NET SDK 10.0.103:
build.cmdnow compilesGodot.AnalyzersandGodot.SourceGenerationwith no RS1038 errors, and the unit test suite passes.