Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies to latest #484

Merged
merged 4 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "4.1.131201",
"version": "5.1.250801",
"commands": [
"dotnet-format"
]
}
}
}
}
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: "2.1.x"
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"
- name: Setup .NET 5
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
dotnet-version: "6.0.x"
- name: Run build script
id: build_script
run: ./build.ps1 -ci
Expand All @@ -58,7 +54,7 @@ jobs:
name: packages
path: artifacts/
if-no-files-found: error
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v2
with:
name: unittests-${{ matrix.os }}
fail_ci_if_error: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ McMaster.Extensions.CommandLineUtils.ArgumentEscaper
A community-maintained fork of Microsoft.Extensions.CommandLineUtils, plus many enhancements.
</PackageDescription>
<PackageTags>commandline;parsing</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1'">
Expand All @@ -31,4 +32,8 @@ McMaster.Extensions.CommandLineUtils.ArgumentEscaper
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project InitialTargets="UpdateCiSettings">

<ItemGroup Condition=" '$(CI)' == 'true' ">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(DisablePublicApiAnalyzer)' != 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3" PrivateAssets="All" />
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Hosting.CommandLine/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static IServiceCollection AddCommonServices(this IServiceCollection serv
.AddSingleton<IHostLifetime, CommandLineLifetime>()
.AddSingleton(provider =>
{
state.SetConsole(provider.GetService<IConsole>());
state.SetConsole(provider.GetRequiredService<IConsole>());
return state;
})
.AddSingleton<CommandLineContext>(state);
Expand Down
4 changes: 2 additions & 2 deletions src/Hosting.CommandLine/Internal/CommandLineLifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace McMaster.Extensions.Hosting.CommandLine.Internal
/// </summary>
internal class CommandLineLifetime : IHostLifetime, IDisposable
{
private readonly IApplicationLifetime _applicationLifetime;
private readonly IHostApplicationLifetime _applicationLifetime;
private readonly ICommandLineService _cliService;
private readonly IConsole _console;
private readonly IUnhandledExceptionHandler? _unhandledExceptionHandler;

/// <summary>
/// Creates a new instance.
/// </summary>
public CommandLineLifetime(IApplicationLifetime applicationLifetime,
public CommandLineLifetime(IHostApplicationLifetime applicationLifetime,
ICommandLineService cliService,
IConsole console,
IUnhandledExceptionHandler? unhandledExceptionHandler = null)
Expand Down
13 changes: 8 additions & 5 deletions src/Hosting.CommandLine/Internal/CommandLineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace McMaster.Extensions.Hosting.CommandLine.Internal
internal class CommandLineService : IDisposable, ICommandLineService
{
private readonly CommandLineApplication _application;
private readonly ILogger _logger;
private readonly ILogger<CommandLineService>? _logger;
private readonly CommandLineState _state;

/// <summary>
Expand All @@ -27,13 +27,16 @@ internal class CommandLineService : IDisposable, ICommandLineService
/// <param name="state">The command line state</param>
/// <param name="serviceProvider">The DI service provider</param>
/// <param name="configure">The delegate to configure the app</param>
public CommandLineService(ILogger<CommandLineService> logger, CommandLineState state,
IServiceProvider serviceProvider, Action<CommandLineApplication> configure)
public CommandLineService(
CommandLineState state,
IServiceProvider serviceProvider,
Action<CommandLineApplication> configure,
ILogger<CommandLineService>? logger = null)
{
_logger = logger;
_state = state;

logger.LogDebug("Constructing CommandLineApplication with args [{args}]", string.Join(",", state.Arguments));
logger?.LogDebug("Constructing CommandLineApplication with args [{args}]", string.Join(",", state.Arguments));
_application = new CommandLineApplication(state.Console, state.WorkingDirectory);

_application.Conventions
Expand All @@ -51,7 +54,7 @@ internal class CommandLineService : IDisposable, ICommandLineService
/// <inheritdoc />
public async Task<int> RunAsync(CancellationToken cancellationToken)
{
_logger.LogDebug("Running");
_logger?.LogDebug("Running");
_state.ExitCode = await _application.ExecuteAsync(_state.Arguments, cancellationToken);
return _state.ExitCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/CommandLineUtils.Tests/DotNetExeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// This file has been modified from the original form. See Notice.txt in the project root for more information.

#if NETCOREAPP || NET5_0
#if NETCOREAPP3_1_OR_GREATER
using System.IO;
using Xunit;

Expand Down
12 changes: 6 additions & 6 deletions test/CommandLineUtils.Tests/FilePathExistsAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public void ValidatesFilesMustExist(string? filePath)

public static TheoryData<string?> BadFilePaths
=> new()
{
"notfound.txt",
"\0",
null,
string.Empty,
};
{
"notfound.txt",
"\0",
null,
string.Empty,
};

[Fact]
public void ValidatesFilesRelativeToAppContext()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(TestFullFramework)' != 'false'">$(TargetFrameworks);net472</TargetFrameworks>
<!-- Once xunit supports nullable reference types, I might reconsider -->
<Nullable>annotations</Nullable>
Expand All @@ -16,11 +16,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="McMaster.Extensions.Xunit" Version="0.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
Expand Down
11 changes: 0 additions & 11 deletions test/CommandLineUtils.Tests/OptionAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,6 @@ public void BindsToStaticProperties()
Assert.Equal(1, PrivateSetterProgram.StaticNumber);
}

#if !NETCOREAPP3_1 && !NET5_0
// .NET Core 3.0 made an intentional breaking change
// see https://github.com/dotnet/coreclr/issues/21268
[Fact]
public void BindsToStaticReadOnlyProps()
{
CommandLineParser.ParseArgs<PrivateSetterProgram>("--static-string", "1");
Assert.Equal("1", PrivateSetterProgram.StaticString);
}
#endif

[Fact]
public void BindsToStaticPropertiesWithSetterMethod()
{
Expand Down
8 changes: 4 additions & 4 deletions test/CommandLineUtils.Tests/ValueParserProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,10 @@ public void ItParsesParamofT(Type type, string input, object expected)

public static TheoryData<Type, string, object> TupleData
=> new()
{
{ typeof((bool, int?)), "", (true, default(int?)) },
{ typeof((bool, int)), "123", (true, 123) },
};
{
{ typeof((bool, int?)), "", (true, default(int?)) },
{ typeof((bool, int)), "123", (true, 123) },
};

private static readonly MethodInfo s_itParsesOptionOfTImpl
= typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesOptionOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance)!;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(TestFullFramework)' != 'false'">$(TargetFrameworks);net472</TargetFrameworks>
</PropertyGroup>

Expand All @@ -14,9 +14,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
Expand Down