From ea665d3b00030a76715cc43f36fa163a252849b1 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Mon, 4 Nov 2024 16:42:23 -0800 Subject: [PATCH] Also check if analyzer reference is isolated file reference to handle .net core processes --- .../Common/AbstractProjectExtensionProvider.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Features/Core/Portable/Common/AbstractProjectExtensionProvider.cs b/src/Features/Core/Portable/Common/AbstractProjectExtensionProvider.cs index cf28b4a561435..b952df809e965 100644 --- a/src/Features/Core/Portable/Common/AbstractProjectExtensionProvider.cs +++ b/src/Features/Core/Portable/Common/AbstractProjectExtensionProvider.cs @@ -145,8 +145,10 @@ private ImmutableArray CreateExtensions(string language) if (TryGetExtensionsFromReference(this.Reference, out var extensions)) return extensions; + var analyzerFileReference = GetAnalyzerFileReference(this.Reference); + // otherwise, see whether we can pick it up from reference itself - if (this.Reference is not AnalyzerFileReference analyzerFileReference) + if (analyzerFileReference is null) return []; using var _ = ArrayBuilder.GetInstance(out var builder); @@ -183,5 +185,17 @@ private ImmutableArray CreateExtensions(string language) } return builder.ToImmutableAndClear(); + + static AnalyzerFileReference? GetAnalyzerFileReference(AnalyzerReference reference) + { + if (reference is AnalyzerFileReference analyzerFileReference) + return analyzerFileReference; +#if NET + if (reference is IsolatedAnalyzerFileReference isolatedReference) + return isolatedReference.UnderlyingAnalyzerFileReference; +#endif + + return null; + } } }