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

Avoid loading assemblies that only contain IDE analyzers #59554

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ async Task<CompilationWithAnalyzersCacheEntry> GetOrCreateCacheEntryAsync()
}
}

/// <summary>
/// List of assemblies that contain analyzers that only run in-proc and should not be loaded OOP.
/// </summary>
private static readonly ImmutableArray<string> s_wellKnownAssembliesContainingIdeAnalyzersOnly = ImmutableArray.Create(
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, do we actually load those assemblies in OOP? (i thought so, but the integration tests are passing now so I'm confused)

"Microsoft.CodeAnalysis.EditorFeatures",
"Microsoft.CodeAnalysis.ExternalAccess.FSharp",
"Microsoft.VisualStudio.LanguageServices.Xaml");

private static async Task<CompilationWithAnalyzersCacheEntry> CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken)
{
// We could consider creating a service so that we don't do this repeatedly if this shows up as perf cost
Expand All @@ -255,6 +263,13 @@ private static async Task<CompilationWithAnalyzersCacheEntry> CreateCompilationW
continue;
}

// do not attempt to load assemblies that we know only have IDE analyzers.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// do not attempt to load assemblies that we know only have IDE analyzers.
// do not attempt to load assemblies that we know only have IDE (in-process) analyzers.

if (reference.FullPath != null &&
s_wellKnownAssembliesContainingIdeAnalyzersOnly.Contains(FileNameUtilities.GetFileName(reference.FullPath, includeExtension: false)))
{
continue;
}

var analyzers = reference.GetAnalyzers(project.Language);
analyzerBuilder.AddRange(analyzers);
analyzerMapBuilder.AppendAnalyzerMap(analyzers);
Expand Down