Closed sassy224 closed 4 years ago
@sassy224 : CA1829 is an IDE suggestion by default, not a warning. See default severities and enabled by default values for all CA rules shipping in .NET5 release over here: https://github.com/dotnet/roslyn-analyzers/blob/master/src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md. You may want to refer to https://docs.microsoft.com/dotnet/fundamentals/productivity/code-analysis#enable-additional-rules to enable additional CA rules as build warnings.
@mavasani my point is I was expecting that, for .Net Framework projects, I only need to set EnableNETAnalyzers = true to be able to use the Roslyn analyzers with its default rules which is good enough for me. Even if I add .editorconfig file, and modify severity, it will have no effect at all. With .Net 5 project, you can edit .editorconfig file, modify severities and it will work out of the box. According to MS's document, in .Net Framework, we only need to set EnableNETAnalyzers=true to have that effect. This issue is to report that it's not working yet.
@sassy224 just to confirm- you are on the .NET5 Preview8 or later SDK correct? That is the first SDK version with built in analyzers. You can target .NetFramework and get all the analyzers, but you need to be on the .Net5 SDK
Also can you check if you open your project in VS2019 16.8 Preview3, do you see an IDE suggestion diagnostic for CA1829 with a code fix?
just to confirm- you are on the .NET5 Preview8 or later SDK correct? That is the first SDK version with built in analyzers. You can target .NetFramework and get all the analyzers, but you need to be on the .Net5 SDK
I see, I was using the old .Net Framework project, not the new SDK-style one.
To confirm, will there be any differences if I build my library using below approaches?
Currently my projects are using old .Net Framework csproj, I'm very hesitant about converting them to new SDK csproj.
will there be any differences if I build my library using below approaches?
I would like to say no, but I am probably not the best or most authoritative person to state that. Likely post a question on dotnet/project-system repo?
Currently my projects are using old .Net Framework csproj, I'm very hesitant about converting them to new SDK csproj.
One other alternative for you is to directly reference the NuGet package linked at https://github.com/dotnet/roslyn-analyzers#microsoftcodeanalysisnetanalyzers. Then you don't need to change to SDK style project file. We do plan to release a 5.0.0 stable NuGet package corresponding to the .NET5 SDK release, so you can switch to that whenever it is published.
I would like to say no, but I am probably not the best or most authoritative person to state that. Likely post a question on dotnet/project-system repo
Thanks, I posted issue there
One other alternative for you is to directly reference the NuGet package linked at https://github.com/dotnet/roslyn-analyzers#microsoftcodeanalysisnetanalyzers. Then you don't need to change to SDK style project file. We do plan to release a 5.0.0 stable NuGet package corresponding to the .NET5 SDK release, so you can switch to that whenever it is published
Thanks for the suggestion, I will consider it as last resort after I get confirmation about the assembly differences.
Got the answer I need so close the issue for now.
Analyzer
N/A
Analyzer source
N/A
Describe the bug
Trying to enable EnableNETAnalyzers for .Net Framework projects but they are not working/having effects.
Steps To Reproduce for .Net Framework projects
Create .Net Framework with below sample code
Expected behavior
Warning CA1829 should be shown.
Actual behavior
No warning is shown
Additional context
=================================== Add any other context about the problem here. I know that install package Microsoft.CodeAnalysis.FxCopAnalyzers will enable analyzers for all projects (.Net Framework, .Net Standard, .Net Core, .Net 5) however, it will create additional package dependency so I want to use .editorconfig + EnableNETAnalyzers to enable new Roslyn analyzers. As mentioned here: https://github.com/dotnet/roslyn-analyzers#microsoftcodeanalysisnetanalyzers