-
Notifications
You must be signed in to change notification settings - Fork 466
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
false-positive for CA1810 #5784
Comments
I'm not certain this is a false positive. Even though the types are defined in a different class, they can still be initialized at a declaration site instead of in this static constructor. |
I am closing the issue, because I think the analyzer pointing this out helps highlight code that can be better optimized. Which is the point of the Analyzer. |
@sharwell Let me know when you are done with your investigation. |
@sharwell Let me know if you want me to close the PR or if you feel like there would be some value. |
Analyzer
Diagnostic ID: CA1810:
Initialize reference type static fields inline
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 6.0.100
Describe the bug
False Positive. Static constructor sets static class fields.
(https://github.com/dotnet/msbuild/blob/797fd829a374a880f63fd4eea4ea6990404c48f4/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs#L39-L49)
Steps To Reproduce
Run the analyzer on the above mentioned code.
Additional context
Using the analyzer on msbuild the related issue is #7179
The text was updated successfully, but these errors were encountered: