Skip to content

Commit 1d31122

Browse files
committed
Use existing shared helper methods
1 parent 17afb7b commit 1d31122

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1402FileMayOnlyContainASingleType.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static bool ContainsTopLevelTypeDeclarations(SyntaxNode node)
108108
return node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration) || node.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration);
109109
}
110110

111-
private static bool IsRelevantType(SyntaxNode node, StyleCopSettings settings)
111+
private static bool IsRelevantType(MemberDeclarationSyntax node, StyleCopSettings settings)
112112
{
113113
if (IsFileLocalType(node))
114114
{
@@ -142,18 +142,9 @@ private static bool IsRelevantType(SyntaxNode node, StyleCopSettings settings)
142142
return isRelevant;
143143
}
144144

145-
private static bool IsFileLocalType(SyntaxNode node)
145+
private static bool IsFileLocalType(MemberDeclarationSyntax node)
146146
{
147-
const SyntaxKind FileKeyword = (SyntaxKind)8449;
148-
149-
var modifiers = node switch
150-
{
151-
BaseTypeDeclarationSyntax x => x.Modifiers,
152-
DelegateDeclarationSyntax x => x.Modifiers,
153-
_ => default,
154-
};
155-
156-
return modifiers.Any(FileKeyword);
147+
return node.GetModifiers().Any(SyntaxKindEx.FileKeyword);
157148
}
158149
}
159150
}

0 commit comments

Comments
 (0)