dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
499 stars 191 forks source link

[Blazor .NET 8] Missing rendermode Symbol in Default Interactivity Auto Template #9618

Closed Ayymoss closed 11 months ago

Ayymoss commented 11 months ago

Is there an existing issue for this?

Describe the bug

Building a new Blazor app with auto interactivity prompted by --help page returns missing symbol in resulting project.

 -int, --interactivity <None|Server|...>  Chooses which interactive render mode to use for interactive components
                                           Type: choice
                                             None         No interactivity (static server rendering only)
                                             Server       Runs on the server
                                             WebAssembly  Runs in the browser using WebAssembly
                                             Auto         Uses Server while downloading WebAssembly assets, then uses
                                           WebAssembly
                                           Default: Server

Expected Behavior

For the render mode attribute to correctly work.

Steps To Reproduce

dotnet new blazor --interactivity auto

In the Client -> Counter.razor page -> @rendermode InteractiveAuto -> "Cannot resolve symbol 'rendermode'"

Exceptions (if any)

Cannot resolve symbol 'rendermode'

.NET Version

8.0.100

Anything else?

Using Rider, but I created the template via CLI.

dotnet --info
.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.6c33ef20

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100\

.NET workloads installed:
 Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

.NET SDKs installed:
  6.0.414 [C:\Program Files\dotnet\sdk]
  8.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
MackinnonBuck commented 11 months ago

Thanks for reaching out. Does your project build without errors when you do so via the command line (dotnet build)?

ghost commented 11 months ago

Hi @Ayymoss. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Ayymoss commented 11 months ago

Hi, thanks for your reply. I probably should have checked that.

It seems to be a visual-only problem. Maybe specific to Rider?

D:\Users\Amos\Desktop\test>dotnet new blazor --interactivity auto
The template "Blazor Web App" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/8.0-third-party-notices for details.

Processing post-creation actions...
Restoring D:\Users\Amos\Desktop\test\test.sln:
  Determining projects to restore...
  Restored D:\Users\Amos\Desktop\test\test\test.csproj (in 215 ms).
  Restored D:\Users\Amos\Desktop\test\test.Client\test.Client.csproj (in 215 ms).
Restore succeeded.

D:\Users\Amos\Desktop\test>dotnet build
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  test.Client -> D:\Users\Amos\Desktop\test\test.Client\bin\Debug\net8.0\test.Client.dll
  test.Client (Blazor output) -> D:\Users\Amos\Desktop\test\test.Client\bin\Debug\net8.0\wwwroot
  test -> D:\Users\Amos\Desktop\test\test\bin\Debug\net8.0\test.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.93

D:\Users\Amos\Desktop\test>
uherman commented 11 months ago

Im experiencing this too, using JetBrains Rider 2023.3 EAP 7. The project builds and i am able to debug from inside Rider without issues so it is only a visual issue.

I tried to open the same Blazor project in VS-Code with the C# Dev Kit plugin and experienced no issues.

rmoudy commented 11 months ago

adding this to the _Imports.razor files seemed to fix the problem for me: @using static Microsoft.AspNetCore.Components.Web.RenderMode

Rider IntelliSense is still showing the error but now the solution builds successfully. In the latest VS 2022, the IntelliSense and the build work correctly.

Mayron commented 11 months ago

I just created a new project with the latest updated Visual Studio version using the "Blazor Web App" template with "Auto" interactivity rendering mode and I see the @using static Microsoft.AspNetCore.Components.Web.RenderMode line is already specified in the _Imports.razor file but I still see the error:

image

EDIT: Pretty sure this is a Resharper error.

GalaxyEClinical commented 11 months ago

I also created a new project with Visual Studio version 17.8.1 using the "Blazor Web App template with the Interactive Render Mode "WebAssembly" option. When I open the counter component, the @rendermode directive is highlighted in red (see attached screen snapshot).

When I build the solution, VS 2022 displays, "Build Succeeded." When I launch the app and click the Counter button, it increments as expected.

I have the latest release of JetBrains ReSharper 2023.2.3 installed.

RenderModeError

JitenShahani commented 11 months ago

I am also facing this same issue in Visual Studio 17.8.1. I also tested it in Visual Studio Preview 17.9.0 Preview 1 but the same problem persistes. I also use Rider and face the same problem their.

Bug

Mayron commented 11 months ago

I mentioned my issue over to the JetBrains Resharper issue tracker: https://youtrack.jetbrains.com/issue/RSRP-494352

I'd suggest anyone having this issue with Resharper to go over there instead. The latest version of Resharper has this issue, as well as the Early Access Program (EAP) version. So they need to do more work on their end to get this highlighting error issue fixed.

Someone shared a temporary fix if you follow that link and view the comments.

KarenTazayan commented 11 months ago

The same issue...

davidwengier commented 11 months ago

There are a lot of reports here, which is great, bit it's not clear if anyone is having this issue in Visual Studio without Resharper installed?

ertan2002 commented 11 months ago

There are a lot of reports here, which is great, bit it's not clear if anyone is having this issue in Visual Studio without Resharper installed?

Hi David

I have visual studio 2022 17.8.1 and have not installed resharper. and as you see it looks fine

image

but I am using Rider.

I face this issue in Rider. But I can build and run my project without an issue

image

PS: Rider IDE has already Resharper built-in

ameyer117 commented 11 months ago

There are a lot of reports here, which is great, bit it's not clear if anyone is having this issue in Visual Studio without Resharper installed?

It appears fine in Visual Studio 2022 Version 17.8.1 without Resharper.

Upon installing Resharper 2023.2.3 in Visual Studio, the issue appears.

ameyer117 commented 11 months ago

Here is the workaround I'm using in the meantime -> https://youtrack.jetbrains.com/issue/RSRP-494352/Support-rendermode-directive#focus=Comments-27-8415772.0-0

davidwengier commented 11 months ago

Thanks all. I'm going to close this issue, since it's a Rider/Resharper issue. The YouTrack link above is presumably the best place for updates.