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.
Fixes #5636 by setting CA2252 to Error severity.
Customer Impact
We intended for the CA2252 Preview Feature analyzer to produce build errors by default, forcing customers to opt into using preview features. We had validated the experience across our own repos and other existing projects, and that error behavior was experienced. In new projects however, the analyzer was being treated as info-level by default.
The net result is that using APIs marked with
[RequiresPreviewFeatures]
was not yielding build errors by default, even if the customer had not opted in. This means customers are able to unknowingly use preview features. This is a blocker for 6.0 GA that needs to be fixed.Testing
This issue had been missed because we had not conducted end-to-end testing of this analyzer through the .NET CLI or in Visual Studio while working in a brand new project. Instead, all prior testing had been conducted while working in projects that already had the projects configured such that this analyzer's diagnostics would be reported as errors. Therefore the behavior of the analyzer itself had been validated, but its default analysis level of Error had not been validated properly.
Using a private build of the analyzers package, we've now validated that the analyzer has the Error severity as the effective default. This has been validated using both command-line and Visual Studio.
Mitigation of Similar Oversights
Risks
This will surface as a build breaking change for someone who consumed preview APIs in Preview 7, RC1, and RC2 in a new project where they had not opted into using preview features. This is very unfortunate, but it's a necessary effect to ensure we have the expected experience in 6.0 GA.
The following APIs are marked as preview:
System.Runtime.Experimental
packageSystem.Runtime.Intrinsics.X86.AvxVnni
Microsoft.AspNetCore.Server.Kestrel.Core.Http3
Microsoft.AspNetCore.Server.Kestrel.Core.Http1AndHttp2AndHttp3
Microsoft.AspNetCore.Hosting.WebHostBuilderQuicExtensions.UseQuic