public void Execute(TagHelperDescriptorProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var compilation = context.GetCompilation(); if (compilation == null) { // No compilation, nothing to do. return; } var iTagHelper = compilation.GetTypeByMetadataName(TagHelperTypes.ITagHelper); if (iTagHelper == null || iTagHelper.TypeKind == TypeKind.Error) { // Could not find attributes we care about in the compilation. Nothing to do. return; } var types = new List <INamedTypeSymbol>(); var visitor = new TagHelperTypeVisitor(iTagHelper, types); var targetAssembly = context.Items.GetTargetAssembly(); if (targetAssembly is not null) { visitor.Visit(targetAssembly.GlobalNamespace); } else { visitor.Visit(compilation.Assembly.GlobalNamespace); foreach (var reference in compilation.References) { if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) { if (IsTagHelperAssembly(assembly)) { visitor.Visit(assembly.GlobalNamespace); } } } } var factory = new DefaultTagHelperDescriptorFactory(compilation, context.IncludeDocumentation, context.ExcludeHidden); for (var i = 0; i < types.Count; i++) { var descriptor = factory.CreateDescriptor(types[i]); if (descriptor != null) { context.Results.Add(descriptor); } } }
public void Execute(TagHelperDescriptorProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var compilation = context.GetCompilation(); if (compilation == null) { // No compilation, nothing to do. return; } var types = new List <INamedTypeSymbol>(); var visitor = TagHelperTypeVisitor.Create(compilation, types); // We always visit the global namespace. visitor.Visit(compilation.Assembly.GlobalNamespace); foreach (var reference in compilation.References) { if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) { if (IsTagHelperAssembly(assembly)) { visitor.Visit(assembly.GlobalNamespace); } } } var factory = new DefaultTagHelperDescriptorFactory(compilation, context.IncludeDocumentation, context.ExcludeHidden); for (var i = 0; i < types.Count; i++) { var descriptor = factory.CreateDescriptor(types[i]); if (descriptor != null) { context.Results.Add(descriptor); } } }