razor icon indicating copy to clipboard operation
razor copied to clipboard

EventCallback<TValue> with a Generic Component with multiple Generic Arguments causes an error

Open Meberem opened this issue 5 years ago • 6 comments

Describe the bug

If a Blazor Component has multiple Generic Parameters then EventCallbacks<TValue> cannot be bound without an intermediary class.

To Reproduce

GenericComponent.cs

@typeparam THeader
@typeparam TRow
<h3>GenericComponent</h3>

@code {
    [Parameter]
    public EventCallback<TRow[]> Callback { get; set; }

    [Parameter]
    public EventCallback<CustomArgs<TRow>> CallbackWithClass { get; set; }
}

CustomArgs.cs

public class CustomArgs<TValue>
{
    public TValue[] Values { get; set; }
}

public class Abc
{
}

public class Def
{
}

TestComponent.cs

<GenericComponent
    THeader="Abc"
    TRow="Def"
    Callback="Callback" <-------------------------- Error
    CallbackWithClass="CallbackWithClass"
/>

@code {
    public async Task Callback(Def[] value)
    {
        await Task.CompletedTask;
    }

    public async Task CallbackWithClass(CustomArgs<Def> args)
    {
        await Task.CompletedTask;
    }
}

Exceptions (if any)

CS1503 Argument 2: cannot convert from 'method group' to 'EventCallback'

Further technical details

  • ASP.NET Core version: 5.0.0
  • Include the output of dotnet --info Version: 5.0.100 Commit: 5044b93829
  • Visual Studio Community 2019 v16.8.2

Meberem avatar Dec 04 '20 12:12 Meberem

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Dec 07 '20 17:12 ghost

If fixing this, verify that the scenario described at https://github.com/dotnet/aspnetcore/issues/29871 is fixed too. If not, reopen that issue.

SteveSandersonMS avatar Feb 19 '21 16:02 SteveSandersonMS

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Jul 20 '21 17:07 ghost

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Nov 11 '21 17:11 ghost

Any updates on this?

Jinjinov avatar Feb 18 '24 18:02 Jinjinov

Still not working.

It seems that you have to

Callback="async (ConcreteType thing) => await Callback(thing)"

which is rather cumbersome.

rwb196884 avatar Nov 10 '25 15:11 rwb196884