fix: compiler-version (and other) warnings #69
Merged
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.
Just as a heads-up, this change moves the code fix into a separate package (explanation below), which may warrant some additional scrutiny before merging.
Analyzers/generators in LogicBlocks depend on v4.12.0-final of Microsoft.CodeAnalysis packages. That causes the resulting DLLs to reference v4.12.0 of the compiler, which is newer than v4.11.0 currently shipped. That in turn causes a
CS9057
warning both when compiling LogicBlocks projects that depend on the analyzers, and in user projects referencing LogicBlocks:To fix this, I've rolled back those Microsoft.CodeAnalysis references to v4.11. This causes the compiler to warn that analyzers and generators should now have the project property
EnforceExtendedAnalyzerRules
turned on:After enabling that property, other warnings are generated, notably
RS1038
in LogicBlocks.Analyzers andRS1035
in LogicBlocks.DiagramGenerator:RS1038
A (new?) rule provides that analyzers and code fixes shouldn't exist in the same assembly, since code fixes rely on the Workspaces package, which is not available for command-line builds. To rectify this, I've moved the code fix into a separate assembly, LogicBlocks.CodeFixes. Additionally, I've put a reference to the code-fix assembly in the Example project, and I've also included it into the main LogicBlocks package.
I've used
ProjectReference
s in one of my own local projects to verify that IntelliSense and the compiler still pick up the error about the missing[LogicBlock]
attribute with the split-out code-fix package:RS1035
This warns that analyzers should not do file I/O. Since that's the whole purpose of the DiagramGenerator project, I don't see a fix or a workaround for this. Therefore I've just suppressed it in the project settings. (There's also an instance of the same warning code enforcing that analyzers should not access
Environment
properties, referring to the use ofEnvironment.NewLine
. However, issue 6467 at the dotnet/roslyn-analyzers project contains an open discussion about whetherNewLine
should be an exception, so I haven't changed anything there.)RS1039
This was warning that the
Tester.GetSymbol
method, in GeneratorTester, invokedSemanticModel.GetDeclaredSymbol
on aSyntaxNode
, which always returns null for certain subclasses ofSyntaxNode
. However, that code was unused, so I've removed it rather than address nullability or anything.