private static TestRazorViewCompiler GetViewCompiler( TestFileProvider fileProvider = null, RazorReferenceManager referenceManager = null, IList <CompiledViewDescriptor> precompiledViews = null, CSharpCompiler csharpCompiler = null) { fileProvider = fileProvider ?? new TestFileProvider(); var options = Options.Create(new MvcRazorRuntimeCompilationOptions { FileProviders = { fileProvider } }); var compilationFileProvider = new RuntimeCompilationFileProvider(options); referenceManager = referenceManager ?? CreateReferenceManager(); precompiledViews = precompiledViews ?? Array.Empty <CompiledViewDescriptor>(); var hostingEnvironment = Mock.Of <IWebHostEnvironment>(e => e.ContentRootPath == "BasePath"); var fileSystem = new FileProviderRazorProjectFileSystem(compilationFileProvider, hostingEnvironment); var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { RazorExtensions.Register(builder); }); csharpCompiler = csharpCompiler ?? new CSharpCompiler(referenceManager, hostingEnvironment); return(new TestRazorViewCompiler( fileProvider, projectEngine, csharpCompiler, precompiledViews)); }
public void GetCompilationReferences_CombinesApplicationPartAndOptionMetadataReferences() { // Arrange var options = new RazorViewEngineOptions(); var objectAssemblyLocation = typeof(object).GetTypeInfo().Assembly.Location; var objectAssemblyMetadataReference = MetadataReference.CreateFromFile(objectAssemblyLocation); options.AdditionalCompilationReferences.Add(objectAssemblyMetadataReference); var applicationPartManager = GetApplicationPartManager(); var feature = new MetadataReferenceFeature(); applicationPartManager.PopulateFeature(feature); var partReferences = feature.MetadataReferences; var expectedReferenceDisplays = partReferences .Concat(new[] { objectAssemblyMetadataReference }) .Select(r => r.Display); var referenceManager = new RazorReferenceManager(applicationPartManager, GetAccessor(options)); // Act var references = referenceManager.CompilationReferences; var referenceDisplays = references.Select(reference => reference.Display); // Assert Assert.Equal(expectedReferenceDisplays, referenceDisplays); }
public TestCSharpCompiler( RazorReferenceManager referenceManager, IWebHostEnvironment hostingEnvironment, DependencyContextCompilationOptions options) : base(referenceManager, hostingEnvironment) { _options = options; }
public SxcOqtane(OqtAssetsAndHeaders assetsAndHeaders, RazorReferenceManager debugRefMan, OqtTempInstanceContext oqtTempInstanceContext, IServiceProvider serviceProvider ) : base($"{OqtConstants.OqtLogPrefix}.Buildr") { _assetsAndHeaders = assetsAndHeaders; _debugRefMan = debugRefMan; _oqtTempInstanceContext = oqtTempInstanceContext; _serviceProvider = serviceProvider; // add log to history! History.Add("oqt-view", Log); }
public void GetCompilationReferences_CombinesApplicationPartAndOptionMetadataReferences() { // Arrange var options = new MvcRazorRuntimeCompilationOptions(); var additionalReferencePath = "additional-path"; options.AdditionalReferencePaths.Add(additionalReferencePath); var applicationPartManager = GetApplicationPartManager(); var referenceManager = new RazorReferenceManager( applicationPartManager, Options.Create(options)); var expected = new[] { ApplicationPartReferencePath, additionalReferencePath }; // Act var references = referenceManager.GetReferencePaths(); // Assert Assert.Equal(expected, references); }
public FeatureCompiler(RazorReferenceManager referenceManager, FeatureRuntimeCompilationOptions options) { _referenceManager = referenceManager; _options = options; }
public TestCSharpCompiler(RazorReferenceManager manager, IWebHostEnvironment hostingEnvironment) : base(manager, hostingEnvironment) { }
public LazyMetadataReferenceFeature(RazorReferenceManager referenceManager) { _referenceManager = referenceManager; }
#pragma warning restore CS0618 // Type or member is obsolete #pragma warning disable CS0618 // Type or member is obsolete public LazyMetadataReferenceFeature(RazorReferenceManager referenceManager) #pragma warning restore CS0618 // Type or member is obsolete { _referenceManager = referenceManager; }