Repository navigation
Fix razor generator/ed files not appearing in solution explorer - #85673
davidwengier merged 4 commits into
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
| internal bool IsPrimaryProject(ProjectId projectId) | ||
| => GetProjectSystemProject(projectId)?.IsPrimary ?? true; | ||
|
|
||
| internal string? TryRedirectAnalyzerAssembly(ProjectId projectId, string fullPath) |
There was a problem hiding this comment.
I assumed based on the existing code that exposing the ProjectSystemProject from a method would be undesirable, but let me know if that's not the correct call, and I could move this and IsPrimaryProject to their call sites, and make the API of this class a little less big-grab-bag-of-stuff.
There was a problem hiding this comment.
🔵 Needs a closer look
Final human review is recommended for the cross-component Solution Explorer and Razor redirection changes.
Pull request overview
Fixes Razor source generators not appearing in Solution Explorer by applying analyzer redirection during CPS lookup and handling case differences.
Changes:
- Routes analyzer redirection through the workspace and CPS lookup.
- Makes Razor assembly mapping case-insensitive.
- Adds regression tests.
File summaries
| File | Summary |
|---|---|
src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProject.cs |
Exposes analyzer redirection. |
src/VisualStudio/Core/Test/SolutionExplorer/CpsDiagnosticItemSourceTests.vb |
Tests redirected generator discovery. |
src/VisualStudio/Core/Impl/SolutionExplorer/DiagnosticItem/CpsDiagnosticItemSourceProvider.cs |
Bridges CPS lookup to the workspace implementation. |
src/VisualStudio/Core/Impl/SolutionExplorer/DiagnosticItem/CpsDiagnosticItemSource.cs |
Redirects paths before reference lookup. |
src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs |
Provides the project-system redirection bridge. |
src/Razor/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.UnitTests/AssemblyRedirectorTests.cs |
Tests case-insensitive matching. |
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/RazorAnalyzerAssemblyRedirector.cs |
Handles lowercase CPS paths. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
jasonmalinowski
left a comment
There was a problem hiding this comment.
Overall the high level is fine, but I worry we introduced a potential race moving use of the ProjectSystemProject out of the lock. I think the method we were trying to call is just movable though, so should be an easy fix up.
| // CPS canonicalizes analyzer paths to lowercase, so match assembly names case-insensitively, otherwise the source | ||
| // generator doesn't show up in the Dependencies node in Visual Studio. | ||
| return compilerAssemblyTypes.ToFrozenDictionary(t => t.name, t => t.path, StringComparer.OrdinalIgnoreCase); |
There was a problem hiding this comment.
Hmm, did this mean we generally weren't redirecting?
There was a problem hiding this comment.
I haven't tested, but I could imagine its possible if someone manually referenced the Razor compiler but didn't match the casing in the msbuild include, then we might not redirect it. Of course, if someone manually referenced the Razor compiler, they're already out in no mans land, and how knows if they expect or get IDE support. We haven't had any issues that indicate anyone has done that.
|
Pushed changes to address the comments, thanks. I ended up sticking with a static class, as getting at the host info for an extension method, only to use a single property, made for a lot more spaghetti than I'd like. Let me know if you feel strongly though. |
Fixes #79052
Looks like:

Microsoft Reviewers: Open in CodeFlow