Skip to content

Commit b18b040

Browse files
committed
Move the typeParameterList cast to its own function
Instead of repeating the cast for each version of BuildStandardTextSyntaxList I moved the typeParameterList cast to its own function
1 parent 4229bcc commit b18b040

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,7 @@ internal static ImmutableArray<string> GenerateStandardText(Document document, B
119119

120120
internal static SyntaxList<XmlNodeSyntax> BuildStandardTextSyntaxList(BaseTypeDeclarationSyntax typeDeclaration, string preText, string postText)
121121
{
122-
TypeParameterListSyntax typeParameterList;
123-
if (typeDeclaration is ClassDeclarationSyntax classDeclaration)
124-
{
125-
typeParameterList = classDeclaration.TypeParameterList;
126-
}
127-
else
128-
{
129-
typeParameterList = (typeDeclaration as StructDeclarationSyntax)?.TypeParameterList;
130-
}
122+
TypeParameterListSyntax typeParameterList = GetTypeParameterList(typeDeclaration);
131123

132124
return XmlSyntaxFactory.List(
133125
XmlSyntaxFactory.Text(preText),
@@ -137,15 +129,7 @@ internal static SyntaxList<XmlNodeSyntax> BuildStandardTextSyntaxList(BaseTypeDe
137129

138130
internal static SyntaxList<XmlNodeSyntax> BuildStandardTextSyntaxList(BaseTypeDeclarationSyntax typeDeclaration, string newLineText, string preText, string postText)
139131
{
140-
TypeParameterListSyntax typeParameterList;
141-
if (typeDeclaration is ClassDeclarationSyntax classDeclaration)
142-
{
143-
typeParameterList = classDeclaration.TypeParameterList;
144-
}
145-
else
146-
{
147-
typeParameterList = (typeDeclaration as StructDeclarationSyntax)?.TypeParameterList;
148-
}
132+
TypeParameterListSyntax typeParameterList = GetTypeParameterList(typeDeclaration);
149133

150134
return XmlSyntaxFactory.List(
151135
XmlSyntaxFactory.NewLine(newLineText),
@@ -154,6 +138,16 @@ internal static SyntaxList<XmlNodeSyntax> BuildStandardTextSyntaxList(BaseTypeDe
154138
XmlSyntaxFactory.Text(postText.EndsWith(".") ? postText : (postText + ".")));
155139
}
156140

141+
private static TypeParameterListSyntax GetTypeParameterList(BaseTypeDeclarationSyntax typeDeclaration)
142+
{
143+
if (typeDeclaration is ClassDeclarationSyntax classDeclaration)
144+
{
145+
return classDeclaration.TypeParameterList;
146+
}
147+
148+
return (typeDeclaration as StructDeclarationSyntax)?.TypeParameterList;
149+
}
150+
157151
private static Task<Document> GetTransformedDocumentAsync(Document document, SyntaxNode root, XmlElementSyntax node, CancellationToken cancellationToken)
158152
{
159153
var typeDeclaration = node.FirstAncestorOrSelf<BaseTypeDeclarationSyntax>();

0 commit comments

Comments
 (0)