Skip to content

Commit

Permalink
Update nuget packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hugener committed Nov 21, 2023
1 parent bfd8124 commit fa0dc29
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Given_a_commandline_with_an_argument_starting_with_dash_Then_result_

var result = testee.Parse(commandLine);

result.Value.Number.Should().Be(expectedNumber);
result.Value!.Number.Should().Be(expectedNumber);
}

[Fact]
Expand All @@ -51,7 +51,7 @@ public void Given_a_commandline_with_arguments_starting_with_dashes_Then_result_

var result = testee.Parse(commandLine);

result.Value.Numbers.Should().Equal(-3, 4, -7);
result.Value!.Numbers.Should().Equal(-3, 4, -7);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Parse_When_ChoiceValueIsMissing_Then_BatchArgumentsShouldBeAsExpecte
var result = commandLineParser.Parse(string.Empty);

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.RequiredArgumentMissing);
result.Error!.Type.Should().Be(ParserErrorType.RequiredArgumentMissing);
result.Error.Message.Should().Be(@"-c/--commands
-b/--batches or -bf/--batches-files or -bsi/--batches-stdin");
result.Error.ToString().Should().Be(@"Error:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class EmptyArgumentsTests
[Theory]
[InlineData(null)]
[InlineData("")]
public void Given_a_purely_optional_commandline_parsing_null_or_an_empty_string_should_succeed(string commandLine)
public void Given_a_purely_optional_commandline_parsing_null_or_an_empty_string_should_succeed(string? commandLine)
{
var testee = new CommandLineParser<Args, int>();
testee.WithArguments(new Args(), args => R.Success(args));
var result = testee.Parse(commandLine);

result.Value.IsOn.Should().BeFalse();
result.Value!.IsOn.Should().BeFalse();
}

private class Args : IArguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void GenerateAndParse_Then_ResultShouldBeExpectedResult()
});

var generateResult = commandLineGenerator.Generate(new Lfs(new Track(expectedPattern)));
var parseResult = commandLineParser.Parse(generateResult.Value);
var parseResult = commandLineParser.Parse(generateResult.Value!);

parseResult.IsSuccess.Should().BeTrue();
parseResult.Value.Should().Be(expectedResult);
Expand All @@ -45,7 +45,7 @@ public void Parse_When_VerbIsUnknown_Then_ResultShouldBeExpectedResult()
var parseResult = commandLineParser.Parse("lfs adsldasdas");

parseResult.IsSuccess.Should().BeFalse();
parseResult.Error.Type.Should().Be(ParserErrorType.UnknownVerb);
parseResult.Error!.Type.Should().Be(ParserErrorType.UnknownVerb);
}

[Fact]
Expand Down Expand Up @@ -86,7 +86,7 @@ track Start tracking the given patterns(s) through Git LFS.
var parseResult = commandLineParser.Parse($"lfs track {helpArgument}");

parseResult.IsSuccess.Should().BeFalse();
parseResult.Error.Type.Should().Be(ParserErrorType.HelpRequested);
parseResult.Error!.Type.Should().Be(ParserErrorType.HelpRequested);
parseResult.Error.Message.Should().Be(expectedHelpText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Parse_When_NoArgumentsNorVerbsAreConfigured_Then_ResultIsSuccessShou
var result = testee.Parse("test");

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.ArgumentsAndVerbsAreNotConfigured);
result.Error!.Type.Should().Be(ParserErrorType.ArgumentsAndVerbsAreNotConfigured);
}

[Fact]
Expand All @@ -33,6 +33,6 @@ public void Parse_When_VerbsAreConfiguredButNoArgumentsAndArgumentIsNotAVerb_The
var result = testee.Parse("test");

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.ArgumentsNotConfiguredOrUnknownVerb);
result.Error!.Type.Should().Be(ParserErrorType.ArgumentsNotConfiguredOrUnknownVerb);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Parse_When_InvalidOptionIsSpecified_Then_ResultShouldBeFalseAndError
var result = testee.Parse(commandLine);

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.UnknownOption);
result.Error!.Type.Should().Be(ParserErrorType.UnknownOption);
result.Error.Message.Should().Be(@"The option does not exist: -d");
}

Expand All @@ -39,7 +39,7 @@ public void Parse_When_UnknownOptionIsSpecified_Then_ResultShouldBeFalseAndError
var result = testee.Parse(commandLine);

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.UnknownOption);
result.Error!.Type.Should().Be(ParserErrorType.UnknownOption);
result.Error.Message.Should().Be(@"The option does not exist: -d");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Given_a_commandline_with_a_complex_type_Then_the_complex_type_should
var result = commandLineParser.Parse(commandLine);

