diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ed3cb72..517c342 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,6 +22,7 @@ jobs: dotnet-version: | 8.x 9.x + 10.x - name: Restore dependencies run: dotnet restore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16383a3..799f062 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,7 @@ jobs: dotnet-version: | 8.x 9.x + 10.x - name: Restore dependencies run: dotnet restore diff --git a/src/ProjectDiff.Core/ProjectDiff.Core.csproj b/src/ProjectDiff.Core/ProjectDiff.Core.csproj index 8aa6c84..6a9070e 100644 --- a/src/ProjectDiff.Core/ProjectDiff.Core.csproj +++ b/src/ProjectDiff.Core/ProjectDiff.Core.csproj @@ -1,7 +1,7 @@  - net8.0;net9.0 + net8.0;net9.0;net10.0 enable enable ProjectDiff.Core @@ -16,14 +16,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/dotnet-proj-diff/ProjectDiffTool.cs b/src/dotnet-proj-diff/ProjectDiffTool.cs index dbb2edd..a0e43c0 100644 --- a/src/dotnet-proj-diff/ProjectDiffTool.cs +++ b/src/dotnet-proj-diff/ProjectDiffTool.cs @@ -2,21 +2,42 @@ namespace ProjectDiff.Tool; -public static class ProjectDiffTool +public class ProjectDiffTool { - public static CommandLineConfiguration BuildCli(IConsole console, TextWriter? stderr = null, TextWriter? stdout = null) + private readonly RootCommand _command; + private readonly TextWriter? _stderr; + private readonly TextWriter? _stdout; + + public ProjectDiffTool(RootCommand command, TextWriter? stderr, TextWriter? stdout) + { + _command = command; + _stderr = stderr; + _stdout = stdout; + } + + public static ProjectDiffTool BuildCli(IConsole console, TextWriter? stderr = null, TextWriter? stdout = null) + { + var cli = new ProjectDiffCommand(console); + + + return new ProjectDiffTool(cli, stderr, stdout); + } + + public async Task InvokeAsync(IReadOnlyList args, CancellationToken cancellationToken = default) { - var cli = new CommandLineConfiguration(new ProjectDiffCommand(console)); - if (stderr is not null) + var parseResult = _command.Parse(args); + + var config = new InvocationConfiguration(); + if (_stderr is not null) { - cli.Error = stderr; + config.Error = _stderr; } - if (stdout is not null) + if (_stdout is not null) { - cli.Output = stdout; + config.Output = _stdout; } - return cli; + return await parseResult.InvokeAsync(config, cancellationToken); } } diff --git a/src/dotnet-proj-diff/dotnet-proj-diff.csproj b/src/dotnet-proj-diff/dotnet-proj-diff.csproj index e2976e1..d9d8cdf 100644 --- a/src/dotnet-proj-diff/dotnet-proj-diff.csproj +++ b/src/dotnet-proj-diff/dotnet-proj-diff.csproj @@ -2,7 +2,7 @@ Exe - net8.0;net9.0 + net8.0;net9.0;net10.0 enable enable true @@ -16,19 +16,20 @@ + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/ProjectDiff.Tests/ProjectDiff.Tests.csproj b/test/ProjectDiff.Tests/ProjectDiff.Tests.csproj index 3074f16..b0c4945 100644 --- a/test/ProjectDiff.Tests/ProjectDiff.Tests.csproj +++ b/test/ProjectDiff.Tests/ProjectDiff.Tests.csproj @@ -1,7 +1,7 @@  - net8.0;net9.0 + net8.0;net9.0;net10.0 enable enable false @@ -12,17 +12,18 @@ + - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs index 200f2e6..bb50404 100644 --- a/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs +++ b/test/ProjectDiff.Tests/Tool/ProjectDiffTests.cs @@ -337,15 +337,6 @@ public async Task DetectsAddedProjectsWithDirectoryScan() await VerifyJson(output); } - [Fact] - public void BuildingCliIsValid() - { - var console = new TestConsole(Directory.GetCurrentDirectory()); - var cli = ProjectDiffTool.BuildCli(console); - cli.ThrowIfInvalid(); - } - - private static async Task ExecuteAndReadStdout( TestRepository repository, params string[] args