private static RazorProjectEngine GetDiscoveryProjectEngine( IReadOnlyList <MetadataReference> references, StaticCompilationTagHelperFeature tagHelperFeature) { var discoveryProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, new VirtualRazorProjectFileSystem(), b => { b.Features.Add(new DefaultMetadataReferenceFeature { References = references }); b.Features.Add(tagHelperFeature); b.Features.Add(new DefaultTagHelperDescriptorProvider()); CompilerFeatures.Register(b); RazorExtensions.Register(b); }); return(discoveryProjectEngine); }
private static IReadOnlyList <TagHelperDescriptor> GetTagHelpersFromCompilation(Compilation compilation, StaticCompilationTagHelperFeature tagHelperFeature, SyntaxTree syntaxTrees) { var compilationWithDeclarations = compilation.AddSyntaxTrees(syntaxTrees); tagHelperFeature.Compilation = compilationWithDeclarations; tagHelperFeature.TargetAssembly = compilationWithDeclarations.Assembly; return(tagHelperFeature.GetDescriptors()); }
private IReadOnlyList <TagHelperDescriptor> GetTagHelpers(IEnumerable <MetadataReference> references, StaticCompilationTagHelperFeature tagHelperFeature, Compilation compilation) { List <TagHelperDescriptor> descriptors = new(); tagHelperFeature.Compilation = compilation; foreach (var reference in references) { if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) { tagHelperFeature.TargetAssembly = assembly; descriptors.AddRange(tagHelperFeature.GetDescriptors()); } } return(descriptors); }