4
4
using System ;
5
5
using Microsoft . AspNet . FileProviders ;
6
6
using Microsoft . AspNet . Mvc . Razor . Precompilation ;
7
- using Microsoft . Dnx . Compilation ;
8
7
using Microsoft . Dnx . Compilation . CSharp ;
9
8
using Microsoft . Dnx . Runtime ;
10
9
using Microsoft . Framework . Caching . Memory ;
@@ -17,7 +16,7 @@ namespace Microsoft.AspNet.Mvc
17
16
/// </summary>
18
17
public abstract class RazorPreCompileModule : ICompileModule
19
18
{
20
- private readonly IServiceProvider _appServices ;
19
+ private readonly IAssemblyLoadContext _loadContext ;
21
20
private readonly IMemoryCache _memoryCache ;
22
21
23
22
/// <summary>
@@ -26,7 +25,7 @@ public abstract class RazorPreCompileModule : ICompileModule
26
25
/// <param name="services">The <see cref="IServiceProvider"/> for the application.</param>
27
26
public RazorPreCompileModule ( IServiceProvider services )
28
27
{
29
- _appServices = services ;
28
+ _loadContext = services . GetRequiredService < IAssemblyLoadContext > ( ) ;
30
29
31
30
// When CompactOnMemoryPressure is true, the MemoryCache evicts items at every gen2 collection.
32
31
// In DTH, gen2 happens frequently enough to make it undesirable for caching precompilation results. We'll
@@ -43,17 +42,13 @@ public RazorPreCompileModule(IServiceProvider services)
43
42
/// <remarks>Pre-compiles all Razor views in the application.</remarks>
44
43
public virtual void BeforeCompile ( BeforeCompileContext context )
45
44
{
46
- var compilerOptionsProvider = _appServices . GetRequiredService < ICompilerOptionsProvider > ( ) ;
47
- var loadContextAccessor = _appServices . GetRequiredService < IAssemblyLoadContextAccessor > ( ) ;
48
- var compilationSettings = GetCompilationSettings ( compilerOptionsProvider , context . ProjectContext ) ;
49
45
var fileProvider = new PhysicalFileProvider ( context . ProjectContext . ProjectDirectory ) ;
50
46
51
47
var viewCompiler = new RazorPreCompiler (
52
48
context ,
53
- loadContextAccessor ,
49
+ _loadContext ,
54
50
fileProvider ,
55
- _memoryCache ,
56
- compilationSettings )
51
+ _memoryCache )
57
52
{
58
53
GenerateSymbols = GenerateSymbols
59
54
} ;
@@ -65,15 +60,5 @@ public virtual void BeforeCompile(BeforeCompileContext context)
65
60
public void AfterCompile ( AfterCompileContext context )
66
61
{
67
62
}
68
-
69
- private static CompilationSettings GetCompilationSettings (
70
- ICompilerOptionsProvider compilerOptionsProvider ,
71
- ProjectContext projectContext )
72
- {
73
- return compilerOptionsProvider . GetCompilerOptions ( projectContext . Name ,
74
- projectContext . TargetFramework ,
75
- projectContext . Configuration )
76
- . ToCompilationSettings ( projectContext . TargetFramework ) ;
77
- }
78
63
}
79
64
}
0 commit comments