-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow VS Code to provide razor source geneator references. #72482
Allow VS Code to provide razor source geneator references. #72482
Conversation
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
{ | ||
// This method is used to load an analyzer assembly from the specified path. | ||
// In this simple implementation, we use Assembly.LoadFrom to load the assembly. | ||
return Assembly.LoadFrom(fullPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you talk with Jason at all about which assembly load context the source generator should be loaded in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall that conversation.
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
- Rename option to be `RazorSourceGenerator` - Cache results in analyzer provider, since result is fixed per roslyn instance - Remove duped names taken out of ProjectSystemProject
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/HostDiagnosticAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
@@ -1002,6 +1002,7 @@ public void RemoveAnalyzerReference(string fullPath) | |||
|
|||
private OneOrMany<string> GetMappedAnalyzerPaths(string fullPath) | |||
{ | |||
fullPath = Path.GetFullPath(fullPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still necessary, now that the full path is being passed in by the client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is needed.
Without this change, variable will be:
s_razorSourceGeneratorSdkDirectory
"Sdks\\Microsoft.NET.Sdk.Razor\\source-generators\\"
fullPath
"C:\\Program Files\\dotnet\\sdk\\6.0.420\\Sdks\\Microsoft.NET.Sdk.Razor\\targets\\..\\\\source-generators\\Microsoft.NET.Sdk.Razor.SourceGenerators.dll"
Path.DirectorySeparatorChar
92 '\\'
and the if condition below would be false and we won't go through getting analyzer references at all:
if (fullPath.LastIndexOf(s_razorSourceGeneratorSdkDirectory, StringComparison.OrdinalIgnoreCase) + s_razorSourceGeneratorSdkDirectory.Length - 1 ==
fullPath.LastIndexOf(Path.DirectorySeparatorChar))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a surprising value for fullPath. I thought this code also ran in VS, so I'm confused as to how it works there.
Removing auto-merge, just in case :) |
Fixes Work Item 1926900
/cc @CyrusNajmabadi @davidwengier @chsienki @dibarbet
Needs dotnet/vscode-csharp#6960 to complete the end to end workflow.