-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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 rule CA1002 on sealed classes #88310
False positive for rule CA1002 on sealed classes #88310
Comments
I believe the rule description is talking about inheritance for the collection itself, and not the element type of the collection: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1002#rule-description I'll move this issue to dotnet/runtime to get it triaged. |
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsAnalyzerDiagnostic ID: CA1002: Analyzer sourceNuGet Package: Microsoft.CodeAnalysis.NetAnalyzers Version: 7.0.0 Describe the bugThis rule prevents the use of Generic Lists for inheritance issues, however sealed classes cannot be inherited, so the rule should not apply. I suggest creating an exception for sealed classes. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/sealed Steps To Reproduce
Expected behaviorAnalyzer should not cite CA1002 on sealed classes. Actual behaviorAnalyzer cites CA1002 on sealed classes. Additional contextNone
|
Tagging subscribers to this area: @dotnet/area-system-collections Issue DetailsAnalyzerDiagnostic ID: CA1002: Analyzer sourceNuGet Package: Microsoft.CodeAnalysis.NetAnalyzers Version: 7.0.0 Describe the bugThis rule prevents the use of Generic Lists for inheritance issues, however sealed classes cannot be inherited, so the rule should not apply. I suggest creating an exception for sealed classes. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/sealed Steps To Reproduce
Expected behaviorAnalyzer should not cite CA1002 on sealed classes. Actual behaviorAnalyzer cites CA1002 on sealed classes. Additional contextNone
|
Moving to |
@buyaa-n is this something we should consider addressing for 8.0? |
There is an open PR already in the roslyn-analyzers repo, so we can address it in 8.0. It seems the issue moved here for deciding if we support the suggested fix. For me the suggestion Let me know what you think @eiriktsarpalis @stephentoub |
Analyzer
Diagnostic ID: CA1002:
Do not expose generic lists
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 7.0.0
Describe the bug
This rule prevents the use of Generic Lists for inheritance issues, however sealed classes cannot be inherited, so the rule should not apply. I suggest creating an exception for sealed classes.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/sealed
Steps To Reproduce
Expected behavior
Analyzer should not cite CA1002 on sealed classes.
Actual behavior
Analyzer cites CA1002 on sealed classes.
Additional context
None
The text was updated successfully, but these errors were encountered: