-
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 issueDoneThis issue has been fixedThis issue has been fixedStatus: Resolvedaffected-very-fewThis issue impacts very few customersThis issue impacts very few customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-razor.languageinvestigateseverity-blockingThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
Describe the bug
Compiler error when using generic array parameter.
If there is no type parameter:
error RZ10001: The type of component 'Component' cannot be inferred based on the values provided. Consider specifying the type arguments directly using the following attributes: 'TItem'.
If type parameter is specified:
error CS0246: The type or namespace name 'TItem' could not be found (are you missing a using directive or an assembly reference?)
To Reproduce
Component.razor
@typeparam TItem
@code {
[Parameter]
public TItem[] List { get; set; }
}
Page.razor
<Component TItem="System.Int32" List="new int[] { 1, 2, 3 }" />
Expected behavior
Compile without errors.
Actual behavior
Compilation error CS0246 in generated file:
__builder.AddAttribute(1, "List", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<TItem[]>());
Workaround
IReadOnlyList<TItem> works fine
sprotty, jirikanda, Rene-Sackers, SommerEngineering, Timovzl and 3 more
Metadata
Metadata
Assignees
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueDoneThis issue has been fixedThis issue has been fixedStatus: Resolvedaffected-very-fewThis issue impacts very few customersThis issue impacts very few customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-razor.languageinvestigateseverity-blockingThis label is used by an internal toolThis label is used by an internal tool