@@ -8,7 +8,7 @@ namespace StyleCop.Analyzers.DocumentationRules
88 using System ;
99 using System . Collections . Immutable ;
1010 using System . Composition ;
11- using System . Globalization ;
11+ using System . Diagnostics ;
1212 using System . Linq ;
1313 using System . Text . RegularExpressions ;
1414 using System . Threading ;
@@ -20,6 +20,7 @@ namespace StyleCop.Analyzers.DocumentationRules
2020 using Microsoft . CodeAnalysis . CSharp . Syntax ;
2121 using Microsoft . CodeAnalysis . Formatting ;
2222 using StyleCop . Analyzers . Helpers ;
23+ using StyleCop . Analyzers . Lightup ;
2324
2425 /// <summary>
2526 /// Implements a code fix for <see cref="SA1642ConstructorSummaryDocumentationMustBeginWithStandardText"/>
@@ -83,7 +84,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
8384
8485 internal static ImmutableArray < string > GenerateStandardText ( Document document , BaseMethodDeclarationSyntax methodDeclaration , BaseTypeDeclarationSyntax typeDeclaration , CancellationToken cancellationToken )
8586 {
86- bool isStruct = typeDeclaration . IsKind ( SyntaxKind . StructDeclaration ) ;
87+ bool isStruct = typeDeclaration . IsKind ( SyntaxKind . StructDeclaration ) || typeDeclaration . IsKind ( SyntaxKindEx . RecordStructDeclaration ) ;
8788 var settings = document . Project . AnalyzerOptions . GetStyleCopSettings ( methodDeclaration . SyntaxTree , cancellationToken ) ;
8889 var culture = settings . DocumentationRules . DocumentationCultureInfo ;
8990 var resourceManager = DocumentationResources . ResourceManager ;
@@ -147,7 +148,19 @@ private static TypeParameterListSyntax GetTypeParameterList(BaseTypeDeclarationS
147148 return classDeclaration . TypeParameterList ;
148149 }
149150
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 ;
151164 }
152165
153166 private static Task < Document > GetTransformedDocumentAsync ( Document document , SyntaxNode root , XmlElementSyntax node , CancellationToken cancellationToken )
@@ -202,21 +215,10 @@ private static bool IsMultiLine(XmlElementSyntax node)
202215 private static Task < Document > GetTransformedDocumentAsync ( Document document , SyntaxNode root , XmlEmptyElementSyntax node )
203216 {
204217 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 ) ;
215219
216220 var newRoot = root . ReplaceNode ( node , BuildSeeElement ( typeDeclaration . Identifier , typeParameterList ) ) ;
217-
218221 var newDocument = document . WithSyntaxRoot ( newRoot ) ;
219-
220222 return Task . FromResult ( newDocument ) ;
221223 }
222224
0 commit comments