-
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
Switch to workspace service to ensure the analyzer loader uses streams on linux #73809
Conversation
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/VSCodeAnalyzerLoader.cs
Outdated
Show resolved
Hide resolved
@@ -17,7 +17,7 @@ internal sealed class ProjectAnalyzerReference(string fullPath, IProjectSystemDi | |||
// NOTE: It is important that we share the same shadow copy assembly loader for all VisualStudioAnalyzer instances. | |||
// This is required to ensure that shadow copied analyzer dependencies are correctly loaded. | |||
private static readonly IAnalyzerAssemblyLoader s_analyzerAssemblyLoader = | |||
new ShadowCopyAnalyzerAssemblyLoader(Path.Combine(Path.GetTempPath(), "VS", "AnalyzerAssemblyLoader")); | |||
DefaultAnalyzerAssemblyLoader.CreateNonLockingLoader(Path.Combine(Path.GetTempPath(), "VS", "AnalyzerAssemblyLoader")); |
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 considered using the workspace service here, but that uses a different path in temp to put them, so I didn't. cc @jasonmalinowski
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.
Does this still run in VS Code? Other than the initializer running, does anything use it?
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.
resolved by adding a version of the service exported for the host workspace (using the VS/AnalyzerAssemblyLoader path)
src/Workspaces/Core/Portable/Workspace/Host/Metadata/AnalyzerAssemblyLoaderOptions.cs
Show resolved
Hide resolved
// Shadow copy analyzer files coming from packages to avoid locking the files in NuGet cache. | ||
// NOTE: The provider will always return the same singleton analyzer loader instance, which is important to | ||
// ensure that shadow copied analyzer dependencies are correctly loaded. | ||
_analyzerAssemblyLoader = provider.GetLoader(shadowCopy: true); |
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.
So do we pass false for shadow copy anywhere? Because I'm not really sure why that flag exists. It seems the shadow copy or not flag is really a host question more or less...or is the flag a "you might want to shadow copy" hint and saying no definitely opts out?
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.
We potentially do here -
writer.WriteBoolean(IsAnalyzerReferenceWithShadowCopyLoader(file)); |
I couldn't track down though where that could be coming from. For now will leave as-is.
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.
Want to file a bug to track?
src/Workspaces/Core/Portable/Diagnostics/HostAnalyzerAssemblyLoaderProvider.cs
Outdated
Show resolved
Hide resolved
...Server/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerWorkspaceFactory.cs
Outdated
Show resolved
Hide resolved
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/VSCodeAnalyzerLoader.cs
Outdated
Show resolved
Hide resolved
c14fe84
to
402ab2d
Compare
402ab2d
to
deccf46
Compare
src/LanguageServer/Protocol/Features/AbstractAnalyzerAssemblyLoaderProvider.cs
Outdated
Show resolved
Hide resolved
/// <summary> | ||
/// Provider to allow MEF access to <see cref="ExtensionAssemblyManager"/> | ||
/// Must be done this way as the manager is required to create MEF as well. | ||
/// </summary> |
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.
This is fine to go with for now, but I'm guessing there's some way we can directly inject the ExtensionAssemblyManager into the catalog. We do similar things though for logging as it is, so this isn't new.
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 did take a quick look. There's nothing in the discovery / catalog APIs that I could find where we could provide a specific instance of an export (we can manually add a type). This https://github.com/microsoft/vs-mef/blob/main/doc/dynamic_recomposition.md#adding-parts-directly-with-compositioncontainercompose also recommends basically what we're doing.
Resolves #73795