-
Notifications
You must be signed in to change notification settings - Fork 469
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
CA1812 should not warn for top-level Program classes #5628
Comments
I think this was recently fixed by @Youssef1313 |
Yeah I believe it should have been fixed. Not aware which version contains the fix though. |
Anything required beyond adding the package? Doesn't seem to have any effect if I add the relevant feed to <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.21513.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup> |
Likely fixed in #5351. |
Thanks @Youssef1313 |
This still occurs in the latest RC (6.0.100-rc.2.21505.57), see https://github.com/adamralph/minver/runs/4132244037?check_suite_focus=true Weirdly, it's only a problem on Windows and MacOS, but not Linux. Is the intention to fix this before RTM? |
Yeah I've seen this not fixed in 6.0.0/6.0.100 either, but that's already been built and ships today so would need backporting to 6.0.1. |
@martincostello I realise RTM is tomorrow, but all I see at https://dotnet.microsoft.com/download/dotnet/6.0 is 6.0.100-rc.2.21505.57. |
I believe it's shipping today ahead of .NET Conf tomorrow - the 6.0.0 packages are all in NuGet.org now (I woke up this morning to various dependabot updates), and the |
sadly, no by the time the fix was merged final builds of .NET 6 were already spinning for today. Considering CA1812 is off by default I don't think this meets the bar to port as a day 0 fix. but I will pursue it for the 6.0.200 SDK release |
@jmarolf |
It is fixed in 7.0.0-preview1.22168.1.
|
Any updates on this fix? @Youssef1313 as .NET 6 is in LTS it makes sense to backport it |
@mavasani @jmarolf Can you comment on whether this can be backported? |
Tagging @buyaa-n |
As @jmarolf mentioned the analyzer is off by default and there is a workaround (suppress), therefore this does not meet the bar for servicing 6.0, I guess it could be considered if 1st party customer requesting it |
Just to share with others who might be encountering this, I was able to disable this for all projects in my solution by putting this in the # Workaround for https://github.com/dotnet/roslyn-analyzers/issues/5628
[Program.cs]
dotnet_diagnostic.ca1812.severity = none |
Closing as this is fixed in 7.x and doesn't meet the bar to backport for 6.x |
Which version is this fixed from? I'm still getting a warning if I create a new console project and enable the |
@kimsey0 I think the fix didn't yet flow into the .NET SDK. Can you try with 7.0.0 from NuGet.org? |
That does indeed seem to fix it. I just assumed that since Microsoft.CodeAnalysis.NetAnalyzers 7.0.0 was released on December 8th and .NET SDK 7.0.1 was released on December 13th, it would include the newest analyzers, but there might be a bit of a delay for the flow. (7.0.1 is also marked as a security patch, so I don't know if that influences anything.) I hope the analyzer changes will be out in the next SDK release. :-) |
Analyzer
Diagnostic ID: CA1812
Describe the improvement
An application that uses top-level programs and uses an analysis rule set that includes CA1812 will generate a warning from the compiler-generated
Program
class in even a trivial application.This then requires the developer to suppress it like so:
Describe suggestions on how to achieve the rule
Special-case compiler-generated
Program
classes for top-level programs and do not emit the violation.Additional context
Application that reproduces the problem adapted from
dotnet new console
using the .NET 6 RC2 SDK.The text was updated successfully, but these errors were encountered: