Skip to content

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

@Meberem

Description

@Meberem

Describe the bug

If a Blazor Component has multiple Generic Parameters then EventCallbacks 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

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions