@@ -8,7 +8,7 @@ namespace StyleCop.Analyzers.DocumentationRules
8
8
using System ;
9
9
using System . Collections . Immutable ;
10
10
using System . Composition ;
11
- using System . Globalization ;
11
+ using System . Diagnostics ;
12
12
using System . Linq ;
13
13
using System . Text . RegularExpressions ;
14
14
using System . Threading ;
@@ -20,6 +20,7 @@ namespace StyleCop.Analyzers.DocumentationRules
20
20
using Microsoft . CodeAnalysis . CSharp . Syntax ;
21
21
using Microsoft . CodeAnalysis . Formatting ;
22
22
using StyleCop . Analyzers . Helpers ;
23
+ using StyleCop . Analyzers . Lightup ;
23
24
24
25
/// <summary>
25
26
/// Implements a code fix for <see cref="SA1642ConstructorSummaryDocumentationMustBeginWithStandardText"/>
@@ -83,7 +84,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
83
84
84
85
internal static ImmutableArray < string > GenerateStandardText ( Document document , BaseMethodDeclarationSyntax methodDeclaration , BaseTypeDeclarationSyntax typeDeclaration , CancellationToken cancellationToken )
85
86
{
86
- bool isStruct = typeDeclaration . IsKind ( SyntaxKind . StructDeclaration ) ;
87
+ bool isStruct = typeDeclaration . IsKind ( SyntaxKind . StructDeclaration ) || typeDeclaration . IsKind ( SyntaxKindEx . RecordStructDeclaration ) ;
87
88
var settings = document . Project . AnalyzerOptions . GetStyleCopSettings ( methodDeclaration . SyntaxTree , cancellationToken ) ;
88
89
var culture = settings . DocumentationRules . DocumentationCultureInfo ;
89
90
var resourceManager = DocumentationResources . ResourceManager ;
@@ -147,7 +148,19 @@ private static TypeParameterListSyntax GetTypeParameterList(BaseTypeDeclarationS
147
148
return classDeclaration . TypeParameterList ;
148
149
}
149
150
150
- return ( typeDeclaration as StructDeclarationSyntax ) ? . TypeParameterList ;
151
+ if ( typeDeclaration is StructDeclarationSyntax structDeclaration )
152
+ {
153
+ return structDeclaration . TypeParameterList ;
154
+ }
155
+
156
+ if ( RecordDeclarationSyntaxWrapper . IsInstance ( typeDeclaration ) )
157
+ {
158
+ var recordDeclaration = ( RecordDeclarationSyntaxWrapper ) typeDeclaration ;
159
+ return recordDeclaration . TypeParameterList ;
160
+ }
161
+
162
+ Debug . Assert ( false , $ "Unhandled type { typeDeclaration . Kind ( ) } ") ;
163
+ return null ;
151
164
}
152
165
153
166
private static Task < Document > GetTransformedDocumentAsync ( Document document , SyntaxNode root , XmlElementSyntax node , CancellationToken cancellationToken )
@@ -202,21 +215,10 @@ private static bool IsMultiLine(XmlElementSyntax node)
202
215
private static Task < Document > GetTransformedDocumentAsync ( Document document , SyntaxNode root , XmlEmptyElementSyntax node )
203
216
{
204
217
var typeDeclaration = node . FirstAncestorOrSelf < BaseTypeDeclarationSyntax > ( ) ;
205
-
206
- TypeParameterListSyntax typeParameterList ;
207
- if ( typeDeclaration is ClassDeclarationSyntax classDeclaration )
208
- {
209
- typeParameterList = classDeclaration . TypeParameterList ;
210
- }
211
- else
212
- {
213
- typeParameterList = ( typeDeclaration as StructDeclarationSyntax ) ? . TypeParameterList ;
214
- }
218
+ var typeParameterList = GetTypeParameterList ( typeDeclaration ) ;
215
219
216
220
var newRoot = root . ReplaceNode ( node , BuildSeeElement ( typeDeclaration . Identifier , typeParameterList ) ) ;
217
-
218
221
var newDocument = document . WithSyntaxRoot ( newRoot ) ;
219
-
220
222
return Task . FromResult ( newDocument ) ;
221
223
}
222
224
0 commit comments