From 028e8baa4cc26f24e08f7a95eba311b930b6f602 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Tue, 30 Jun 2015 13:39:03 -0700 Subject: [PATCH] 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. --- src/Microsoft.DotNet.CodeFormatting/Rules/UsingLocationRule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.CodeFormatting/Rules/UsingLocationRule.cs b/src/Microsoft.DotNet.CodeFormatting/Rules/UsingLocationRule.cs index 20143c08..e5f3fcbf 100644 --- a/src/Microsoft.DotNet.CodeFormatting/Rules/UsingLocationRule.cs +++ b/src/Microsoft.DotNet.CodeFormatting/Rules/UsingLocationRule.cs @@ -16,7 +16,7 @@ namespace Microsoft.DotNet.CodeFormatting.Rules /// /// This will ensure that using directives are placed outside of the namespace. /// - [SyntaxRule(UsingLocationRule.Name, UsingLocationRule.Description, SyntaxRuleOrder.UsingLocationFormattingRule)] + [SyntaxRule(UsingLocationRule.Name, UsingLocationRule.Description, SyntaxRuleOrder.UsingLocationFormattingRule, DefaultRule = false)] internal sealed class UsingLocationRule : CSharpOnlyFormattingRule, ISyntaxFormattingRule { internal const string Name = "UsingLocation";