result.IsSuccess.Should().BeTrue();
result.Value.AllowShutdown.Should().BeTrue();
result.Value!.AllowShutdown.Should().BeTrue();
result.Value.IsLoggingToConsole.Should().BeTrue();
result.Value.FileLogOptions?.LogPath.Should().Be(ExpectedLogPath);
result.Value.FileLogOptions?.MaxLogFileSizeInBytes.Should().Be(ExpectedMaxLogFileSizeInBytes);
Expand All @@ -46,7 +46,7 @@ public void Given_a_commandline_with_an_optional_complex_type_with_a_required_fi
var result = commandLineParser.Parse(commandLine);

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.InnerParserError);
result.Error!.Type.Should().Be(ParserErrorType.InnerParserError);
result.Error.InnerParserError!.Type.Should().Be(ParserErrorType.RequiredArgumentMissing);
}

Expand Down Expand Up @@ -137,7 +137,7 @@ public void Given_the_help_commandline_Then_ResultErrorToString_should_be_the_ex
commandLineParser.WithArguments(new Options(false, false), options => R.Success(options));
var parserResult = commandLineParser.Parse("-?");

var result = parserResult.Error.ToString();
var result = parserResult.Error!.ToString();

result.Should().Be(expectedHelpText);
}
Expand All @@ -151,7 +151,7 @@ public void Given_a_commandline_without_a_required_argument_Then_ResultErrorToSt
commandLineParser.WithArguments(new Options(false, false), options => R.Success(options));
var parserResult = commandLineParser.Parse($@"-fl """"");

var result = parserResult.Error.ToString();
var result = parserResult.Error!.ToString();

result.Should().Be(expectedText);
}
Expand All @@ -167,7 +167,7 @@ public void Given_a_nested_commandline_without_a_required_argument_Then_ResultEr
commandLineParser.WithArguments(new Options(false, false), options => R.Success(options));
var parserResult = commandLineParser.Parse($@"-fl -ms 3");

var result = parserResult.Error.ToString();
var result = parserResult.Error!.ToString();

result.Should().Be(expectedText);
}
Expand All @@ -181,7 +181,7 @@ public void Given_a_commandline_with_an_option_without_an_argument_Then_ResultEr
commandLineParser.WithArguments(new FileLogOptions(string.Empty), options => R.Success(options));
var parserResult = commandLineParser.Parse($@"-lp");

var result = parserResult.Error.ToString();
var result = parserResult.Error!.ToString();

result.Should().Be(expectedText);
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public void Given_a_commandline_When_parsing_twice_Then_ResultErrorToString_shou

var result = commandLineParser.Parse($@"-lp ""{expectedLogPath}""");

