Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Use PrecompilationTagHelperTypeResolver to locate TagHelpers during
Browse files Browse the repository at this point in the history
precompilation.

Fixes #2298
  • Loading branch information
pranavkm committed Sep 10, 2015
1 parent 894574d commit 2e32ffc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 112 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
using System.Runtime.Versioning;
using Microsoft.AspNet.FileProviders;
using Microsoft.Dnx.Compilation.CSharp;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Internal;

namespace Microsoft.AspNet.Mvc.Razor.Precompilation
Expand All @@ -18,20 +16,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Precompilation
/// </summary>
public abstract class RazorPreCompileModule : ICompileModule
{
private readonly IAssemblyLoadContext _loadContext;
private readonly object _memoryCacheLookupLock = new object();
private readonly Dictionary<PrecompilationCacheKey, MemoryCache> _memoryCacheLookup =
new Dictionary<PrecompilationCacheKey, MemoryCache>();

/// <summary>
/// Instantiates a new <see cref="RazorPreCompileModule"/> instance.
/// </summary>
/// <param name="services">The <see cref="IServiceProvider"/> for the application.</param>
public RazorPreCompileModule(IServiceProvider services)
{
_loadContext = services.GetRequiredService<IAssemblyLoadContext>();
}

/// <summary>
/// Gets or sets a value that determines if symbols (.pdb) file for the precompiled views is generated.
/// </summary>
Expand Down Expand Up @@ -65,7 +53,6 @@ public virtual void BeforeCompile(BeforeCompileContext context)

var viewCompiler = new RazorPreCompiler(
context,
_loadContext,
fileProvider,
memoryCache)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Mvc.Internal;
using Microsoft.AspNet.Mvc.Razor.Compilation;
using Microsoft.AspNet.Mvc.Razor.Directives;
using Microsoft.AspNet.Mvc.Razor.Internal;
using Microsoft.AspNet.Razor.Runtime.Precompilation;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Dnx.Compilation;
using Microsoft.Dnx.Compilation.CSharp;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.Internal;

Expand All @@ -27,22 +27,22 @@ public class RazorPreCompiler
{
public RazorPreCompiler(
[NotNull] BeforeCompileContext compileContext,
[NotNull] IAssemblyLoadContext loadContext,
[NotNull] IFileProvider fileProvider,
[NotNull] IMemoryCache precompilationCache)
{
CompileContext = compileContext;
LoadContext = loadContext;
FileProvider = fileProvider;
// There should always be a syntax tree even if there are no files (we generate one)
Debug.Assert(compileContext.Compilation.SyntaxTrees.Length > 0);
var defines = compileContext.Compilation.SyntaxTrees[0].Options.PreprocessorSymbolNames;
CompilationSettings = new CompilationSettings
{
CompilationOptions = compileContext.Compilation.Options,
// REVIEW: There should always be a syntax tree even if there are no files (we generate one)
Defines = compileContext.Compilation.SyntaxTrees[0].Options.PreprocessorSymbolNames,
Defines = defines,
LanguageVersion = compileContext.Compilation.LanguageVersion
};
PreCompilationCache = precompilationCache;
TagHelperTypeResolver = new PrecompilationTagHelperTypeResolver(CompileContext, LoadContext);
TagHelperTypeResolver = new PrecompilationTagHelperTypeResolver(CompileContext.Compilation);
}

/// <summary>
Expand All @@ -54,8 +54,6 @@ public RazorPreCompiler(

protected BeforeCompileContext CompileContext { get; }

protected IAssemblyLoadContext LoadContext { get; }

protected CompilationSettings CompilationSettings { get; }

protected IMemoryCache PreCompilationCache { get; }
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.AspNet.Mvc.Razor/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"Microsoft.AspNet.Mvc.Razor.Host": "6.0.0-*",
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-*",
"Microsoft.AspNet.Razor.Runtime.Precompilation": "4.0.0-*",
"Microsoft.AspNet.PageExecutionInstrumentation.Interfaces": "1.0.0-*",
"Microsoft.Framework.HashCodeCombiner.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ namespace PrecompilationWebSite
{
public class RazorPreCompilation : RazorPreCompileModule
{
public RazorPreCompilation(IServiceProvider provider)
: base(provider)
public RazorPreCompilation()
{
}
}
Expand Down

0 comments on commit 2e32ffc

Please sign in to comment.