Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler should not report Warning RZ2012 when using Blazor bind syntax #11292

Closed
bonsall opened this issue Dec 10, 2024 · 1 comment
Closed
Labels
area-compiler Umbrella for all compiler issues untriaged

Comments

@bonsall
Copy link

bonsall commented Dec 10, 2024

Version Used: C# 12, C# 13 (potentially older C# versions as well)

Steps to Reproduce:

  1. Create a blazor component that is setup to leverage the @bind-VariableName syntax that blazor provides, by adding Parameter properties that also have the EditorRequiredAttribute supplied. For example: [Parameter, EditorRequired] public string Value { get; set; }, [Parameter, EditorRequired] public EventCallback<string> ValueChanged { get; set; }, and [Parameter, EditorRequired] public Expression<Func<string>> ValueExpression { get; set; }
  2. Use this blazor component anywhere in the application and use the bind syntax to set the variables <MyComponent @bind-Value="SomeVariable" />
  3. Compiler will produce warning RZ2012 for both the ValueChanged and ValueExpression parameters, which is incorrect since those parameters are being set.

EX:
SomeInput.razor

@* Any Markup, it does't really matter *@
@code {
    [Parameter, EditorRequired]
    public string? Value { get; set; }

    [Parameter, EditorRequired]
    public EventCallback<string?> ValueChanged { get; set; }

    [Parameter, EditorRequired]
    public Expression<Func<string?>> ValueExpression { get; set; }
}

App.razor

<SomeInput @bind-Value="MyValue" />

@code {
    public string? MyValue { get; set; }
}

Diagnostic Id: RZ2012

Expected Behavior: No RZ2012 warning is produced.

Actual Behavior: An RZ2012 warning is produced.

@jjonescz
Copy link
Member

This is fixed by #11043 which will be in a future .NET 9.0.200 release.

@jjonescz jjonescz transferred this issue from dotnet/roslyn Dec 11, 2024
@jjonescz jjonescz added the area-compiler Umbrella for all compiler issues label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues untriaged
Projects
None yet
Development

No branches or pull requests

2 participants