Skip to content

Commit 6cd2235

Browse files
committed
rename ThrowIfInvalid to Validate, fixes dotnet#1908
1 parent e965ae2 commit 6cd2235

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ System.CommandLine
103103
public System.Boolean EnableTokenReplacement { get; }
104104
public LocalizationResources LocalizationResources { get; }
105105
public Command RootCommand { get; }
106-
public System.Void ThrowIfInvalid()
107106
public class CommandLineConfigurationException : System.Exception, System.Runtime.Serialization.ISerializable
108107
.ctor(System.String message)
109108
.ctor()
110109
.ctor(System.String message, System.Exception innerException)
110+
public System.Void Validate()
111111
public static class CompletionSourceExtensions
112112
public static System.Void Add(this CompletionSourceList completionSources, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
113113
public static System.Void Add(this CompletionSourceList completionSources, System.CommandLine.Completions.CompletionDelegate complete)

src/System.CommandLine.Tests/CommandLineConfigurationTests.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void ThrowIfInvalid_throws_if_there_are_duplicate_sibling_option_aliases_
2323

2424
var config = new CommandLineConfiguration(command);
2525

26-
var validate = () => config.ThrowIfInvalid();
26+
var validate = () => config.Validate();
2727

2828
validate.Should()
2929
.Throw<CommandLineConfigurationException>()
@@ -51,7 +51,7 @@ public void ThrowIfInvalid_throws_if_there_are_duplicate_sibling_option_aliases_
5151

5252
var config = new CommandLineConfiguration(command);
5353

54-
var validate = () => config.ThrowIfInvalid();
54+
var validate = () => config.Validate();
5555

5656
validate.Should()
5757
.Throw<CommandLineConfigurationException>()
@@ -76,7 +76,7 @@ public void ThrowIfInvalid_throws_if_there_are_duplicate_sibling_subcommand_alia
7676

7777
var config = new CommandLineConfiguration(rootCommand);
7878

79-
var validate = () => config.ThrowIfInvalid();
79+
var validate = () => config.Validate();
8080

8181
validate.Should()
8282
.Throw<CommandLineConfigurationException>()
@@ -104,7 +104,7 @@ public void ThrowIfInvalid_throws_if_there_are_duplicate_sibling_subcommand_alia
104104

105105
var config = new CommandLineConfiguration(command);
106106

107-
var validate = () => config.ThrowIfInvalid();
107+
var validate = () => config.Validate();
108108

109109
validate.Should()
110110
.Throw<CommandLineConfigurationException>()
@@ -129,7 +129,7 @@ public void ThrowIfInvalid_throws_if_sibling_command_and_option_aliases_collide_
129129

130130
var config = new CommandLineConfiguration(rootCommand);
131131

132-
var validate = () => config.ThrowIfInvalid();
132+
var validate = () => config.Validate();
133133

134134
validate.Should()
135135
.Throw<CommandLineConfigurationException>()
@@ -157,7 +157,7 @@ public void ThrowIfInvalid_throws_if_sibling_command_and_option_aliases_collide_
157157

158158
var config = new CommandLineConfiguration(rootCommand);
159159

160-
var validate = () => config.ThrowIfInvalid();
160+
var validate = () => config.Validate();
161161

162162
validate.Should()
163163
.Throw<CommandLineConfigurationException>()
@@ -180,7 +180,7 @@ public void ThrowIfInvalid_throws_if_there_are_duplicate_sibling_global_option_a
180180

181181
var config = new CommandLineConfiguration(command);
182182

183-
var validate = () => config.ThrowIfInvalid();
183+
var validate = () => config.Validate();
184184

185185
validate.Should()
186186
.Throw<CommandLineConfigurationException>()
@@ -204,7 +204,7 @@ public void ThrowIfInvalid_does_not_throw_if_global_option_alias_is_the_same_as_
204204

205205
var config = new CommandLineConfiguration(rootCommand);
206206

207-
var validate = () => config.ThrowIfInvalid();
207+
var validate = () => config.Validate();
208208

209209
validate.Should().NotThrow();
210210
}
@@ -223,7 +223,7 @@ public void ThrowIfInvalid_does_not_throw_if_global_option_alias_is_the_same_as_
223223

224224
var config = new CommandLineConfiguration(rootCommand);
225225

226-
var validate = () => config.ThrowIfInvalid();
226+
var validate = () => config.Validate();
227227

228228
validate.Should().NotThrow();
229229
}
@@ -236,7 +236,7 @@ public void ThrowIfInvalid_throws_if_a_command_is_its_own_parent()
236236

237237
var config = new CommandLineConfiguration(command);
238238

239-
var validate = () => config.ThrowIfInvalid();
239+
var validate = () => config.Validate();
240240

241241
validate.Should()
242242
.Throw<CommandLineConfigurationException>()
@@ -255,7 +255,7 @@ public void ThrowIfInvalid_throws_if_a_parentage_cycle_is_detected()
255255

256256
var config = new CommandLineConfiguration(rootCommand);
257257

258-
var validate = () => config.ThrowIfInvalid();
258+
var validate = () => config.Validate();
259259

260260
validate.Should()
261261
.Throw<CommandLineConfigurationException>()

src/System.CommandLine/CommandLineConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private bool DefaultTokenReplacer(
118118
/// </summary>
119119
/// <remarks>Due to the performance cost of this method, it is recommended to be used in unit testing or in scenarios where the parser is configured dynamically at runtime.</remarks>
120120
/// <exception cref="CommandLineConfigurationException">Thrown if the configuration is found to be invalid.</exception>
121-
public void ThrowIfInvalid()
121+
public void Validate()
122122
{
123123
ThrowIfInvalid(RootCommand);
124124

0 commit comments

Comments
 (0)