From 03dea86c4e4f4b19a3379f0c1b9f6ff40bd1edec Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 8 Jan 2018 20:56:43 -0800 Subject: [PATCH] Adding more tests and clarity around file paths I noticed we were really undertesting all of the things that handle paths and file names. I gave this some love and a little clean up where we weren't doing the right thing in RazorSourceDocument. Also changed the template engine tests to use the FileSystemRazorProject. These tests are already using the files on disk as inputs. I turned off checksums for these since they now have the full file path, and that would not be portable. --- .../RazorSourceDocument.cs | 9 +- .../FileSystemRazorProjectTest.cs | 82 ++++++++++++++++++- .../RazorTemplateEngineIntegrationTest.cs | 54 +++++------- .../RazorSourceDocumentTest.cs | 47 ++++++++++- .../RazorTemplateEngineTest.cs | 46 +++++++++++ .../Views/Home/_ViewImports.cshtml | 1 + .../Views/_ViewImports.cshtml | 1 + .../_ViewImports.cshtml | 1 + .../GenerateCodeWithBaseType.codegen.cs | 1 - .../GenerateCodeWithConfigureClass.codegen.cs | 1 - .../GenerateCodeWithDefaults.codegen.cs | 1 - .../GenerateCodeWithSetNamespace.codegen.cs | 1 - .../Language/TestRazorProjectItem.cs | 4 + 13 files changed, 208 insertions(+), 41 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/_ViewImports.cshtml create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/_ViewImports.cshtml create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/_ViewImports.cshtml diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs index c13c1974ca..ef0fabef5f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs @@ -183,13 +183,20 @@ namespace Microsoft.AspNetCore.Razor.Language if (string.IsNullOrEmpty(filePath)) { // Fall back to the relative path only if necessary. + filePath = projectItem.RelativePhysicalPath; + } + + if (string.IsNullOrEmpty(filePath)) + { + // Then fall back to the FilePath (yeah it's a bad name) which is like an MVC view engine path + // It's much better to have something than nothing. filePath = projectItem.FilePath; } using (var stream = projectItem.Read()) { // Autodetect the encoding. - return new StreamSourceDocument(stream, null, new RazorSourceDocumentProperties(filePath, projectItem.FilePath)); + return new StreamSourceDocument(stream, null, new RazorSourceDocumentProperties(filePath, projectItem.RelativePhysicalPath)); } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs index 35f8b32117..e2d471c8fd 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/FileSystemRazorProjectTest.cs @@ -76,7 +76,16 @@ namespace Microsoft.AspNetCore.Razor.Language var items = fileSystemProject.EnumerateItems("/"); // Assert - Assert.Collection(items.OrderBy(f => f.FilePath), + Assert.Collection( + items.OrderBy(f => f.FilePath), + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + + }, item => { Assert.Equal("/Home.cshtml", item.FilePath); @@ -84,6 +93,14 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(Path.Combine(TestFolder, "Home.cshtml"), item.PhysicalPath); Assert.Equal("Home.cshtml", item.RelativePhysicalPath); + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, item => { @@ -93,6 +110,14 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(Path.Combine("Views", "About", "About.cshtml"), item.RelativePhysicalPath); }, item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => { Assert.Equal("/Views/Home/Index.cshtml", item.FilePath); Assert.Equal("/", item.BasePath); @@ -111,7 +136,15 @@ namespace Microsoft.AspNetCore.Razor.Language var items = fileSystemProject.EnumerateItems("/Views"); // Assert - Assert.Collection(items.OrderBy(f => f.FilePath), + Assert.Collection( + items.OrderBy(f => f.FilePath), + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine( "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, item => { Assert.Equal("/About/About.cshtml", item.FilePath); @@ -120,6 +153,13 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(Path.Combine("About", "About.cshtml"), item.RelativePhysicalPath); }, item => + { + Assert.Equal("/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/Views", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + }, + item => { Assert.Equal("/Home/Index.cshtml", item.FilePath); Assert.Equal("/Views", item.BasePath); @@ -141,6 +181,44 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Empty(items); } + [Fact] + public void FindHierarchicalItems_FindsItemsWithMatchingNames() + { + // Arrange + var fileSystemProject = new FileSystemRazorProject(TestFolder); + + // Act + var items = fileSystemProject.FindHierarchicalItems("/Views/Home/Index.cshtml", "_ViewImports.cshtml"); + + // Assert + Assert.Collection( + items, + item => + { + Assert.Equal("/Views/Home/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "Home", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/Views/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "Views", "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePhysicalPath); + + }, + item => + { + Assert.Equal("/_ViewImports.cshtml", item.FilePath); + Assert.Equal("/", item.BasePath); + Assert.Equal(Path.Combine(TestFolder, "_ViewImports.cshtml"), item.PhysicalPath); + Assert.Equal("_ViewImports.cshtml", item.RelativePhysicalPath); + + }); + } + [Fact] public void GetItem_ReturnsFileFromDisk() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs index b5cd18e7ff..025ff5aa1f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs @@ -12,39 +12,35 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithDefaults() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") + var project = new FileSystemRazorProject(TestProjectRoot); + var razorEngine = RazorEngine.Create(engine => { - Content = content, - }; - var project = new TestRazorProject(new[]{ projectItem }); - var razorEngine = RazorEngine.Create(); + engine.Features.Add(new SuppressChecksumOptionsFeature()); + }); var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act - var resultcSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert - AssertCSharpDocumentMatchesBaseline(resultcSharpDocument); + AssertCSharpDocumentMatchesBaseline(cSharpDocument); } [Fact] public void GenerateCodeWithBaseType() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") + var project = new FileSystemRazorProject(TestProjectRoot); + var razorEngine = RazorEngine.Create(engine => { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); - var razorEngine = RazorEngine.Create(engine => engine.SetBaseType("MyBaseType")); + engine.Features.Add(new SuppressChecksumOptionsFeature()); + + engine.SetBaseType("MyBaseType"); + }); var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); @@ -54,15 +50,11 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithConfigureClass() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") - { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); + var project = new FileSystemRazorProject(TestProjectRoot); var razorEngine = RazorEngine.Create(engine => { + engine.Features.Add(new SuppressChecksumOptionsFeature()); + engine.ConfigureClass((document, @class) => { @class.ClassName = "MyClass"; @@ -81,7 +73,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); @@ -91,21 +83,17 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests public void GenerateCodeWithSetNamespace() { // Arrange - var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml"); - var content = File.ReadAllText(filePath); - var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "") - { - Content = content, - }; - var project = new TestRazorProject(new[] { projectItem }); + var project = new FileSystemRazorProject(TestProjectRoot); var razorEngine = RazorEngine.Create(engine => { + engine.Features.Add(new SuppressChecksumOptionsFeature()); + engine.SetNamespace("MyApp.Razor.Views"); }); var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act - var cSharpDocument = templateEngine.GenerateCode(projectItem.FilePath); + var cSharpDocument = templateEngine.GenerateCode($"{FileName}.cshtml"); // Assert AssertCSharpDocumentMatchesBaseline(cSharpDocument); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs index 18d68a8d44..fbae2747c2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Razor.Language public void ReadFrom_ProjectItem() { // Arrange - var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", "c:\\myapp\\"); + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", "filePath.cshtml", "c:\\myapp\\"); // Act var document = RazorSourceDocument.ReadFrom(projectItem); @@ -82,6 +82,51 @@ namespace Microsoft.AspNetCore.Razor.Language Assert.Equal(projectItem.Content, ReadContent(document)); } + [Fact] + public void ReadFrom_ProjectItem_NoRelativePath() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", "c:\\myapp\\filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("c:\\myapp\\filePath.cshtml", document.FilePath); + Assert.Null(document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToRelativePath() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", relativePhysicalPath: "filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Equal("filePath.cshtml", document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + + [Fact] + public void ReadFrom_ProjectItem_FallbackToFileName() + { + // Arrange + var projectItem = new TestRazorProjectItem("filePath.cshtml", basePath: "c:\\myapp\\"); + + // Act + var document = RazorSourceDocument.ReadFrom(projectItem); + + // Assert + Assert.Equal("filePath.cshtml", document.FilePath); + Assert.Null(document.RelativePath); + Assert.Equal(projectItem.Content, ReadContent(document)); + } + [Fact] public void Create_WithoutEncoding() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs index 453788d36c..5e757d9252 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs @@ -310,5 +310,51 @@ namespace Microsoft.AspNetCore.Razor.Language var paths = imports.Select(i => i.FilePath); Assert.Equal(expected, paths); } + + [Fact] + public void CreateCodeDocument_WithFileSystemProject_ReturnsCorrectItems() + { + // Arrange + var testFolder = Path.Combine( + TestProject.GetProjectDirectory(typeof(FileSystemRazorProjectTest)), + "TestFiles", + "FileSystemRazorProject"); + + var project = new FileSystemRazorProject(testFolder); + var razorEngine = RazorEngine.Create(); + var templateEngine = new RazorTemplateEngine(razorEngine, project) + { + Options = + { + ImportsFileName = "_ViewImports.cshtml" + } + }; + + // Act + var codeDocument = templateEngine.CreateCodeDocument("/Views/Home/Index.cshtml"); + + // Assert + Assert.Collection( + codeDocument.Imports, + item => + { + Assert.Equal(Path.Combine(testFolder, "_ViewImports.cshtml"), item.FilePath); + Assert.Equal("_ViewImports.cshtml", item.RelativePath); + + }, + item => + { + Assert.Equal(Path.Combine(testFolder, "Views", "_ViewImports.cshtml"), item.FilePath); + Assert.Equal(Path.Combine("Views", "_ViewImports.cshtml"), item.RelativePath); + + }, + item => + { + Assert.Equal(Path.Combine(testFolder, "Views", "Home", "_ViewImports.cshtml"), item.FilePath); + Assert.Equal(Path.Combine("Views", "Home", "_ViewImports.cshtml"), item.RelativePath); + + }); + } + } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/Home/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/Views/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/_ViewImports.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/_ViewImports.cshtml new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/FileSystemRazorProject/_ViewImports.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs index 65d4c88f80..38d08a7c75 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.codegen.cs @@ -1,4 +1,3 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithBaseType.cshtml")] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs index e5e3d8c3ef..2baca26a3f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.codegen.cs @@ -1,4 +1,3 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.MyClass), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithConfigureClass.cshtml")] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs index 569564df42..0ca4f5d061 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.codegen.cs @@ -1,4 +1,3 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Razor.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithDefaults.cshtml")] diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs index 66e6a60345..8cff2ae67f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.codegen.cs @@ -1,4 +1,3 @@ -#pragma checksum "TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "38aa8e26c5d2a85c61d8e93fe69dd326fe82671b" // #pragma warning disable 1591 [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(MyApp.Razor.Views.Template), @"default", @"/TestFiles/IntegrationTests/RazorTemplateEngineIntegrationTest/GenerateCodeWithSetNamespace.cshtml")] diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs index 52c5f77825..a577847515 100644 --- a/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestRazorProjectItem.cs @@ -11,10 +11,12 @@ namespace Microsoft.AspNetCore.Razor.Language public TestRazorProjectItem( string filePath, string physicalPath = null, + string relativePhysicalPath = null, string basePath = "/") { FilePath = filePath; PhysicalPath = physicalPath; + RelativePhysicalPath = relativePhysicalPath; BasePath = basePath; } @@ -24,6 +26,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override string PhysicalPath { get; } + public override string RelativePhysicalPath { get; } + public override bool Exists => true; public string Content { get; set; } = "Default content";