You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CA1822 needs to be updated to include referencing primary constructor parameters as accessing "instance" state. Right now, it suggests marking members that only access PC parameters as static, which is incorrect. See the screenshots reported here: dotnet/csharplang#7377 (reply in thread)
Steps To Reproduce
Create a new project with .NET 8 and enable analysis.
Create a type with a primary constructor.
Try one of the code samples in the linked comment, such as having an expression-bodied property return a PC parameter.
Expected behavior
No warnings.
Actual behavior
CA1822 is issued.
Additional context
This is a C# 12 feature, may require updating the roslyn reference in tests to use.
The text was updated successfully, but these errors were encountered:
Analyzer
Diagnostic ID: CA1822:
Mark members as static
Analyzer source
SDK: Built-in CA analyzers in .NET 8p6 SDK or later
Version: SDK 8.0.0-preview6
Describe the bug
CA1822 needs to be updated to include referencing primary constructor parameters as accessing "instance" state. Right now, it suggests marking members that only access PC parameters as static, which is incorrect. See the screenshots reported here: dotnet/csharplang#7377 (reply in thread)
Steps To Reproduce
Expected behavior
No warnings.
Actual behavior
CA1822 is issued.
Additional context
This is a C# 12 feature, may require updating the roslyn reference in tests to use.
The text was updated successfully, but these errors were encountered: