Skip to content

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

@gurunathancs1991

Description

@gurunathancs1991

Description:

When using EventCallBack<T>, I countered an issue about error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback'

I have checked other github blogs which related to this, mostly reported that, this has been fixed in preview 7 version. Right now, i have tested with preview 7 build but could not get resolve it.

Here the link which i checked earlier.
#10077
#8385
#10730
#10077

Whether any syntax changes required to resolve in preview 7 version?

Screenshot:
image

Please find my component structure:

Rendering Page [Index razor page]


      @page "/"
      @using GenericEvent.Shared.Models;
      @inject IJSRuntime jsruntime;

    <MyGenComponent Data="@MyData">
        <Events>
        <NonGenericEvents EventTwo="@Event2"></NonGenericEvents>
        <GenericEvents EventOne="@EventOne"></GenericEvents>
         </Events>

    </MyGenComponent>

    @functions {
        public List<string> MyData = new List<string>() { "a", "b", "c", "d" };

        public void Event2(EventArguments args)
       {

       }

       public async Task EventOne(EventArgsData<string> data)
       {
        //dummy call
        await jsruntime.InvokeAsync<string>("call");
       }
      }

MyGenComponent.razor


    @using GenericEvent.Shared.Models;

    @typeparam T;

    <div>
        <ul>
            @ChildContent
        </ul>
    </div>


    @functions {
    [Parameter]
    protected RenderFragment ChildContent { get; set; }

    [Parameter]
    public IEnumerable<T> Data { get; set; }
    }


Events.razor


      @using Microsoft.AspNetCore.Components;

      @inherits ComponentBase



     <CascadingValue Value="@this">
        @ChildContent
    </CascadingValue>

     @functions{

    [Parameter]
    protected RenderFragment ChildContent { get; set; }

    public GenericEvents<object> GenEvents { get; set; }

    public NonGenericEvents NonGenEvents { get; set; }



     }

GenericEvents.razor


      @using Microsoft.AspNetCore.Components;
      @using GenericEvent.Shared.Models;


       @typeparam TValue


      <CascadingValue Value="@this">

     </CascadingValue>


     @functions{
   
     [Parameter]
    public EventCallback<EventArgsData<TValue>> EventOne { get; set; }

    }



NonGenericEvents.razor

   @using Microsoft.AspNetCore.Components;
    @using GenericEvent.Shared.Models;




   <CascadingValue Value="@this">

   </CascadingValue>


   @functions{

     [Parameter]
     public EventCallback<EventArguments> EventTwo { get; set; }


     }

To Reproduce

Clone this Github repository and run the application

https://github.com/gurunathancs1991/BlazorGenericEvents

We are also expecting the solution for this thread too

#12116

Additional context


C:\Users\GurunathanA>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview7-012814
 Commit:    efad165932

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview7-012814\

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

.NET Core SDKs installed:
  1.1.13 [C:\Program Files\dotnet\sdk]
  1.1.14 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.2.202 [C:\Program Files\dotnet\sdk]
  2.2.300 [C:\Program Files\dotnet\sdk]
  3.0.100-preview7-012814 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview4-19216-03 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview7.19363.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview4-27615-11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: By DesignResolved because the behavior in this issue is the intended design.area-blazorIncludes: Blazor, Razor Componentscomponent ecosystemIndicates an issue which also has impact on 3rd party component ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions