/// <summary>
        /// Initalizes a new instance of the <see cref="DnxRoslynCompilationService"/> 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="optionsAccessor">Accessor to <see cref="RazorViewEngineOptions"/>.</param>
        /// <param name="fileProviderAccessor">The <see cref="IRazorViewEngineFileProviderAccessor"/>.</param>
        public DnxRoslynCompilationService(
            IHostingEnvironment environment,
            ILibraryExporter libraryExporter,
            IOptions <RazorViewEngineOptions> optionsAccessor,
            IRazorViewEngineFileProviderAccessor fileProviderAccessor)
        {
            _environment           = environment;
            _libraryExporter       = libraryExporter;
            _options               = optionsAccessor.Value;
            _applicationReferences = new Lazy <List <MetadataReference> >(GetApplicationReferences);

#if NETSTANDARD1_5
            _razorLoadContext = new RazorLoadContext();
#endif
        }
Beispiel #2
0
        // Internal for unit testing
        internal DefaultRoslynCompilationService(
            DependencyContext dependencyContext,
            RazorViewEngineOptions viewEngineOptions,
            IRazorViewEngineFileProviderAccessor fileProviderAccessor,
            ILoggerFactory loggerFactory)
        {
            _dependencyContext     = dependencyContext;
            _applicationReferences = new Lazy <List <MetadataReference> >(GetApplicationReferences);
            _fileProvider          = fileProviderAccessor.FileProvider;
            _compilationCallback   = viewEngineOptions.CompilationCallback;
            _parseOptions          = viewEngineOptions.ParseOptions;
            _compilationOptions    = viewEngineOptions.CompilationOptions;
            _logger = loggerFactory.CreateLogger <DefaultRoslynCompilationService>();

#if NETSTANDARD1_5
            _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
        }
        // Internal for unit testing
        internal DefaultRoslynCompilationService(
            DependencyContext dependencyContext,
            RazorViewEngineOptions viewEngineOptions,
            IRazorViewEngineFileProviderAccessor fileProviderAccessor,
            ILoggerFactory loggerFactory)
        {
            _dependencyContext = dependencyContext;
            _applicationReferences = new Lazy<List<MetadataReference>>(GetApplicationReferences);
            _fileProvider = fileProviderAccessor.FileProvider;
            _compilationCallback = viewEngineOptions.CompilationCallback;
            _parseOptions = viewEngineOptions.ParseOptions;
            _compilationOptions = viewEngineOptions.CompilationOptions;
            _logger = loggerFactory.CreateLogger<DefaultRoslynCompilationService>();

#if NETSTANDARD1_5
            _razorLoadContext = new RazorLoadContext();
#endif
        }
Beispiel #5
0
        /// <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
        }
Beispiel #7
0
        /// <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
        }