This repository was archived by the owner on Jul 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
src/Microsoft.DotNet.CodeFormatting.Tests/Rules Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public CombinationTest()
26
26
{
27
27
s_formattingEngine . CopyrightHeader = ImmutableArray . Create ( "" , "// header" ) ;
28
28
s_formattingEngine . FormatLogger = new EmptyFormatLogger ( ) ;
29
+ s_formattingEngine . PreprocessorConfigurations = ImmutableArray < string [ ] > . Empty ;
29
30
}
30
31
31
32
protected override async Task < Document > RewriteDocumentAsync ( Document document )
@@ -93,5 +94,57 @@ private void M()
93
94
94
95
Verify ( text , expected , runFormatter : false ) ;
95
96
}
97
+
98
+ [ Fact ]
99
+ public void PreprocessorSymbolNotDefined ( )
100
+ {
101
+ var text = @"
102
+ class C
103
+ {
104
+ #if DOG
105
+ void M() { }
106
+ #endif
107
+ }" ;
108
+
109
+ var expected = @"
110
+ // header
111
+
112
+ internal class C
113
+ {
114
+ #if DOG
115
+ void M() { }
116
+ #endif
117
+ }" ;
118
+
119
+ Verify ( text , expected , runFormatter : false ) ;
120
+ }
121
+
122
+ [ Fact ]
123
+ public void PreprocessorSymbolDefined ( )
124
+ {
125
+ var text = @"
126
+ internal class C
127
+ {
128
+ #if DOG
129
+ internal void M() {
130
+ }
131
+ #endif
132
+ }" ;
133
+
134
+ var expected = @"
135
+ // header
136
+
137
+ internal class C
138
+ {
139
+ #if DOG
140
+ internal void M()
141
+ {
142
+ }
143
+ #endif
144
+ }" ;
145
+
146
+ s_formattingEngine . PreprocessorConfigurations = ImmutableArray . CreateRange ( new [ ] { new [ ] { "DOG" } } ) ;
147
+ Verify ( text , expected , runFormatter : false ) ;
148
+ }
96
149
}
97
150
}
You can’t perform that action at this time.
0 commit comments