diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProject.cs b/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProject.cs
index bf51f43d02..d192313e54 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProject.cs
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProject.cs
@@ -8,15 +8,8 @@ using System.Linq;
namespace Microsoft.AspNetCore.Razor.Evolution
{
- ///
- /// A implementation over the physical file system.
- ///
- public class FileSystemRazorProject : RazorProject
+ internal class FileSystemRazorProject : RazorProject
{
- ///
- /// Initializes a new instance of .
- ///
- /// The directory to root the file system at.
public FileSystemRazorProject(string root)
{
if (string.IsNullOrEmpty(root))
@@ -27,12 +20,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Root = root.Replace('\\', '/').TrimEnd('/');
}
- ///
- /// The root of the file system.
- ///
public string Root { get; }
- ///
public override IEnumerable EnumerateItems(string basePath)
{
var absoluteBasePath = NormalizeAndEnsureValidPath(basePath);
@@ -52,7 +41,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution
});
}
- ///
public override RazorProjectItem GetItem(string path)
{
var absolutePath = NormalizeAndEnsureValidPath(path);
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProjectItem.cs b/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProjectItem.cs
index f8a79016e1..d20c38f6d8 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProjectItem.cs
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/FileSystemRazorProjectItem.cs
@@ -5,10 +5,7 @@ using System.IO;
namespace Microsoft.AspNetCore.Razor.Evolution
{
- ///
- /// An implementation of using .
- ///
- public class FileSystemRazorProjectItem : RazorProjectItem
+ internal class FileSystemRazorProjectItem : RazorProjectItem
{
///
/// Initializes a new instance of .
@@ -23,27 +20,18 @@ namespace Microsoft.AspNetCore.Razor.Evolution
File = file;
}
- ///
- /// Gets the .
- ///
public FileInfo File { get; }
- ///
public override string BasePath { get; }
- ///
public override string Path { get; }
- ///
public override bool Exists => File.Exists;
- ///
public override string FileName => File.Name;
- ///
public override string PhysicalPath => File.FullName;
- ///
public override Stream Read() => File.OpenRead();
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/RazorProject.cs b/src/Microsoft.AspNetCore.Razor.Evolution/RazorProject.cs
index dbda49932f..abb7564128 100644
--- a/src/Microsoft.AspNetCore.Razor.Evolution/RazorProject.cs
+++ b/src/Microsoft.AspNetCore.Razor.Evolution/RazorProject.cs
@@ -123,5 +123,15 @@ namespace Microsoft.AspNetCore.Razor.Evolution
return path;
}
+
+ ///
+ /// Create a Razor project based on a physical file system.
+ ///
+ /// The directory to root the file system at.
+ /// A
+ public static RazorProject Create(string rootDirectoryPath)
+ {
+ return new FileSystemRazorProject(rootDirectoryPath);
+ }
}
}
diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorTemplateEngineFactoryService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorTemplateEngineFactoryService.cs
index f24dc2f1c6..1991d6f2d5 100644
--- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorTemplateEngineFactoryService.cs
+++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorTemplateEngineFactoryService.cs
@@ -26,7 +26,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
RazorExtensions.Register(b);
});
- var templateEngine = new MvcRazorTemplateEngine(engine, new FileSystemRazorProject(projectPath));
+ var templateEngine = new MvcRazorTemplateEngine(engine, RazorProject.Create(projectPath));
templateEngine.Options.ImportsFileName = "_ViewImports.cshtml";
return templateEngine;
}
diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs
index 75bb90ccfb..8860fca6bd 100644
--- a/src/RazorPageGenerator/Program.cs
+++ b/src/RazorPageGenerator/Program.cs
@@ -55,7 +55,7 @@ namespace RazorPageGenerator
});
var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories);
- var razorProject = new FileSystemRazorProject(targetProjectDirectory);
+ var razorProject = RazorProject.Create(targetProjectDirectory);
var templateEngine = new RazorTemplateEngine(razorEngine, razorProject);
var fileCount = 0;
@@ -66,7 +66,7 @@ namespace RazorPageGenerator
Console.WriteLine();
Console.WriteLine(" Generating code files for views in {0}", viewDir);
var viewDirPath = viewDir.Substring(targetProjectDirectory.Length).Replace('\\', '/');
- var cshtmlFiles = razorProject.EnumerateItems(viewDirPath).Cast();
+ var cshtmlFiles = razorProject.EnumerateItems(viewDirPath);
if (!cshtmlFiles.Any())
{
@@ -86,7 +86,7 @@ namespace RazorPageGenerator
return results;
}
- private static RazorPageGeneratorResult GenerateCodeFile(RazorTemplateEngine templateEngine, FileSystemRazorProjectItem projectItem)
+ private static RazorPageGeneratorResult GenerateCodeFile(RazorTemplateEngine templateEngine, RazorProjectItem projectItem)
{
var projectItemWrapper = new FileSystemRazorProjectItemWrapper(projectItem);
var cSharpDocument = templateEngine.GenerateCode(projectItemWrapper);
@@ -106,9 +106,9 @@ namespace RazorPageGenerator
private class FileSystemRazorProjectItemWrapper : RazorProjectItem
{
- private readonly FileSystemRazorProjectItem _source;
+ private readonly RazorProjectItem _source;
- public FileSystemRazorProjectItemWrapper(FileSystemRazorProjectItem item)
+ public FileSystemRazorProjectItemWrapper(RazorProjectItem item)
{
_source = item;
}
@@ -130,7 +130,7 @@ namespace RazorPageGenerator
private string ProcessFileIncludes()
{
- var basePath = _source.File.DirectoryName;
+ var basePath = System.IO.Path.GetDirectoryName(_source.PhysicalPath);
var cshtmlContent = File.ReadAllText(_source.PhysicalPath);
var startMatch = "<%$ include: ";