Skip to content

Commit 5c16ca9

Browse files
authored
remove SymbolCannotContainDelimiterArgumentException (#727)
1 parent 35c8e12 commit 5c16ca9

File tree

4 files changed

+27
-37
lines changed

4 files changed

+27
-37
lines changed

src/System.CommandLine.Tests/CommandTests.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ public void Commands_at_multiple_levels_can_have_their_own_arguments()
135135
}
136136

137137
[Theory]
138-
[InlineData("aa:")]
139-
[InlineData("aa=")]
140-
[InlineData(":aa")]
141-
[InlineData("=aa")]
142-
[InlineData("aa:aa")]
143-
[InlineData("aa=aa")]
138+
[InlineData("aa:", ":")]
139+
[InlineData("aa=", "=")]
140+
[InlineData(":aa", ":")]
141+
[InlineData("=aa", "=")]
142+
[InlineData("aa:aa", ":")]
143+
[InlineData("aa=aa", "=")]
144144
public void When_a_command_name_contains_a_delimiter_then_an_error_is_returned(
145-
string commandWithDelimiter)
145+
string commandWithDelimiter,
146+
string delimiter)
146147
{
147148
Action create = () =>
148149
{
@@ -156,7 +157,12 @@ public void When_a_command_name_contains_a_delimiter_then_an_error_is_returned(
156157
});
157158
};
158159

159-
create.Should().Throw<SymbolCannotContainDelimiterArgumentException>();
160+
create.Should()
161+
.Throw<ArgumentException>()
162+
.Which
163+
.Message
164+
.Should()
165+
.Be($"Command \"{commandWithDelimiter}\" is not allowed to contain a delimiter but it contains \"{delimiter}\"");
160166
}
161167

162168
[Theory]
@@ -187,14 +193,6 @@ public void When_a_command_alias_is_added_and_contains_whitespace_then_an_inform
187193
.Be($"Command alias cannot contain whitespace: \"{alias}\"");
188194
}
189195

190-
[Fact]
191-
public void When_a_command_name_contains_a_delimiter_then_the_error_is_informative()
192-
{
193-
var subject = new SymbolCannotContainDelimiterArgumentException('ツ');
194-
subject.Message.Should()
195-
.Be(@"Symbol cannot contain delimiter: ""ツ""");
196-
}
197-
198196
[Theory]
199197
[InlineData("outer", "outer")]
200198
[InlineData("outer arg", "outer")]

src/System.CommandLine.Tests/OptionTests.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,19 @@ public void When_an_option_alias_contains_a_delimiter_then_an_informative_error_
153153
string delimiter,
154154
string template)
155155
{
156-
Action create = () => new Parser(
157-
new Option(
158-
string.Format(template, delimiter)));
156+
var alias = string.Format(template, delimiter);
159157

160-
create.Should().Throw<ArgumentException>().Which.Message.Should()
161-
.Be($"Symbol cannot contain delimiter: \"{delimiter}\"");
158+
Action create = () =>
159+
{
160+
new Parser(new Option(alias));
161+
};
162+
163+
create.Should()
164+
.Throw<ArgumentException>()
165+
.Which
166+
.Message
167+
.Should()
168+
.Be($"Option \"{alias}\" is not allowed to contain a delimiter but it contains \"{delimiter}\"");
162169
}
163170

164171
[Theory]

src/System.CommandLine/CommandLineConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public CommandLineConfiguration(
4848
{
4949
if (alias.Contains(delimiter))
5050
{
51-
throw new SymbolCannotContainDelimiterArgumentException(delimiter);
51+
throw new ArgumentException($"{symbol.GetType().Name} \"{alias}\" is not allowed to contain a delimiter but it contains \"{delimiter}\"");
5252
}
5353
}
5454
}

src/System.CommandLine/SymbolCannotContainDelimiterArgumentException.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)