dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.5k stars 10.04k forks source link

VS Community Preview 16.1.0 - Razor Components intellisense errors #9320

Closed aford22 closed 5 years ago

aford22 commented 5 years ago

Describe the bug

Regression with VS Community Preview 16.1.0 that was not present in previous Preview release. When authoring Razor Components the "Errors" window and Intellisense both show the same compilation "errors" that are not errors. The project still builds and runs despite those errors. See screenshot of error window: image

These false compilation errors were not present in previous VS Community preview release.

To Reproduce

Steps to reproduce the behavior:

  1. Install VS Community Preview 16.1.0
  2. Use Razor Components "example" project that shipped with previous release of VS Community Preview (the project with the "Counter" page and "Fetch Data" weather forecasts page). I.e. the code:
    
    @page "/counter"
    @using WebApplication1.Services
    @inject WeatherForecastService ForecastService

Counter

Current count: @currentCount

@functions { int currentCount = 0;

void IncrementCount()
{
    currentCount++;
}

}


3. Build the project. You will see the false compilation errors
![image](https://user-images.githubusercontent.com/11410374/56026062-4975ef80-5d0b-11e9-87ef-7ac5bcc51331.png)
4. Project builds successfully and can be run with no issues

### Expected behavior
False compilation errors should not be present in the "Errors" window nor as red wavy lines in the main "Code Editor" window

### Additional context
These issues were not present in previous VS Community Preview release
NTaylorMullen commented 5 years ago

@aford22 a few questions to properly diagnose what you're seeing.

aford22 commented 5 years ago

Are you able to reproduce the issue with a new project?

Well, unfortunately the "Razor Components" project template has disappeared from the latest VS Comm release... as have the Blazor project templates. This is a problem in itself.

However if I use the "ASP.Net Core Web Application" template then "Web Application" to create a new project, there are lots of files that then need changed to make them work with Razor Components. Like Startup, index, .csproj, etc. Its hacking the whole newly generated project so much that I am not sure what this proves...

What's your dotnet --info output?

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview3-010431
 Commit:    d72abce213

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\

Host (useful for support):
  Version: 3.0.0-preview3-27503-5
  Commit:  3844df9537

.NET Core SDKs installed:
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.1.505 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.1.700-preview-009597 [C:\Program Files\dotnet\sdk]
  2.2.101 [C:\Program Files\dotnet\sdk]
  3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview3-27504-2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Do you see your button tag in Counter.razor as purple?

No, its blue. See screenshot. image You can also see the false error red wavy line...

Would you mind pasting the contents of your .csproj

Surely:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview3-19153-02" />
  </ItemGroup>

</Project>
henkmollema commented 5 years ago

I'm having the same issue with SDK v3.0.100-preview3-010431 and VS 16.1 Preview 1. I can reproduce it by creating a new Razor Components project with dotnet new razorcomponents and opening it in Visual Studio. I receive errors such as:

CS0428  Cannot convert method group 'IncrementCount' to non-delegate type 'object'. Did you intend to invoke the method? C:\tmp\razorcomponents\Components\Pages\Counter.razor:7

Also the HTML tags don't get their correct colorization:

image

The csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <_RazorComponentInclude>Components\**\*.cshtml</_RazorComponentInclude>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.Server" Version="3.0.0-preview3-19153-02" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview3-19153-02" />
  </ItemGroup>
</Project>
mkArtakMSFT commented 5 years ago

Thanks for contacting us folks. We believe this is now fix in our nightly releases and will be released as part of the next preview release.

GerritBergen commented 5 years ago

@mkArtakMSFT Any idea when the release that fixes this will come out?

henkmollema commented 5 years ago

Updating to Preview 4 fixed this for me, using the same VS 16.1 Preview 1 version.

GerritBergen commented 5 years ago

@henkmollema oh I see. I'm having the same issue with VS 16.0.2 (public release) running core preview 4. Guess they fixed it in VS 16.1. I'll probably just deal with it until 16.1 goes public.

tedekeroth commented 5 years ago

I would like to reopen this issue, as this is present also in 3.0.100-preview5-011568. If I clone this repo: https://github.com/torhovland/blazor-realworld-example-app

and replace the version of core in global.json with "3.0.100-preview5-011568", the exact behaviour as above appears:

Im running VS2019 Preview, v 16.2.0 Preview 1.0

Here is my dotnet --info:

C:\Users\wagge>dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100-preview5-011568 Commit: b487ff10aa

Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\

Host (useful for support): Version: 3.0.0-preview5-27626-15 Commit: 61f30f5a23

.NET Core SDKs installed: 2.1.507 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.1.800-preview-009677 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 2.2.400-preview-010195 [C:\Program Files\dotnet\sdk] 3.0.100-preview5-011568 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

rynowak commented 5 years ago

Hi, it looks like you are posting on a closed issue/PR/commit!

We're very likely to lose track of your bug/feedback/question unless you:

  1. Open a new issue
  2. Explain very clearly what you need help with
  3. If you think you have found a bug, include detailed repro steps so that we can investigate the problem

Thanks!

tedekeroth commented 5 years ago

INdeed, i thought it would be good to re-open an issue that wasnt really resolved, but I can create a new one of course =)

MrFoxPro commented 5 years ago

Same error on 3.0.100-preview6-012264 / Razor.VSCode. Should be reopened

rynowak commented 5 years ago

Hi, it looks like you are posting on a closed issue/PR/commit!

We're very likely to lose track of your bug/feedback/question unless you:

  1. Open a new issue
  2. Explain very clearly what you need help with
  3. If you think you have found a bug, include detailed repro steps so that we can investigate the problem

Thanks!