private static IEnumerable <string> GetSupportedLanguages(TypeDefinition typeDef, PEModule peModule, Type attributeType, AttributeLanguagesFunc languagesFunc) { IEnumerable <string>?result = null; foreach (CustomAttributeHandle customAttrHandle in typeDef.GetCustomAttributes()) { if (peModule.IsTargetAttribute(customAttrHandle, attributeType.Namespace !, attributeType.Name, ctor: out _)) { if (languagesFunc(peModule, customAttrHandle) is { } attributeSupportedLanguages) { if (result is null) { result = attributeSupportedLanguages; } else { // This is a slow path, but only occurs if a single type has multiple // DiagnosticAnalyzerAttribute instances applied to it. result = result.Concat(attributeSupportedLanguages); } } } } return(result ?? SpecializedCollections.EmptyEnumerable <string>()); }
private static IEnumerable <string> 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)); }
private static IEnumerable <string> GetSupportedLanguages(TypeDefinition typeDef, PEModule peModule, Type attributeType, AttributeLanguagesFunc languagesFunc) { foreach (CustomAttributeHandle customAttrHandle in typeDef.GetCustomAttributes()) { if (peModule.IsTargetAttribute(customAttrHandle, attributeType.Namespace !, attributeType.Name, ctor: out _)) { IEnumerable <string>?attributeSupportedLanguages = languagesFunc(peModule, customAttrHandle); if (attributeSupportedLanguages != null) { foreach (string item in attributeSupportedLanguages) { yield return(item); } } } } }
private static bool IsDiagnosticAnalyzerAttribute(PEModule peModule, CustomAttributeHandle customAttrHandle) { return(peModule.IsTargetAttribute(customAttrHandle, s_diagnosticAnalyzerAttributeNamespace, nameof(DiagnosticAnalyzerAttribute), out EntityHandle ctor)); }
private static bool IsGeneratorAttribute(PEModule peModule, CustomAttributeHandle customAttrHandle) { return(peModule.IsTargetAttribute(customAttrHandle, s_generatorAttributeNamespace, nameof(GeneratorAttribute), ctor: out _)); }
private static bool IsSourceGeneratorAttribute(PEModule peModule, CustomAttributeHandle customAttrHandle) { EntityHandle ctor; return(peModule.IsTargetAttribute(customAttrHandle, s_sourceGeneratorAttributeNamespace, nameof(SourceGeneratorAttribute), out ctor)); }