razor: RZ10020 error after upgrading to Visual Studio 17.6

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After upgrading to Visual Studio 17.6, with dotnet 7 SDK at 7.0.302, we are seeing the following Razor errors when using @bind-Value:get

RZ10020 Attribute 'bind-Value:get' can only be used with RazorLanguageVersion 7.0 or higher

image

Expected Behavior

No errors reported.

Steps To Reproduce

No response

Exceptions (if any)

RZ10020 Attribute ‘bind-Value:get’ can only be used with RazorLanguageVersion 7.0 or higher

.NET Version

7.0.302

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Issue still present in the new 17.7 GA release. 😞

This issue remains in VS 17.6.4.

In a new Blazor Server project, replace index.razor with this code. The error list indicates 6 errors, however the project still runs.

@page "/"

<PageTitle>Index</PageTitle>
<h1>Bind Get Set Examples</h1>

<h2>Elements</h2>

<input type="text" @bind:get="text" @bind:set="(value) => { text = value; }" />
<input type="text" @bind:get="text" @bind:set="Set" />
<input type="text" @bind:get="text" @bind:set="SetAsync" />

<h2>Components</h2>

<InputText @bind-Value:get="text" @bind-Value:set="(value) => { text = value; }" />
<InputText @bind-Value:get="text" @bind-Value:set="Set" />
<InputText @bind-Value:get="text" @bind-Value:set="SetAsync" />

@code {
    private string text = "";

    private void Set(string value)
    {
        text = value;
    }

    private Task SetAsync(string value)
    {
        text = value;
        return Task.CompletedTask;
    }
}

I updated to VS 17.6.3 and .NET 7.0.304, but this issue still remains. Was this intended to be fixed in those updates?

Set the following in your .csproj, wait VS to register the change, then delete it:

<RazorLanguageVersion>7</RazorLanguageVersion>

Resolved it for me, without restarting etc. Just after saving the csproj, an open .razor window flashed, and the errors cleared. Had already cleaned the solution, nixed bin/obj/.vs, to no avail.

I still cannot reproduce the issue, either, so this does appear to be a bug.

This has been fixed in subsequent updates.

I have same issue in 17.7.6. There was no errors when I wrote soemthing like @bind-Value:get="something" at first. But when I opened my computer next week the RZ10020 errors just came from nowhere.🤨

The project runs normally though.

@ryanbuening as @blake-fm said, the bind after stuff not being colourized is known, and tracked by https://github.com/dotnet/razor/issues/8552

@ryanbuening @bind:after was already behaving that way for us, prior to the kerfuffle in May.

Those two use CreateInferredEventCallback, which is… creative. Speculation: it may need its own special context to handle semantics.

I am getting this bug as well after upgrade and a completely new project (created after the upgrade)

I get this error too, although only in the editor. I don’t see it in build output

Same

I get this error too, although only in the editor. I don’t see it in build output