Transition root paths => relative for tooling.

#2213
This commit is contained in:
N. Taylor Mullen 2015-03-19 17:41:22 -07:00
parent 9a6f8b392d
commit 0f1292abf6
1 changed files with 16 additions and 0 deletions

View File

@ -51,6 +51,7 @@ namespace Microsoft.AspNet.Mvc.Razor
public MvcRazorHost(string root) :
this(new DefaultCodeTreeCache(new PhysicalFileProvider(root)))
{
ApplicationRoot = root;
}
#endif
/// <summary>
@ -112,6 +113,13 @@ namespace Microsoft.AspNet.Mvc.Razor
}
}
#if NET45
/// <summary>
/// The path to the application root.
/// </summary>
public string ApplicationRoot { get; }
#endif
/// <summary>
/// Gets the model type used by default when no model is specified.
/// </summary>
@ -186,6 +194,14 @@ namespace Microsoft.AspNet.Mvc.Razor
/// <inheritdoc />
public override RazorParser DecorateRazorParser([NotNull] RazorParser razorParser, string sourceFileName)
{
#if NET45
// Need to convert sourceFileName to application relative (rooted paths are passed in by tooling).
if (Path.IsPathRooted(sourceFileName))
{
sourceFileName = sourceFileName.Substring(ApplicationRoot.Length);
}
#endif
var inheritedCodeTrees = ChunkInheritanceUtility.GetInheritedCodeTrees(sourceFileName);
return new MvcRazorParser(razorParser, inheritedCodeTrees, DefaultInheritedChunks);
}