-
Notifications
You must be signed in to change notification settings - Fork 187
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
[Azure.ClientSdk.Analyzers] Refine AZC0030 #9961
base: main
Are you sure you want to change the base?
Conversation
ce95f75
to
a9926ed
Compare
a9926ed
to
4de06d3
Compare
private const string JsonElement = "JsonElement"; | ||
private static readonly string[] suffixes = new string[] { OptionsSuffix }; | ||
|
||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(Descriptors.AZC0030); } } |
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.
Since we want a different behavior for when a model is suffixed with "Options", I've split that functionality into this new class which still shares the original diagnostic ID with GeneralSuffixAnalyzer
. My main motivation was to reduce the blast radius of this change, in the case that users have suppressed the original diagnostic ID. If we feel like these changes warrant a new ID, it should be setup to easily do so.
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.
Good thinking.
private const string JsonElement = "JsonElement"; | ||
private static readonly string[] suffixes = new string[] { OptionsSuffix }; | ||
|
||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(Descriptors.AZC0030); } } |
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.
Good thinking.
private const string JsonElement = "JsonElement"; | ||
private static readonly string[] suffixes = new string[] { OptionsSuffix }; | ||
|
||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(Descriptors.AZC0030); } } |
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.
This pattern will allocate each time the property is called. Since the underlying array is immutable, we should be able to share the same instance.
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(Descriptors.AZC0030); } } | |
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = | |
ImmutableArray.Create(Descriptors.AZC0030); |
if ($"{fullNamespace}".Equals(AzureResourceManagerNamespaceName) | ||
|| $"{fullNamespace}".StartsWith($"{AzureResourceManagerNamespaceName}.")) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; |
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.
if ($"{fullNamespace}".Equals(AzureResourceManagerNamespaceName) | |
|| $"{fullNamespace}".StartsWith($"{AzureResourceManagerNamespaceName}.")) | |
{ | |
return true; | |
} | |
return false; | |
return ($"{fullNamespace}".Equals(AzureResourceManagerNamespaceName) | |
|| $"{fullNamespace}".StartsWith($"{AzureResourceManagerNamespaceName}.")); |
This PR introduces fixes for these items:
sdk-for-net test pr: Azure/azure-sdk-for-net#48597