Skip to content

Commit fc7a433

Browse files
committed
Clarify file-scoped namespace behavior in SA1402 code fix
1 parent d208f0a commit fc7a433

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace StyleCop.Analyzers.MaintainabilityRules
55
{
6+
using System;
67
using System.Collections.Generic;
78
using System.Collections.Immutable;
89
using System.Composition;
@@ -14,6 +15,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules
1415
using Microsoft.CodeAnalysis.CSharp;
1516
using Microsoft.CodeAnalysis.CSharp.Syntax;
1617
using StyleCop.Analyzers.Helpers;
18+
using StyleCop.Analyzers.Lightup;
1719

1820
/// <summary>
1921
/// Implements a code fix for <see cref="SA1402FileMayOnlyContainASingleType"/>.
@@ -89,6 +91,10 @@ private static async Task<Solution> GetTransformedSolutionAsync(Document documen
8991
nodesToRemoveFromExtracted.Add(child);
9092
break;
9193

94+
case SyntaxKindEx.FileScopedNamespaceDeclaration:
95+
// Only one file-scoped namespace is allowed per syntax tree
96+
throw new InvalidOperationException("This location is not reachable");
97+
9298
default:
9399
break;
94100
}

0 commit comments

Comments
 (0)