@@ -59,54 +59,33 @@ public SA1613ElementParameterDocumentationMustDeclareParameterName()
5959 /// <inheritdoc/>
6060 protected override void HandleXmlElement ( SyntaxNodeAnalysisContext context , IEnumerable < XmlNodeSyntax > syntaxList , params Location [ ] diagnosticLocations )
6161 {
62- var xmlParameterNames = syntaxList
63- . Where ( x => string . Equals ( x . GetName ( ) ? . ToString ( ) , XmlCommentHelper . ParamXmlTag ) )
64- . Select ( x =>
65- {
66- var nameAttribute = XmlCommentHelper . GetFirstAttributeOrDefault < XmlNameAttributeSyntax > ( x ) ;
67- var location = x . GetLocation ( ) ;
68-
69- if ( nameAttribute != null )
70- {
71- location = nameAttribute . GetLocation ( ) ;
72- }
73-
74- return new Tuple < string , Location > ( nameAttribute ? . Identifier ? . Identifier . ValueText , location ) ;
75- } )
76- . ToImmutableArray ( ) ;
62+ foreach ( var syntax in syntaxList )
63+ {
64+ var nameParameter = XmlCommentHelper . GetFirstAttributeOrDefault < XmlNameAttributeSyntax > ( syntax ) ;
65+ var parameterValue = nameParameter ? . Identifier ? . Identifier . ValueText ;
7766
78- VerifyParameters ( context , xmlParameterNames , diagnosticLocations . First ( ) ) ;
67+ if ( string . IsNullOrWhiteSpace ( parameterValue ) )
68+ {
69+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , nameParameter ? . GetLocation ( ) ?? syntax . GetLocation ( ) ) ) ;
70+ }
71+ }
7972 }
8073
8174 /// <inheritdoc/>
8275 protected override void HandleCompleteDocumentation ( SyntaxNodeAnalysisContext context , XElement completeDocumentation , params Location [ ] diagnosticLocations )
8376 {
84- var xmlParameterNames = completeDocumentation . Nodes ( )
77+ var xmlParamTags = completeDocumentation . Nodes ( )
8578 . OfType < XElement > ( )
86- . Where ( e => e . Name == XmlCommentHelper . ParamXmlTag )
87- . Select ( x =>
88- {
89- var name = x . Attributes ( ) . FirstOrDefault ( a => a . Name == "name" ) ? . Value ;
79+ . Where ( e => e . Name == XmlCommentHelper . ParamXmlTag ) ;
9080
91- return new Tuple < string , Location > ( name , null ) ;
92- } )
93- . ToImmutableArray ( ) ;
94-
95- VerifyParameters ( context , xmlParameterNames , diagnosticLocations . First ( ) ) ;
96- }
97-
98- private static void VerifyParameters ( SyntaxNodeAnalysisContext context , ImmutableArray < Tuple < string , Location > > documentationParameters , Location identifierLocation )
99- {
100- var index = 0 ;
101-
102- foreach ( var documentedParameter in documentationParameters )
81+ foreach ( var paramTag in xmlParamTags )
10382 {
104- if ( string . IsNullOrWhiteSpace ( documentedParameter . Item1 ) )
83+ var name = paramTag . Attributes ( ) . FirstOrDefault ( a => a . Name == "name" ) ? . Value ;
84+
85+ if ( string . IsNullOrWhiteSpace ( name ) )
10586 {
106- context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , documentedParameter . Item2 ?? identifierLocation ) ) ;
87+ context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , diagnosticLocations . First ( ) ) ) ;
10788 }
108-
109- index ++ ;
11089 }
11190 }
11291 }
0 commit comments