Skip to content

.NET 7 regression generic array parameters 35980 #48526

@Bouke

Description

@Bouke

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a component like this:

@* SelectMultiple.razor *@
@typeparam TItem
@inherits InputBase<TItem[]>
@code {
    [Parameter, EditorRequired]
    public TItem[] Options { get; set; } = null!;
    protected override bool TryParseValueFromString(string? value, out TItem[] result, out string validationErrorMessage) => throw new NotImplementedException();
}

Which is used like this:

<SelectMultiple @bind-Value="Selected" Options="Options" />
@code {
    string[] Selected { get; set; } = Array.Empty<string>();
    string[] Options { get; }
}

With .NET 6 SDK this builds and runs just fine, I believe as a result of #35980. With the .NET 7 SDK this fails with the following error:

0>/private/tmp/BlazorGeneric/BlazorGeneric/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Counter_razor.g.cs(138,96): Error CS0400 : The type or namespace name 'TItem' could not be found in the global namespace (are you missing an assembly reference?)
0>/private/tmp/BlazorGeneric/BlazorGeneric/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Counter_razor.g.cs(138,111): Error CS1503 : Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<string[]>' to 'Microsoft.AspNetCore.Components.EventCallback'

Expected Behavior

With .NET 6 SDK this builds and runs just fine. I expect the .NET 7 SDK to not introduce regressions.

Steps To Reproduce

repro

Exceptions (if any)

No response

.NET Version

7.0.203

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions