-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround: Fixing analyzer build errors on VS2019 v16.9 #1026
Conversation
@bording has much more context in this area. I defer to him |
haven't updated yet, but I plan to, I can report back once I have. How many failures does it raise? Maybe it's quicker to analyse and either fix or change the rule. |
Almost 200. Ranging from implementing IDisposable properly to proper exception constructors etc.. Not an easy fix. |
B.t.w, I'm not saying we shouldn't fix the issues. Just workaround it for now and create PRs later with proper fixes for them. These analysers are also automatically enabled on net5.0 projects, so it'd be a good preparation to fix them properly. |
@@ -33,6 +33,7 @@ | |||
|
|||
<PropertyGroup> | |||
<AnalysisMode>AllEnabledByDefault</AnalysisMode> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most extreme mode that the analyzers can be set to. Only a handful of rules are enabled by default, so this is opting in to all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. I'll take a closer look tomorrow and see if I can get it back to the previous behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change it to "Default" then only a hand full of warnings are left that you've already fixed anyway.
@@ -33,6 +33,7 @@ | |||
|
|||
<PropertyGroup> | |||
<AnalysisMode>AllEnabledByDefault</AnalysisMode> | |||
<EnableNETAnalyzers>false</EnableNETAnalyzers> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would a way to globally disable the analyzers, though since this project isn't targeting net5.0
, they are already disabled by default. Seems like this is redundant at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this line so they aren't all disabled now.
Updated to not completely remove the analyzers and only remove the feature enabling all of them at the same time. Thanks for taking a look @bording. |
@@ -67,7 +63,7 @@ | |||
<PackageReference Include="MinVer" Version="2.4.0" PrivateAssets="All" /> | |||
<PackageReference Include="System.Memory" Version="4.5.4" /> | |||
<PackageReference Include="System.Threading.Channels" Version="5.0.0" /> | |||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.1" /> | |||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what version of the .NET SDK we're using to build against in CI? If we can just update to a .NET 5 SDK, I'd prefer to do that over explicitly adding a package reference to the analyzer.
Then we just need to have <EnableNETAnalyzers>true</EnableNETAnalyzers>
in the project file to enable the default set of analyzers to run against this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RabbitMQ's Concourse uses
dotnet-sdk-3.1
dotnet-runtime-2.1
I could not get .NET 5 build 3.1 apps without surprising failures (I no longer remember the details). I'd be all for moving to use .NET 5 (but target .NET Core 3.1+ for now) but perhaps it should be a separate PR.
Sounds good. I'll rebase to fix the merge errors. |
@michaelklishin rebase done :) |
Thank you! |
Proposed Changes
VS 2019 automatically enables nullable checks and some analyzers for projects. To avoid builds failing when developing locally I disabled the .NET analyzers for the time being until they can be reviewed and fixed properly.
Would be nice if someone can confirm this behavior before and after: @bollhals @danielmarbach
Types of Changes
Checklist
CONTRIBUTING.md
document