File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -678,6 +678,34 @@ public void File_With_Reorder_Modifiers_In_If_Directive_Should_Pass_Validation(s
678
678
result . OutputLines . First ( ) . Should ( ) . StartWith ( "Formatted 1 files in" ) ;
679
679
}
680
680
681
+ [ Test ]
682
+ public void File_With_Reordered_Usings_In_If_Directive_Should_Pass_Validation ( )
683
+ {
684
+ var context = new TestContext ( ) ;
685
+
686
+ context . WhenAFileExists (
687
+ "file1.cs" ,
688
+ """
689
+ #if NOT_UNTIL_LATER
690
+ namespace Namespace {
691
+
692
+ using System.Xml;
693
+ using System.Configuration;
694
+
695
+ public class ClassName {
696
+
697
+ }
698
+ }
699
+ #endif
700
+ """
701
+ ) ;
702
+
703
+ var result = Format ( context ) ;
704
+
705
+ result . ErrorOutputLines . Should ( ) . BeEmpty ( ) ;
706
+ result . OutputLines . First ( ) . Should ( ) . StartWith ( "Formatted 1 files in" ) ;
707
+ }
708
+
681
709
[ Test ]
682
710
public void File_With_Added_Trailing_Comma_Before_Comment_Should_Pass_Validation ( )
683
711
{
Original file line number Diff line number Diff line change @@ -124,7 +124,16 @@ var groupOfUsingData in GroupUsings(
124
124
}
125
125
}
126
126
127
- if ( reorderedDirectives && usings . Any ( o => o . ToFullString ( ) . Contains ( "#endif" ) ) )
127
+ if (
128
+ reorderedDirectives
129
+ && (
130
+ usings . Any ( o => o . ToFullString ( ) . Contains ( "#endif" ) )
131
+ || (
132
+ usings [ 0 ] . Parent is NamespaceDeclarationSyntax namespaceDeclarationSyntax
133
+ && namespaceDeclarationSyntax . GetLeadingTrivia ( ) . ToFullString ( ) . Contains ( "#if" )
134
+ )
135
+ )
136
+ )
128
137
{
129
138
context . State . ReorderedUsingsWithDisabledText = true ;
130
139
}
You can’t perform that action at this time.
0 commit comments