Skip to content

Commit 4414f0c

Browse files
committed
Simplify access to SA1307's descriptor
1 parent 78d9aa3 commit 4414f0c

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ internal class SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter : Diag
4545

4646
private static readonly Action<SyntaxNodeAnalysisContext> FieldDeclarationAction = HandleFieldDeclaration;
4747

48-
private static readonly DiagnosticDescriptor SA1307Descriptor =
49-
new SA1307AccessibleFieldsMustBeginWithUpperCaseLetter().SupportedDiagnostics.Single();
50-
5148
/// <inheritdoc/>
5249
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
5350
ImmutableArray.Create(Descriptor);
@@ -87,7 +84,7 @@ private static void HandleFieldDeclaration(SyntaxNodeAnalysisContext context)
8784
{
8885
// SA1307 is taken precedence here. SA1307 should be reported if the field is accessible.
8986
// So if SA1307 is enabled this diagnostic will only be reported for internal fields.
90-
if (!context.IsAnalyzerSuppressed(SA1307Descriptor))
87+
if (!context.IsAnalyzerSuppressed(SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.Descriptor))
9188
{
9289
return;
9390
}

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ internal class SA1307AccessibleFieldsMustBeginWithUpperCaseLetter : DiagnosticAn
3737
private const string Description = "The name of a public or internal field in C# does not begin with an upper-case letter.";
3838
private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1307.md";
3939

40-
private static readonly DiagnosticDescriptor Descriptor =
40+
#pragma warning disable SA1202 // Elements should be ordered by access
41+
internal static readonly DiagnosticDescriptor Descriptor =
4142
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink);
43+
#pragma warning restore SA1202 // Elements should be ordered by access
4244

4345
private static readonly Action<SyntaxNodeAnalysisContext> FieldDeclarationAction = HandleFieldDeclaration;
4446

0 commit comments

Comments
 (0)