Skip to content

Conversation

@Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jul 22, 2022

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

@ghost ghost added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Jul 22, 2022
Comment on lines 73 to 79
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).
{
}
Copy link
Member Author

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?

Copy link
Member Author

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:

options: ImmutableHashSet.Create<IOption2>(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess),

Copy link
Member Author

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.

Copy link
Member Author

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 :)

Copy link
Contributor

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!

@Youssef1313
Copy link
Member Author

@mavasani Can you review please? Thanks!

@mavasani mavasani enabled auto-merge August 9, 2022 12:35
@Youssef1313
Copy link
Member Author

@mavasani There is an unrelated failure here.

@mavasani mavasani merged commit 02b8f24 into dotnet:main Aug 9, 2022
@ghost ghost added this to the Next milestone Aug 9, 2022
@Youssef1313 Youssef1313 deleted the move-simplify-type-names branch August 9, 2022 17:23
@dibarbet dibarbet modified the milestones: Next, 17.4 P2 Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SimplifyTypeNamesDiagnosticAnalyzerBase should sub-type AbstractBuiltInCodeStyleDiagnosticAnalyzer

3 participants