Skip to content

Commit

Permalink
feat: update ToTask usage
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi committed Mar 14, 2024
1 parent 36fb94d commit 6858c14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageVersion Include="NuGet.Protocol" Version="6.9.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="WeihanLi.Common" Version="1.0.64-preview-20240313-152853" />
<PackageVersion Include="WeihanLi.Common" Version="1.0.64-preview-20240314-151324" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
Expand Down
9 changes: 1 addition & 8 deletions src/dotnet-exec/Services/CodeExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,7 @@ protected async Task<Result<int>> ExecuteAssembly(Assembly assembly, ExecOptions
return Result.Fail("No valid EntryPoint found", ResultStatus.RequestError, (int)ResultStatus.RequestError);
}

await TaskHelper.ToTask(returnValue).ConfigureAwait(false);
var returnExitCode = returnValue switch
{
ValueTask<int> valueTaskValue => valueTaskValue.Result,
Task<int> taskValue => taskValue.Result,
int value => value,
_ => 0
};
var returnExitCode = await TaskHelper.ToTask<int>(returnValue).ConfigureAwait(false);
return Result.Success(returnExitCode);
}
catch (Exception e)
Expand Down

0 comments on commit 6858c14

Please sign in to comment.