public TestRazorCompilationService( ICompilationService compilationService, IMvcRazorHost razorHost, IOptions<RazorViewEngineOptions> viewEngineOptions) : base(compilationService, razorHost, viewEngineOptions) { }
public TestRazorCompilationService( ICompilationService compilationService, IMvcRazorHost razorHost, IOptions <RazorViewEngineOptions> viewEngineOptions) : base(compilationService, razorHost, viewEngineOptions) { }
public RazorCompilationServiceSpy(ICompilationService compilationService, IMvcRazorHost razorHost, IOptions <RazorViewEngineOptions> options) { _inner = new RazorCompilationService(compilationService, razorHost, options); _log = new List <CompileEntry>(); }
public TestRazorCompilationService( ICompilationService compilationService, IMvcRazorHost razorHost, IRazorViewEngineFileProviderAccessor fileProviderAccessor, ILoggerFactory loggerFactory) : base(compilationService, razorHost, fileProviderAccessor, loggerFactory) { }
public RazorCompilationService(ICompilationService compilationService, IMvcRazorHost razorHost, IOptions <RazorViewEngineOptions> viewEngineOptions) { _compilationService = compilationService; _razorHost = razorHost; _fileProvider = viewEngineOptions.Options.FileProvider; }
public RazorCompilationServiceSpy(ICompilationService compilationService, IMvcRazorHost razorHost, IRazorViewEngineFileProviderAccessor fileProviderAccessor, ILoggerFactory logger) { _inner = new RazorCompilationService(compilationService, razorHost, fileProviderAccessor, logger); _log = new List <CompileEntry>(); }
public RazorCompilationService(ICompilationService compilationService, IMvcRazorHost razorHost, IOptions<RazorViewEngineOptions> viewEngineOptions) { _compilationService = compilationService; _razorHost = razorHost; _fileProvider = viewEngineOptions.Options.FileProvider; }
public RazorCompilationService(IApplicationEnvironment environment, ICompilationService compilationService, IMvcRazorHost razorHost) { _environment = environment; _baseCompilationService = compilationService; _razorHost = razorHost; _appRoot = EnsureTrailingSlash(environment.ApplicationBasePath); }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="loaderEngine">The loader used to load compiled assemblies.</param> /// <param name="libraryManager">The library manager that provides export and reference information.</param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> public RoslynCompilationService(IApplicationEnvironment environment, IAssemblyLoadContextAccessor loaderAccessor, ILibraryManager libraryManager, IMvcRazorHost host) { _environment = environment; _loader = loaderAccessor.GetLoadContext(typeof(RoslynCompilationService).GetTypeInfo().Assembly); _libraryManager = libraryManager; _applicationReferences = new Lazy <List <MetadataReference> >(GetApplicationReferences); _classPrefix = host.MainClassNamePrefix; }
/// <summary> /// Instantiates a new instance of the <see cref="RazorCompilationService"/> class. /// </summary> /// <param name="compilationService">The <see cref="ICompilationService"/> to compile generated code.</param> /// <param name="razorHost">The <see cref="IMvcRazorHost"/> to generate code from Razor files.</param> /// <param name="fileProviderAccessor">The <see cref="IRazorViewEngineFileProviderAccessor"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> public RazorCompilationService( ICompilationService compilationService, IMvcRazorHost razorHost, IRazorViewEngineFileProviderAccessor fileProviderAccessor, ILoggerFactory loggerFactory) { _compilationService = compilationService; _razorHost = razorHost; _fileProvider = fileProviderAccessor.FileProvider; _logger = loggerFactory.CreateLogger<RazorCompilationService>(); }
/// <summary> /// Instantiates a new instance of the <see cref="RazorCompilationService"/> class. /// </summary> /// <param name="compilationService">The <see cref="ICompilationService"/> to compile generated code.</param> /// <param name="razorHost">The <see cref="IMvcRazorHost"/> to generate code from Razor files.</param> /// <param name="fileProviderAccessor">The <see cref="IRazorViewEngineFileProviderAccessor"/>.</param> public RazorCompilationService( ICompilationService compilationService, IMvcRazorHost razorHost, IRazorViewEngineFileProviderAccessor fileProviderAccessor, ILoggerFactory loggerFactory) { _compilationService = compilationService; _razorHost = razorHost; _fileProvider = fileProviderAccessor.FileProvider; _logger = loggerFactory.CreateLogger <RazorCompilationService>(); }
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider, [NotNull] IMvcRazorHost host, [NotNull] IOptions <RazorViewEngineOptions> optionsAccessor) { _serviceProvider = designTimeServiceProvider; _host = host; var appEnv = _serviceProvider.GetRequiredService <IApplicationEnvironment>(); _fileSystem = optionsAccessor.Options.FileSystem; }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="loaderEngine">The loader used to load compiled assemblies.</param> /// <param name="libraryManager">The library manager that provides export and reference information.</param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> public RoslynCompilationService(IApplicationEnvironment environment, IAssemblyLoadContextAccessor loaderAccessor, ILibraryManager libraryManager, ICompilerOptionsProvider compilerOptionsProvider, IMvcRazorHost host) { _environment = environment; _loader = loaderAccessor.GetLoadContext(typeof(RoslynCompilationService).GetTypeInfo().Assembly); _libraryManager = libraryManager; _applicationReferences = new Lazy<List<MetadataReference>>(GetApplicationReferences); _compilerOptionsProvider = compilerOptionsProvider; _classPrefix = host.MainClassNamePrefix; }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="loaderAccessor"> /// The accessor for the <see cref="IAssemblyLoadContext"/> used to load compiled assemblies. /// </param> /// <param name="libraryExporter">The library manager that provides export and reference information.</param> /// <param name="compilerOptionsProvider"> /// The <see cref="ICompilerOptionsProvider"/> that provides Roslyn compilation settings. /// </param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> public DefaultRoslynCompilationService(IApplicationEnvironment environment, IAssemblyLoadContextAccessor loaderAccessor, IOrchardLibraryManager libraryExporter, ICompilerOptionsProvider compilerOptionsProvider, IMvcRazorHost host, IOptions<RazorViewEngineOptions> optionsAccessor) { _environment = environment; _loader = loaderAccessor.GetLoadContext(typeof(DefaultRoslynCompilationService).GetTypeInfo().Assembly); _libraryExporter = libraryExporter; _applicationReferences = new Lazy<List<MetadataReference>>(GetApplicationReferences); _compilerOptionsProvider = compilerOptionsProvider; _fileProvider = optionsAccessor.Options.FileProvider; _classPrefix = host.MainClassNamePrefix; }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="loaderAccessor"> /// The accessor for the <see cref="IAssemblyLoadContext"/> used to load compiled assemblies. /// </param> /// <param name="libraryExporter">The library manager that provides export and reference information.</param> /// <param name="compilerOptionsProvider"> /// The <see cref="ICompilerOptionsProvider"/> that provides Roslyn compilation settings. /// </param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> public DefaultRoslynCompilationService(IApplicationEnvironment environment, IAssemblyLoadContextAccessor loaderAccessor, IOrchardLibraryManager libraryExporter, ICompilerOptionsProvider compilerOptionsProvider, IMvcRazorHost host, IOptions <RazorViewEngineOptions> optionsAccessor) { _environment = environment; _loader = loaderAccessor.GetLoadContext(typeof(DefaultRoslynCompilationService).GetTypeInfo().Assembly); _libraryExporter = libraryExporter; _applicationReferences = new Lazy <List <MetadataReference> >(GetApplicationReferences); _compilerOptionsProvider = compilerOptionsProvider; _fileProvider = optionsAccessor.Options.FileProvider; _classPrefix = host.MainClassNamePrefix; }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="loaderAccessor"> /// The accessor for the <see cref="IAssemblyLoadContext"/> used to load compiled assemblies. /// </param> /// <param name="libraryManager">The library manager that provides export and reference information.</param> /// <param name="compilerOptionsProvider"> /// The <see cref="ICompilerOptionsProvider"/> that provides Roslyn compilation settings. /// </param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> public RoslynCompilationService( IApplicationEnvironment environment, ILibraryExporter libraryExporter, ICompilerOptionsProvider compilerOptionsProvider, IMvcRazorHost host, IOptions <RazorViewEngineOptions> optionsAccessor) { _environment = environment; _libraryExporter = libraryExporter; _applicationReferences = new Lazy <List <MetadataReference> >(GetApplicationReferences); _compilerOptionsProvider = compilerOptionsProvider; _fileProvider = optionsAccessor.Value.FileProvider; _classPrefix = host.MainClassNamePrefix; #if DOTNET5_4 _razorLoadContext = new RazorLoadContext(); #endif }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="loaderAccessor"> /// The accessor for the <see cref="IAssemblyLoadContext"/> used to load compiled assemblies. /// </param> /// <param name="libraryManager">The library manager that provides export and reference information.</param> /// <param name="compilerOptionsProvider"> /// The <see cref="ICompilerOptionsProvider"/> that provides Roslyn compilation settings. /// </param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> public RoslynCompilationService( IApplicationEnvironment environment, ILibraryExporter libraryExporter, ICompilerOptionsProvider compilerOptionsProvider, IMvcRazorHost host, IOptions<RazorViewEngineOptions> optionsAccessor) { _environment = environment; _libraryExporter = libraryExporter; _applicationReferences = new Lazy<List<MetadataReference>>(GetApplicationReferences); _compilerOptionsProvider = compilerOptionsProvider; _fileProvider = optionsAccessor.Value.FileProvider; _classPrefix = host.MainClassNamePrefix; #if DOTNET5_4 _razorLoadContext = new RazorLoadContext(); #endif }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="libraryExporter">The library manager that provides export and reference information.</param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> /// <param name="optionsAccessor">Accessor to <see cref="RazorViewEngineOptions"/>.</param> /// <param name="fileProviderAccessor">The <see cref="IRazorViewEngineFileProviderAccessor"/>.</param> public RoslynCompilationService( IApplicationEnvironment environment, Extensions.CompilationAbstractions.ILibraryExporter libraryExporter, IMvcRazorHost host, IOptions <RazorViewEngineOptions> optionsAccessor, IRazorViewEngineFileProviderAccessor fileProviderAccessor, ILoggerFactory loggerFactory) { _environment = environment; _libraryExporter = libraryExporter; _applicationReferences = new Lazy <List <MetadataReference> >(GetApplicationReferences); _fileProvider = fileProviderAccessor.FileProvider; _classPrefix = host.MainClassNamePrefix; _compilationCallback = optionsAccessor.Value.CompilationCallback; _parseOptions = optionsAccessor.Value.ParseOptions; _compilationOptions = optionsAccessor.Value.CompilationOptions; _logger = loggerFactory.CreateLogger <RoslynCompilationService>(); #if DOTNET5_5 _razorLoadContext = new RazorLoadContext(); #endif }
public static string GetMainClassName( this GeneratorResults results, IMvcRazorHost host, SyntaxTree syntaxTree) { if (results == null) { throw new ArgumentNullException(nameof(results)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (syntaxTree == null) { throw new ArgumentNullException(nameof(syntaxTree)); } // The mainClass name should return directly from the generator results. var classes = syntaxTree.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>(); var mainClass = classes.FirstOrDefault(c => c.Identifier.ValueText.StartsWith(host.MainClassNamePrefix, StringComparison.Ordinal)); if (mainClass != null) { var typeName = mainClass.Identifier.ValueText; if (!string.IsNullOrEmpty(host.DefaultNamespace)) { typeName = host.DefaultNamespace + "." + typeName; } return typeName; } return null; }
public static string GetMainClassName( this GeneratorResults results, IMvcRazorHost host, SyntaxTree syntaxTree) { if (results == null) { throw new ArgumentNullException(nameof(results)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (syntaxTree == null) { throw new ArgumentNullException(nameof(syntaxTree)); } // The mainClass name should return directly from the generator results. var classes = syntaxTree.GetRoot().DescendantNodes().OfType <ClassDeclarationSyntax>(); var mainClass = classes.FirstOrDefault(c => c.Identifier.ValueText.StartsWith(host.MainClassNamePrefix, StringComparison.Ordinal)); if (mainClass != null) { var typeName = mainClass.Identifier.ValueText; if (!string.IsNullOrEmpty(host.DefaultNamespace)) { typeName = host.DefaultNamespace + "." + typeName; } return(typeName); } return(null); }
/// <summary> /// Initalizes a new instance of the <see cref="RoslynCompilationService"/> class. /// </summary> /// <param name="environment">The environment for the executing application.</param> /// <param name="libraryExporter">The library manager that provides export and reference information.</param> /// <param name="host">The <see cref="IMvcRazorHost"/> that was used to generate the code.</param> /// <param name="optionsAccessor">Accessor to <see cref="RazorViewEngineOptions"/>.</param> /// <param name="fileProviderAccessor">The <see cref="IRazorViewEngineFileProviderAccessor"/>.</param> public RoslynCompilationService( IApplicationEnvironment environment, Extensions.CompilationAbstractions.ILibraryExporter libraryExporter, IMvcRazorHost host, IOptions<RazorViewEngineOptions> optionsAccessor, IRazorViewEngineFileProviderAccessor fileProviderAccessor, ILoggerFactory loggerFactory) { _environment = environment; _libraryExporter = libraryExporter; _applicationReferences = new Lazy<List<MetadataReference>>(GetApplicationReferences); _fileProvider = fileProviderAccessor.FileProvider; _classPrefix = host.MainClassNamePrefix; _compilationCallback = optionsAccessor.Value.CompilationCallback; _parseOptions = optionsAccessor.Value.ParseOptions; _compilationOptions = optionsAccessor.Value.CompilationOptions; _logger = loggerFactory.CreateLogger<RoslynCompilationService>(); #if DOTNET5_5 _razorLoadContext = new RazorLoadContext(); #endif }
/// <summary> /// Instantiates a new instance of the <see cref="RazorCompilationService"/> class. /// </summary> /// <param name="compilationService">The <see cref="ICompilationService"/> to compile generated code.</param> /// <param name="razorHost">The <see cref="IMvcRazorHost"/> to generate code from Razor files.</param> /// <param name="viewEngineOptions"> /// The <see cref="IFileProvider"/> to read Razor files referenced in error messages. /// </param> public RazorCompilationService(IExecutionContext executionContext, Type basePageType) { _executionContext = executionContext; _razorHost = new MvcRazorHost(executionContext, basePageType); }
public RazorCompilationService(ICompilationService compilationService, IMvcRazorHost razorHost) { _compilationService = compilationService; _razorHost = razorHost; }