Skip to content

Commit 15cd12e

Browse files
Improved readability of some code in SA1402CodeFixProvider
1 parent 30b7631 commit 15cd12e

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1402CodeFixProvider.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules
1919
/// Implements a code fix for <see cref="SA1402FileMayOnlyContainASingleType"/>.
2020
/// </summary>
2121
/// <remarks>
22-
/// <para>To fix a violation of this rule, move each class into its own file.</para>
22+
/// <para>To fix a violation of this rule, move each type into its own file.</para>
2323
/// </remarks>
2424
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1402CodeFixProvider))]
2525
[Shared]
@@ -114,16 +114,22 @@ private static string GetExtractedDocumentName(MemberDeclarationSyntax memberDec
114114
{
115115
string extractedDocumentName = NamedTypeHelpers.GetNameOrIdentifier(memberDeclarationSyntax);
116116

117+
var typeDeclarationSyntax = memberDeclarationSyntax as TypeDeclarationSyntax;
117118
var delegateDeclarationSyntax = memberDeclarationSyntax as DelegateDeclarationSyntax;
118-
if (delegateDeclarationSyntax?.TypeParameterList?.Parameters.Count > 0)
119+
120+
if (typeDeclarationSyntax != null)
119121
{
120-
extractedDocumentName += "`" + delegateDeclarationSyntax.TypeParameterList.Parameters.Count;
122+
if (typeDeclarationSyntax.TypeParameterList?.Parameters.Count > 0)
123+
{
124+
extractedDocumentName += "`" + typeDeclarationSyntax.TypeParameterList.Parameters.Count;
125+
}
121126
}
122-
123-
var typeDeclarationSyntax = memberDeclarationSyntax as TypeDeclarationSyntax;
124-
if (typeDeclarationSyntax?.TypeParameterList?.Parameters.Count > 0)
127+
else if (delegateDeclarationSyntax != null)
125128
{
126-
extractedDocumentName += "`" + typeDeclarationSyntax.TypeParameterList.Parameters.Count;
129+
if (delegateDeclarationSyntax.TypeParameterList?.Parameters.Count > 0)
130+
{
131+
extractedDocumentName += "`" + delegateDeclarationSyntax.TypeParameterList.Parameters.Count;
132+
}
127133
}
128134

129135
return extractedDocumentName;

0 commit comments

Comments
 (0)