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

Missing BindAsync overload #225

Open
danigutsch opened this issue Dec 27, 2024 · 0 comments
Open

Missing BindAsync overload #225

danigutsch opened this issue Dec 27, 2024 · 0 comments

Comments

@danigutsch
Copy link

danigutsch commented Dec 27, 2024

The BindAsync overload for Task<Result<TSource>> and Result destination is missing.

Minimal repro:

Create a new web API project and install Ardalis.Result and Ardalis.Result.AspNetCore.

Program.cs:

using Ardalis.Result;
using Ardalis.Result.AspNetCore;

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

app.UseHttpsRedirection();

app.MapGet("/", async () =>
{
    var result = await SomeMethod();

    result.ToMinimalApiResult();
});

app.Run();

return;

async Task<Result> SomeMethod()
{
    return await SomeAsyncIntResult()
        .BindAsync(i => SomeSyncResult());
}

static Result SomeSyncResult()
{
    return Result.Success();
}

static async Task<Result<int>> SomeAsyncIntResult()
{
    await Task.Delay(0);
    return Result<int>.Success(1);
}

The code fails with: System.NullReferenceException: 'Object reference not set to an instance of an object.'

Proposed solution is in PR #224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant