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)
245245 {
246246 return CommandLineParseResult . CreateSuccess ( CommandLineOptions . ListRules ) ;
247247 }
248+ else if ( arg . StartsWith ( "/" , comparison ) )
249+ {
250+ return CommandLineParseResult . CreateError ( $ "Unrecognized option \" { arg } \" ") ;
251+ }
248252 else
249253 {
250254 formatTargets . Add ( arg ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ private CommandLineOptions Parse(params string[] args)
1717 return options ;
1818 }
1919
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+
2029 [ Fact ]
2130 public void Rules ( )
2231 {
@@ -114,5 +123,23 @@ public void CopyrightEnable2()
114123 Assert . True ( options . RuleMap [ FormattingDefaults . CopyrightRuleName ] ) ;
115124 Assert . Equal ( new [ ] { "test.csproj" } , options . FormatTargets ) ;
116125 }
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+ }
117144 }
118145}
You can’t perform that action at this time.
0 commit comments