Skip to content
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

Merged
merged 6 commits into from
Jun 7, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented May 31, 2024

Resolves #73795

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels May 31, 2024
@@ -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"));
Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

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)

@dibarbet dibarbet marked this pull request as ready for review May 31, 2024 19:46
@dibarbet dibarbet requested a review from a team as a code owner May 31, 2024 19:46
// 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);
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

@dibarbet dibarbet force-pushed the fix_analyzer_loading_linux branch from c14fe84 to 402ab2d Compare June 6, 2024 01:15
Comment on lines +16 to +19
/// <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>
Copy link
Member

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.

Copy link
Member Author

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.

@dibarbet dibarbet merged commit f0a5241 into dotnet:main Jun 7, 2024
25 checks passed
@dibarbet dibarbet deleted the fix_analyzer_loading_linux branch June 7, 2024 17:47
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 7, 2024
@jjonescz jjonescz modified the milestones: Next, 17.11 P3 Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filesystem pollution in /tmp/
5 participants