Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cd-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 #v5.2.0
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 #v6.0.0
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore src/MinimalCli.sln
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 #v5.2.0
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 #v6.0.0
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore src/MinimalCli.sln
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 #v5.2.0
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 #v6.0.0
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: Restore dependencies
run: dotnet restore src/MinimalCli.sln
Expand Down
5 changes: 3 additions & 2 deletions src/MinimalCli.Core/CommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ public void SetHandler(Delegate handler)

if (returnType == typeof(Task))
{
var task = (Task)_delegateHandler.DynamicInvoke(dynamicArguments.ToArray());
return task;
Task? returnTask = _delegateHandler.DynamicInvoke(dynamicArguments.ToArray()) as Task;
return returnTask
?? Task.FromException(new InvalidOperationException("Invoke of command failed."));
}
else if (returnType == typeof(void))
{
Expand Down
6 changes: 4 additions & 2 deletions src/MinimalCli.Core/CommandBuilderOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace MinimalCli;
public class CommandBuilder<THandler>
where THandler : notnull
{
IServiceProvider _serviceProvider;
readonly IServiceProvider _serviceProvider;
internal Command Command;

internal CommandBuilder(Command cmd,
Expand Down Expand Up @@ -95,7 +95,9 @@ internal async Task handlerActivator(ParseResult parseResult)

if (returnType == typeof(Task))
{
var task = (Task)dlgt.DynamicInvoke(dynamicArguments.ToArray());
Task? task = dlgt.DynamicInvoke(dynamicArguments.ToArray()) as Task
?? throw new InvalidOperationException("Invoke of command failed.");

await task.ConfigureAwait(false);
}
else if (returnType == typeof(void))
Expand Down
2 changes: 1 addition & 1 deletion src/MinimalCli.Core/CommandExecutorShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public int Execute(RootCommand rootCommand, string[] args)
private static bool GetInput(RootCommand rootCommand, string prompt, string[] exitCommands, out ParseResult? result)
{
Console.Write(prompt + "> ");
string commandString = Console.ReadLine();
string? commandString = Console.ReadLine() ?? "";

foreach (string exitCmd in exitCommands)
{
Expand Down
2 changes: 1 addition & 1 deletion src/MinimalCli.Core/MinimalCli.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<PackageId>MinimalCli.Core</PackageId>
Expand Down
3 changes: 2 additions & 1 deletion src/MinimalCli.Core/MinimalCommandLineApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public void SetRootHandler(Delegate handler)

if (returnType == typeof(Task))
{
var task = (Task)_delegateHandler.DynamicInvoke(dynamicArguments.ToArray());
Task task = _delegateHandler.DynamicInvoke(dynamicArguments.ToArray()) as Task
?? throw new InvalidOperationException("Invoke of command failed.");
return task;
}
else if (returnType == typeof(void))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MinimalCli" Version="2.0.5.58" />
<PackageReference Include="MinimalCli" Version="2.0.8.2" />
</ItemGroup>

</Project>
8 changes: 5 additions & 3 deletions src/MinimalCli/MinimalCli.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<PackageId>MinimalCli</PackageId>
Expand All @@ -27,9 +27,11 @@
<ItemGroup>
<!-- Runtime library -->
<Content Include="..\MinimalCli.Core\bin\$(Configuration)\netstandard2.0\MinimalCli.Core.dll" Pack="true" PackagePath="lib/netstandard2.0/" />
<Content Include="..\MinimalCli.Core\bin\$(Configuration)\net8.0\MinimalCli.Core.dll" Pack="true" PackagePath="lib/net8.0/" />
<Content Include="..\MinimalCli.Core\bin\$(Configuration)\net8.0\MinimalCli.Core.dll" Pack="true" PackagePath="lib/net8.0/" />
<Content Include="..\MinimalCli.Core\bin\$(Configuration)\net9.0\MinimalCli.Core.dll" Pack="true" PackagePath="lib/net9.0/" />
<Content Include="..\MinimalCli.Core\bin\$(Configuration)\net10.0\MinimalCli.Core.dll" Pack="true" PackagePath="lib/net10.0/" />

<!-- Source generator library -->
<!-- Source generator library -->
<Content Include="..\MinimalCli.SourceGenerator\bin\$(Configuration)\netstandard2.0\MinimalCli.SourceGenerator.dll" Pack="true" PackagePath="analyzers/dotnet/cs/" />
</ItemGroup>

Expand Down