Skip to content

Commit 240e901

Browse files
committed
Fix SA1612 after updates to base analyzer
1 parent ab398f7 commit 240e901

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ public SA1612ElementParameterDocumentationMustMatchElementParameters()
6161
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, IEnumerable<XmlNodeSyntax> syntaxList, params Location[] diagnosticLocations)
6262
{
6363
var node = context.Node;
64-
var identifierLocation = GetIdentifier(node).GetLocation();
64+
var identifier = GetIdentifier(node);
65+
66+
bool supportedIdentifier = identifier != null;
67+
if (!supportedIdentifier)
68+
{
69+
return;
70+
}
71+
72+
var identifierLocation = identifier.Value.GetLocation();
6573
var parameterList = GetParameters(node)?.ToImmutableArray();
6674

6775
bool hasNoParameters = !parameterList?.Any() ?? false;
@@ -82,7 +90,15 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, IEnu
8290
protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, XElement completeDocumentation, params Location[] diagnosticLocations)
8391
{
8492
var node = context.Node;
85-
var identifierLocation = GetIdentifier(node).GetLocation();
93+
var identifier = GetIdentifier(node);
94+
95+
bool supportedIdentifier = identifier != null;
96+
if (!supportedIdentifier)
97+
{
98+
return;
99+
}
100+
101+
var identifierLocation = identifier.Value.GetLocation();
86102
var parameterList = GetParameters(node)?.ToImmutableArray();
87103

88104
bool hasNoParameters = !parameterList?.Any() ?? false;
@@ -141,11 +157,11 @@ private static IEnumerable<ParameterSyntax> GetParameters(SyntaxNode node)
141157
?? (node as DelegateDeclarationSyntax)?.ParameterList?.Parameters;
142158
}
143159

144-
private static SyntaxToken GetIdentifier(SyntaxNode node)
160+
private static SyntaxToken? GetIdentifier(SyntaxNode node)
145161
{
146162
return (node as MethodDeclarationSyntax)?.Identifier
147163
?? (node as IndexerDeclarationSyntax)?.ThisKeyword
148-
?? (node as DelegateDeclarationSyntax).Identifier;
164+
?? (node as DelegateDeclarationSyntax)?.Identifier;
149165
}
150166
}
151167
}

0 commit comments

Comments
 (0)