Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit 028e8ba

Browse files
committed
Disable the using location rule by default
Moving a using from inside a namespace to outside it is a fundamentally dangerous operation. In part because it changes the context of the lookup: - Outside the namespace only the other usings are considered - Inside the namespace the namespace + the usings are considered This makes it trivial to create an error by moving a using directive around. Instead of continuing to patch this rule I've decided to just disable it by default for now. We can revisit and make it safer later on but for now it takes too much work to fix this.
1 parent 98df38a commit 028e8ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Microsoft.DotNet.CodeFormatting/Rules/UsingLocationRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.DotNet.CodeFormatting.Rules
1616
/// <summary>
1717
/// This will ensure that using directives are placed outside of the namespace.
1818
/// </summary>
19-
[SyntaxRule(UsingLocationRule.Name, UsingLocationRule.Description, SyntaxRuleOrder.UsingLocationFormattingRule)]
19+
[SyntaxRule(UsingLocationRule.Name, UsingLocationRule.Description, SyntaxRuleOrder.UsingLocationFormattingRule, DefaultRule = false)]
2020
internal sealed class UsingLocationRule : CSharpOnlyFormattingRule, ISyntaxFormattingRule
2121
{
2222
internal const string Name = "UsingLocation";

0 commit comments

Comments
 (0)