result.Value.LogPath.Should().Be(expectedLogPath);
result.Value!.LogPath.Should().Be(expectedLogPath);
result.Value.MaxLogFileSizeInBytes.Should().NotBe(ExpectedMaxLogFileSizeInBytes);
result.Value.MaxNumberOfLogFiles.Should().Be(expectedMaxFiles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Given_a_complete_commandline_Then_parsed_result_should_be_expected_v
var result = testee.Parse(commandLine);

result.IsSuccess.Should().BeTrue();
result.Value.HostName.Should().Be(ExpectedHost);
result.Value!.HostName.Should().Be(ExpectedHost);
result.Value.BuildTypeId.Should().Be(ExpectedBuildTypeId);
result.Value.Credentials?.UserName.Should().Be(ExpectedUserName);
new NetworkCredential(string.Empty, result.Value.Credentials?.Password).Password.Should().Be(ExpectedPassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NuGet.Versioning" Version="6.5.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NuGet.Versioning" Version="6.8.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public void Given_a_commandline_that_only_contains_verbs_When_parsed_with_a_verb
var result = commandLineParser.Parse(new[] { "run", "and", "fail" });

result.IsSuccess.Should().BeFalse();
result.Error.Type.Should().Be(ParserErrorType.UnknownVerb);
result.Error!.Type.Should().Be(ParserErrorType.UnknownVerb);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 5 additions & 5 deletions Source/Sundew.CommandLine/CommandLineParser{TSuccess,TError}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public ValueTask<R<TSuccess, ParserError<TError>>> ParseAsync(IReadOnlyList<Read
/// <summary>Parses the specified arguments.</summary>
/// <param name="arguments">The arguments.</param>
/// <returns>The parser result.</returns>
public ValueTask<R<TSuccess, ParserError<TError>>> ParseAsync(string arguments)
public ValueTask<R<TSuccess, ParserError<TError>>> ParseAsync(string? arguments)
{
return this.ParseAsync(arguments, 0);
}
Expand All @@ -168,7 +168,7 @@ public ValueTask<R<TSuccess, ParserError<TError>>> ParseAsync(string arguments)
/// <param name="arguments">The arguments.</param>
/// <param name="startIndex">The argument index at which to start parsing.</param>
/// <returns>The parser result.</returns>
public ValueTask<R<TSuccess, ParserError<TError>>> ParseAsync(string arguments, int startIndex)
public ValueTask<R<TSuccess, ParserError<TError>>> ParseAsync(string? arguments, int startIndex)
{
var argumentArray = arguments.AsMemory().ParseCommandLineArguments().ToArray();
return this.ParseAsync(argumentArray, startIndex);
Expand Down Expand Up @@ -264,7 +264,7 @@ public R<TSuccess, ParserError<TError>> Parse(IReadOnlyList<ReadOnlyMemory<char>
/// <summary>Parses the specified arguments.</summary>
/// <param name="arguments">The arguments.</param>
/// <returns>The parser result.</returns>
public R<TSuccess, ParserError<TError>> Parse(string arguments)
public R<TSuccess, ParserError<TError>> Parse(string? arguments)
{
return this.Parse(arguments, 0);
}
Expand All @@ -275,7 +275,7 @@ public R<TSuccess, ParserError<TError>> Parse(string arguments)
/// <param name="arguments">The arguments.</param>
/// <param name="startIndex">The argument index at which to start parsing.</param>
/// <returns>The parser result.</returns>
public R<TSuccess, ParserError<TError>> Parse(string arguments, int startIndex)
public R<TSuccess, ParserError<TError>> Parse(string? arguments, int startIndex)
{
var argumentArray = arguments.AsMemory().ParseCommandLineArguments().ToArray();
return this.Parse(argumentArray, startIndex);
Expand Down Expand Up @@ -320,7 +320,7 @@ private static R<TSuccess, ParserError<TError>> CheckResultForHelpRequestedError
ArgumentsAction<TSuccess, TError>? argumentsAction,
Settings settings)
{
if (!result)
if (!result.IsSuccess)
{
if (result.Error.Type == ParserErrorType.HelpRequested)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static R<GeneratorError> Generate(IArguments arguments, StringBuilder str
foreach (var option in argumentsBuilder.Options)
{
var serializeResult = option.SerializeTo(stringBuilder, settings, useAliases);
if (!serializeResult)
if (serializeResult.HasError)
{
return R.Error(serializeResult.Error);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Sundew.CommandLine/Internal/Options/NestingOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public R<bool, GeneratorError> SerializeTo(StringBuilder stringBuilder, Settings
stringBuilder.Append(Constants.SpaceCharacter);
var result = SerializeValue(actualOption, stringBuilder, settings, useAliases);

if (result)
if (result.IsSuccess)
{
return result.To(true);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public R<ParserError> DeserializeFrom(
{
var options = this.getDefault();
var result = this.DeserializeValue(commandLineArgumentsParser, argumentList, options, settings);
if (result)
if (result.IsSuccess)
{
this.setOptions(options);
return result;
Expand Down
4 changes: 2 additions & 2 deletions Source/Sundew.CommandLine/ResultExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class ResultExtensions
/// <returns>A value indicating whether help could be useful.</returns>
public static bool WriteToConsole<TValue, TError>(this R<TValue, ParserError<TError>> result)
{
if (result)
if (result.IsSuccess)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(result.Value);
Expand All @@ -45,7 +45,7 @@ public static bool WriteToConsole<TValue, TError>(this R<TValue, ParserError<TEr
/// <returns>The exit code.</returns>
public static int GetExitCode(this R<int, ParserError<int>> result)
{
if (result)
if (result.IsSuccess)
{
return result.Value;
}
Expand Down
20 changes: 11 additions & 9 deletions Source/Sundew.CommandLine/Sundew.CommandLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ Features:
<NoWarn>SA1625</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Internal\Choices\**" />
<EmbeddedResource Remove="Internal\Choices\**" />
<None Remove="Internal\Choices\**" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.1">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -52,18 +58,14 @@ Features:
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Sundew.Base.Collections" Version="10.0.1" />
<PackageReference Include="Sundew.Base.Primitives" Version="10.0.1" />
<PackageReference Include="Sundew.Base.Text" Version="10.0.1" />
<PackageReference Include="Sundew.Packaging.Publish" Version="8.2.1">
<PackageReference Include="Sundew.Base.Collections" Version="11.0.0" />
<PackageReference Include="Sundew.Base.Primitives" Version="11.0.0" />
<PackageReference Include="Sundew.Base.Text" Version="11.0.0" />
<PackageReference Include="Sundew.Packaging.Publish" Version="8.2.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Internal\Choices\" />
</ItemGroup>

</Project>

0 comments on commit fa0dc29

Please sign in to comment.