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

Load analyzers and generators in isolated ALCs in our OOP process #74780

Merged
merged 191 commits into from
Aug 27, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Aug 15, 2024

Fixes #48083

This will allow reloading of them when they change on disk.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 15, 2024
@@ -15,20 +15,22 @@ namespace Microsoft.CodeAnalysis.Host;
internal abstract class AbstractAnalyzerAssemblyLoaderProvider : IAnalyzerAssemblyLoaderProvider
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view with whitespace off.

@@ -12,6 +12,10 @@
using System.Runtime.InteropServices;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view with whitespace off.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a few nitpicks, or questions which don't need to be answered prior to merging, looks good. :shipit: If you haven't, you may want to run an RPS run to ensure the changing of paths in %TEMP% doesn't cause an unexplainable regression.

Comment on lines 27 to 31
/// We include the <see cref="WorkspaceKind"/> of the workspace in the path we produce. That way we don't
/// collide in the common case of a normal host workspace and OOP workspace running together. This avoids an
/// annoying exception as each will try to clean up this directory, throwing exceptions because the other is
/// locking it. The exception is fine, since the cleanup is just hygienic and isn't intended to be needed for
/// correctness. But it is annoying and does cause noise in our perf test harness.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an observation -- this code is relatively new. I don't understand why it ever would have been necessary, but we should be on the lookout for this problem coming back. Maybe give it a few RPS runs first or something?

}

public Assembly LoadFromPath(string fullPath)
=> throw new InvalidOperationException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider putting a "This test should not be loading analyzer assemblies" so if somebody doesn't know what this is it'll be a bit clearer.

// Load all analyzers into a fresh shadow copied load context. In the future, if we want to support reloading
// of solution-level analyzer references, we should just need to listen for changes to those analyzer paths and
// then call back into this method to update hte solution accordingly.
var analyzerLoader = loaderProvider.CreateNewShadowCopyLoader();
Copy link
Member

@dibarbet dibarbet Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me. Will have to reload VSCode to reload sln level analyzers, but those should be way way less common than project based ones.

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…stemProject.cs

Co-authored-by: Jason Malinowski <jason@jason-m.com>
@CyrusNajmabadi CyrusNajmabadi merged commit 7c7a412 into dotnet:main Aug 27, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the isolatedALC branch August 27, 2024 16:54
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 27, 2024
@Youssef1313
Copy link
Member

@CyrusNajmabadi Are they now never run in devenv and always run in ServiceHub.RoslynCodeAnalysisService? Does that mean they can start working in IDE and target net8.0+?

@CyrusNajmabadi
Copy link
Member Author

Are they now never run in devenv and always run in ServiceHub.RoslynCodeAnalysisService?

No. Users can have their VS setup to run generators in proc.

Does that mean they can start working in IDE and target net8.0+?

That's not a decision for me. It's up to @jaredpar and the team. That said, nothing stops people from using our public APIs which load analzyer refs in proc. So as long as that's a supported scenario, then netstandard2 will need to be there.

@jasonmalinowski
Copy link
Member

@Youssef1313: targeting net8.0 would still cause issues for anybody who won't have that change; at best this gets in to 17.12 so they'll be a lot of users that haven't upgraded. I don't imagine we'll be dropping netstandard use in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visual Studio does not reload source generator assemblies when they change on disk
7 participants