diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs index 438c8ed501be7..46d1b3ed487f7 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs @@ -243,12 +243,20 @@ from supportedLanguage in supportedLanguages private static IEnumerable GetSupportedLanguages(TypeDefinition typeDef, PEModule peModule, Type attributeType, AttributeLanguagesFunc languagesFunc) { - var attributeLanguagesList = from customAttrHandle in typeDef.GetCustomAttributes() - where peModule.IsTargetAttribute(customAttrHandle, attributeType.Namespace!, attributeType.Name, ctor: out _) - let attributeSupportedLanguages = languagesFunc(peModule, customAttrHandle) - where attributeSupportedLanguages != null - select attributeSupportedLanguages; - return attributeLanguagesList.SelectMany(x => x); + foreach (CustomAttributeHandle customAttrHandle in typeDef.GetCustomAttributes()) + { + if (peModule.IsTargetAttribute(customAttrHandle, attributeType.Namespace!, attributeType.Name, ctor: out _)) + { + IEnumerable? attributeSupportedLanguages = languagesFunc(peModule, customAttrHandle); + if (attributeSupportedLanguages != null) + { + foreach (string item in attributeSupportedLanguages) + { + yield return item; + } + } + } + } } private static IEnumerable GetDiagnosticsAnalyzerSupportedLanguages(PEModule peModule, CustomAttributeHandle customAttrHandle)