This repository was archived by the owner on Jul 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Microsoft.DotNet.CodeFormatting.Tests Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,10 @@ public static CommandLineParseResult Parse(string[] args)
245
245
{
246
246
return CommandLineParseResult . CreateSuccess ( CommandLineOptions . ListRules ) ;
247
247
}
248
+ else if ( arg . StartsWith ( "/" , comparison ) )
249
+ {
250
+ return CommandLineParseResult . CreateError ( $ "Unrecognized option \" { arg } \" ") ;
251
+ }
248
252
else
249
253
{
250
254
formatTargets . Add ( arg ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ private CommandLineOptions Parse(params string[] args)
17
17
return options ;
18
18
}
19
19
20
+ private CommandLineOptions FailToParse ( params string [ ] args )
21
+ {
22
+ CommandLineOptions options ;
23
+ Assert . False ( CommandLineParser . TryParse ( args , out options ) ) ;
24
+ Assert . Null ( options ) ;
25
+
26
+ return options ;
27
+ }
28
+
20
29
[ Fact ]
21
30
public void Rules ( )
22
31
{
@@ -114,5 +123,23 @@ public void CopyrightEnable2()
114
123
Assert . True ( options . RuleMap [ FormattingDefaults . CopyrightRuleName ] ) ;
115
124
Assert . Equal ( new [ ] { "test.csproj" } , options . FormatTargets ) ;
116
125
}
126
+
127
+ [ Fact ]
128
+ public void SingleUnrecognizedOption ( )
129
+ {
130
+ FailToParse ( "/unrecognized" ) ;
131
+ }
132
+
133
+ [ Fact ]
134
+ public void UnrecognizedOptionWithFormatTarget ( )
135
+ {
136
+ FailToParse ( "test.csproj" , "/unrecognized" ) ;
137
+ }
138
+
139
+ [ Fact ]
140
+ public void UnrecognizedOptionWithOtherwiseValidArguments ( )
141
+ {
142
+ FailToParse ( "test.csproj" , "/nocopyright" , "/unrecognized" ) ;
143
+ }
117
144
}
118
145
}
You can’t perform that action at this time.
0 commit comments