Skip to content

Commit aa6ec0d

Browse files
Remove unnecessary helper method in SA1205CodeFixProvider
1 parent f34185c commit aa6ec0d

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Contributors to the New StyleCop Analyzers project.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
#nullable disable
5-
64
namespace StyleCop.Analyzers.OrderingRules
75
{
86
using System.Collections.Immutable;
@@ -74,7 +72,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
7472
var keywordToken = typeDeclarationNode.Keyword;
7573

7674
var replacementModifiers = DeclarationModifiersHelper.AddModifiers(typeDeclarationNode.Modifiers, ref keywordToken, accessModifierKinds);
77-
var replacementNode = ReplaceModifiers(typeDeclarationNode, replacementModifiers);
75+
var replacementNode = (TypeDeclarationSyntax)typeDeclarationNode.WithModifiers(replacementModifiers);
7876
replacementNode = ReplaceKeyword(replacementNode, keywordToken);
7977
var newSyntaxRoot = syntaxRoot.ReplaceNode(typeDeclarationNode, replacementNode);
8078
return document.WithSyntaxRoot(newSyntaxRoot);
@@ -102,26 +100,6 @@ private static ImmutableArray<SyntaxKind> GetMissingAccessModifiers(Accessibilit
102100
}
103101
}
104102

105-
// This code was copied from the Roslyn code base (and slightly modified). It can be removed if
106-
// TypeDeclarationSyntaxExtensions.WithModifiers is made public (Roslyn issue #2186)
107-
private static TypeDeclarationSyntax ReplaceModifiers(TypeDeclarationSyntax node, SyntaxTokenList modifiers)
108-
{
109-
switch (node.Kind())
110-
{
111-
case SyntaxKind.ClassDeclaration:
112-
return ((ClassDeclarationSyntax)node).WithModifiers(modifiers);
113-
case SyntaxKind.InterfaceDeclaration:
114-
return ((InterfaceDeclarationSyntax)node).WithModifiers(modifiers);
115-
case SyntaxKind.StructDeclaration:
116-
return ((StructDeclarationSyntax)node).WithModifiers(modifiers);
117-
case SyntaxKindEx.RecordDeclaration:
118-
case SyntaxKindEx.RecordStructDeclaration:
119-
return ((RecordDeclarationSyntaxWrapper)node).WithModifiers(modifiers);
120-
}
121-
122-
return node;
123-
}
124-
125103
// This code was copied from the Roslyn code base (and slightly modified). It can be removed if
126104
// TypeDeclarationSyntaxExtensions.WithModifiers is made public (Roslyn issue #2186)
127105
private static TypeDeclarationSyntax ReplaceKeyword(TypeDeclarationSyntax node, SyntaxToken keyword)

0 commit comments

Comments
 (0)