From 10781014da743064dda71b6d67f913c7e1dc516a Mon Sep 17 00:00:00 2001 From: tmat Date: Mon, 14 Feb 2022 18:32:53 -0800 Subject: [PATCH] Avoid loading assemblies that only contain IDE analyzers --- .../DiagnosticAnalyzer/DiagnosticComputer.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/DiagnosticComputer.cs b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/DiagnosticComputer.cs index b99ff55be839f..20256ce81bce7 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/DiagnosticComputer.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/DiagnosticAnalyzer/DiagnosticComputer.cs @@ -238,6 +238,14 @@ async Task GetOrCreateCacheEntryAsync() } } + /// + /// List of assemblies that contain analyzers that only run in-proc and should not be loaded OOP. + /// + private static readonly ImmutableArray s_wellKnownAssembliesContainingIdeAnalyzersOnly = ImmutableArray.Create( + "Microsoft.CodeAnalysis.EditorFeatures", + "Microsoft.CodeAnalysis.ExternalAccess.FSharp", + "Microsoft.VisualStudio.LanguageServices.Xaml"); + private static async Task 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 @@ -255,6 +263,13 @@ private static async Task CreateCompilationW continue; } + // do not attempt to load assemblies that we know only have IDE 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);