-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Derive type names analyzer from AbstractBuiltInCodeStyleDiagnosticAnalyzer #62869
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
Conversation
| protected SimplifyTypeNamesDiagnosticAnalyzerBase() | ||
| : base(ImmutableDictionary<DiagnosticDescriptor, IOption2>.Empty | ||
| .Add(s_descriptorSimplifyNames, null!) | ||
| .Add(s_descriptorSimplifyMemberAccess, null!) | ||
| .Add(s_descriptorPreferBuiltinOrFrameworkType, null!)) // PROTOTYPE: TODO: This was already broken. We have no ctor that matches what this analyzer has (ie, multiple descriptors, with one descriptor having more than one option). | ||
| { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mavasani Two of these descriptors don't have options, and one of them has two options, PreferIntrinsicPredefinedTypeKeywordInMemberAccess and PreferIntrinsicPredefinedTypeKeywordInDeclaration
Are you okay with introducing a new constructor that accepts ImmutableDictionary<DiagnosticDescriptor, ImmutableHashSet<IOption2>>?
Or do you have another suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the options are already added by another analyzer that uses the same ID:
roslyn/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeDiagnosticAnalyzerBase.cs
Line 23 in 02aa5ba
| options: ImmutableHashSet.Create<IOption2>(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mavasani This is something to consider as a follow-up. Should we remove s_descriptorPreferBuiltinOrFrameworkType from SimplifyTypeNamesDiagnosticAnalyzerBase in favor of PreferFrameworkTypeDiagnosticAnalyzerBase? They both use the same code-style options and the same diagnostic id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked by #50307. I forgot I opened such an issue :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything you mentioned in the above comments sounds good to me!
|
@mavasani Can you review please? Thanks! |
|
@mavasani There is an unrelated failure here. |
I tried to move the analyzer to Analyzers layer, but the language-specific implementations depend on internals of workspaces. But I kept the abstract base class in Analyzers.
Fixes #62639