Skip to content

Commit

Permalink
change method signature to be consistent with other classes in the hi…
Browse files Browse the repository at this point in the history
…erarchy.
  • Loading branch information
johnjaylward committed May 22, 2020
1 parent abb6108 commit 4bc7803
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/CommandLine/Core/InstanceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static ParserResult<T> Build<T>(
(from p in specProps select p.Specification.ConversionType).ToArray());

Func<IEnumerable<Error>, ParserResult<T>> notParsed =
errs => new NotParsed<T>(makeDefault().GetType().ToTypeInfo(), errs);
errs => new NotParsed<T>(errs, makeDefault().GetType().ToTypeInfo());

var argumentsList = arguments.Memoize();
Func<ParserResult<T>> buildUp = () =>
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLine/Core/InstanceChooser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private static HelpVerbRequestedError MakeHelpVerbRequestedError(

private static NotParsed<object> MakeNotParsed(IEnumerable<Type> types, params Error[] errors)
{
return new NotParsed<object>(TypeInfo.Create(typeof(NullInstance), types), errors);
return new NotParsed<object>(errors, TypeInfo.Create(typeof(NullInstance), types));
}
}
}
2 changes: 1 addition & 1 deletion src/CommandLine/ErrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static class ErrorExtensions
public static ParserResult<T> ToParserResult<T>(this IEnumerable<Error> errors, T instance)
{
return errors.Any()
? (ParserResult<T>)new NotParsed<T>(instance.GetType().ToTypeInfo(), errors)
? (ParserResult<T>)new NotParsed<T>(errors, instance.GetType().ToTypeInfo())
: (ParserResult<T>)new Parsed<T>(instance);
}

Expand Down
2 changes: 1 addition & 1 deletion src/CommandLine/ParserResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public bool Equals(Parsed<T> other)
public sealed class NotParsed<T> : ParserResult<T>, IEquatable<NotParsed<T>>
{

internal NotParsed(TypeInfo typeInfo, IEnumerable<Error> errors)
internal NotParsed(IEnumerable<Error> errors, TypeInfo typeInfo)
: base(errors, typeInfo)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLine/Text/HelpText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public static HelpText AutoBuild<T>(ParserResult<T> parserResult, Func<HelpText,
}, e => e, maxDisplayWidth: maxDisplayWidth);

var err = errors.OfType<HelpVerbRequestedError>().Single();
var pr = new NotParsed<object>(TypeInfo.Create(err.Type), new Error[] { err });
var pr = new NotParsed<object>(new Error[] { err }, TypeInfo.Create(err.Type));
return err.Matched
? AutoBuild(pr, current =>
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void Explicit_help_request_generates_help_requested_error()
{
// Fixture setup
var expectedResult = new NotParsed<Simple_Options>(
TypeInfo.Create(typeof(Simple_Options)), new Error[] { new HelpRequestedError() });
new Error[] { new HelpRequestedError() }, TypeInfo.Create(typeof(Simple_Options)));

// Exercize system
var result = InvokeBuild<Simple_Options>(
Expand Down
2 changes: 1 addition & 1 deletion tests/CommandLine.Tests/Unit/Issue104Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void Create_instance_with_enum_options_enabled_and_nullable_enum()
// Exercize system
var sut = new HelpText { AddDashesToOption = true, AddEnumValuesToHelpText = true, MaximumDisplayWidth = 80 }
.AddPreOptionsLine("pre-options")
.AddOptions(new NotParsed<Options_With_Nullable_Enum_Having_HelpText>(TypeInfo.Create(typeof(Options_With_Enum_Having_HelpText)), Enumerable.Empty<Error>()))
.AddOptions(new NotParsed<Options_With_Nullable_Enum_Having_HelpText>(Enumerable.Empty<Error>(), TypeInfo.Create(typeof(Options_With_Enum_Having_HelpText))))
.AddPostOptionsLine("post-options");

// Verify outcome
Expand Down
16 changes: 8 additions & 8 deletions tests/CommandLine.Tests/Unit/Text/HelpTextAutoBuildFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public void HelpText_with_AdditionalNewLineAfterOption_true_should_have_newline(
// Fixture setup
// Exercize system
var sut = new HelpText { AdditionalNewLineAfterOption = true }
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
.AddOptions(new NotParsed<Simple_Options>(Enumerable.Empty<Error>(),
TypeInfo.Create(typeof(Simple_Options))));

// Verify outcome

Expand All @@ -40,8 +40,8 @@ public void HelpText_with_AdditionalNewLineAfterOption_false_should_not_have_new
// Fixture setup
// Exercize system
var sut = new HelpText { AdditionalNewLineAfterOption = false }
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
.AddOptions(new NotParsed<Simple_Options>(Enumerable.Empty<Error>(),
TypeInfo.Create(typeof(Simple_Options))));

// Verify outcome

Expand All @@ -59,8 +59,8 @@ public void HelpText_with_by_default_should_include_help_version_option()
// Fixture setup
// Exercize system
var sut = new HelpText ()
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
.AddOptions(new NotParsed<Simple_Options>(Enumerable.Empty<Error>(),
TypeInfo.Create(typeof(Simple_Options))));

// Verify outcome

Expand All @@ -77,8 +77,8 @@ public void HelpText_with_AutoHelp_false_should_hide_help_option()
// Fixture setup
// Exercize system
var sut = new HelpText { AutoHelp = false,AutoVersion = false}
.AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)),
Enumerable.Empty<Error>()));
.AddOptions(new NotParsed<Simple_Options>(Enumerable.Empty<Error>(),
TypeInfo.Create(typeof(Simple_Options))));

// Verify outcome

Expand Down
Loading

0 comments on commit 4bc7803

Please sign in to comment.