-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Description
If a generic component has a parameter property:
@typeparam T
@code {
[Parameter]
public Func<T[]> GetItems { get; set; }
}
When you use the component the GetItems will cause a build fail with the error "The type or namespace name T could not be found" since it generates this code for the page:
__builder.OpenComponent<BlazorTest.Client.Shared.GenericComponent<string>>(0);
__builder.AddAttribute(1, "GetItems", new System.Func<T[]>(GetItems)
But there is no definition of T there as T is defined on the comonent, it should generate as string[] not T[]
To Reproduce
With the component above create the following page
@page "/"
<GenericComponent T="string" GetItems="GetItems" />
@code {
string[] GetItems() => new[]
{
"Foo", "Bar"
};
}
As soon as you try to compile it will fail
I have tested this on 6.0.0-preview.6.21355.2
Metadata
Metadata
Assignees
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components