-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
The Razor Editor Tooling specifically (and not the regular Razor compiler) shows errors in the VS warning list for ambiguous types when a type name for a component exists in more than 1 namespace (even though only one of those types is an actual IComponent).
The actual compilation works fine and the app runs, but you get these spurious errors in VS's error list that are distracting and confusing.
The bug seems to be due to this line where it writes out the as-typed tag name:
https://github.com/dotnet/aspnetcore/blob/master/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs#L527
It seems to use the TagName instead of the full type name due to the comment at the top of this method:
https://github.com/dotnet/aspnetcore/blob/master/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs#L518-L521
So this code is written in this slightly unusual way to avoid the "unused namespace" error, but can instead cause an ambiguous reference error.
To Reproduce
- Clone this repo: https://github.com/Eilon/AddMessageNotificationSample
- Open in VS for Windows (VS Code probably shows the same problem, but I think there are some other tooling bug there that will distract from it)
- Open the file
HelloWorld.razor - Look in the VS Error List and see 4 "ambiguous reference" errors
Further technical details
Microsoft Visual Studio Enterprise 2019 Preview
Version 16.8.0 Preview 2.1
VisualStudio.16.Preview/16.8.0-pre.2.1+30428.66
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Enterprise
Visual C++ 2019 00435-60000-00000-AA935
Microsoft Visual C++ 2019
ASP.NET and Web Tools 2019 16.8.259.4173
ASP.NET and Web Tools 2019
ASP.NET Core Razor Language Services 16.1.0.2042706+bfe936d4db2120e689274a4e0a088f72f424c7cd
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2019 16.8.259.4173
For additional information, visit https://www.asp.net/
Pre-requisite checklist
- Steps to reproduce the issue
- Razor Language Server client logs included.
- HTML Language Server client logs included
