7
7
[ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
8
8
public class AvoidStringlyTypedApisAnalyzer : DiagnosticAnalyzer
9
9
{
10
- internal const string DiagnosticId = DiagnosticIds . AvoidStringlyTypedApis ;
10
+ private const string DiagnosticId = DiagnosticIds . AvoidStringlyTypedApis ;
11
11
private const string Title = "Avoid stringly-typed APIs" ;
12
12
private const string MessageFormat = "Use 'nameof({0})' instead of the string literal \" {0}\" " ;
13
- private const string Description = "Replace string literals representing member names with the nameof operator to ensure type safety." ;
13
+
14
+ private const string Description =
15
+ "Replace string literals representing member names with the nameof operator to ensure type safety." ;
16
+
14
17
private const string Category = "Refactoring" ;
15
18
16
19
private static readonly DiagnosticDescriptor Rule = new (
@@ -21,7 +24,8 @@ public class AvoidStringlyTypedApisAnalyzer : DiagnosticAnalyzer
21
24
DiagnosticSeverity . Warning ,
22
25
isEnabledByDefault : true ,
23
26
description : Description ,
24
- helpLinkUri : $ "https://github.com/rjmurillo/EffectiveCSharp.Analyzers{ ThisAssembly . GitCommitId } /docs/{ DiagnosticId } .md") ;
27
+ helpLinkUri :
28
+ $ "https://github.com/rjmurillo/EffectiveCSharp.Analyzers{ ThisAssembly . GitCommitId } /docs/{ DiagnosticId } .md") ;
25
29
26
30
/// <inheritdoc/>
27
31
public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics => ImmutableArray . Create ( Rule ) ;
@@ -45,7 +49,8 @@ private static void AnalyzeLiteralExpression(SyntaxNodeAnalysisContext context)
45
49
46
50
SemanticModel semanticModel = context . SemanticModel ;
47
51
48
- if ( containingClass != null && semanticModel . GetDeclaredSymbol ( containingClass , context . CancellationToken ) is { } containingTypeSymbol )
52
+ if ( containingClass != null
53
+ && semanticModel . GetDeclaredSymbol ( containingClass , context . CancellationToken ) is { } containingTypeSymbol )
49
54
{
50
55
IEnumerable < string > memberNames = containingTypeSymbol . GetMembers ( ) . Select ( member => member . Name ) ;
51
56
@@ -56,7 +61,8 @@ private static void AnalyzeLiteralExpression(SyntaxNodeAnalysisContext context)
56
61
}
57
62
}
58
63
59
- if ( containingMethod != null && semanticModel . GetDeclaredSymbol ( containingMethod , context . CancellationToken ) is { } methodSymbol )
64
+ if ( containingMethod != null
65
+ && semanticModel . GetDeclaredSymbol ( containingMethod , context . CancellationToken ) is { } methodSymbol )
60
66
{
61
67
IEnumerable < string > parameterNames = methodSymbol . Parameters . Select ( parameter => parameter . Name ) ;
62
68
0 commit comments