Remove Get/SetRelativePath

This commit is contained in:
Ryan Nowak 2018-01-05 18:05:17 -08:00
parent d602f9d770
commit b93bab9c04
51 changed files with 181 additions and 259 deletions

View File

@ -26,13 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
Options.DefaultImports = GetDefaultImports(); Options.DefaultImports = GetDefaultImports();
} }
/// <inheritsdoc />
public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem) public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem)
{ {
var codeDocument = base.CreateCodeDocument(projectItem); return base.CreateCodeDocument(projectItem);
codeDocument.SetRelativePath(projectItem.FilePath);
return codeDocument;
} }
// Internal for testing. // Internal for testing.

View File

@ -20,12 +20,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
ClassDeclarationIntermediateNode @class, ClassDeclarationIntermediateNode @class,
MethodDeclarationIntermediateNode method) MethodDeclarationIntermediateNode method)
{ {
var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@namespace.Content = "AspNetCore"; @namespace.Content = "AspNetCore";
var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath;
@class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>"; @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>";
@class.Modifiers.Clear(); @class.Modifiers.Clear();

View File

@ -1,34 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
{
internal static class RazorCodeDocumentExtensions
{
private const string RelativePathKey = "relative-path";
public static string GetRelativePath(this RazorCodeDocument document)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
return document.Items[RelativePathKey] as string;
}
public static void SetRelativePath(this RazorCodeDocument document, string relativePath)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
document.Items[RelativePathKey] = relativePath;
}
}
}

View File

@ -29,8 +29,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
} }
var generatedTypeName = $"{@namespace.Content}.{@class.ClassName}"; var generatedTypeName = $"{@namespace.Content}.{@class.ClassName}";
var path = codeDocument.GetRelativePath();
var escapedPath = EscapeAsVerbatimLiteral(path); // The MVC attributes require a relative path to be specified so that we can make a view engine path.
// We can't use a rooted path because we don't know what the project root is.
//
// If we can't sanitize the path, we'll just set it to null and let is blow up at runtime - we don't
// want to create noise if this code has to run in some unanticipated scenario.
var escapedPath = MakeVerbatimStringLiteral(ConvertToViewEnginePath(codeDocument.Source.RelativePath));
string attribute; string attribute;
if (documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind) if (documentNode.DocumentKind == MvcViewDocumentClassifierPass.MvcViewDocumentKind)
@ -40,7 +45,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
else if (documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind && else if (documentNode.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind &&
PageDirective.TryGetPageDirective(documentNode, out var pageDirective)) PageDirective.TryGetPageDirective(documentNode, out var pageDirective))
{ {
var escapedRoutePrefix = EscapeAsVerbatimLiteral(pageDirective.RouteTemplate); var escapedRoutePrefix = MakeVerbatimStringLiteral(pageDirective.RouteTemplate);
attribute = $"[assembly:{RazorPageAttribute}({escapedPath}, typeof({generatedTypeName}), {escapedRoutePrefix})]"; attribute = $"[assembly:{RazorPageAttribute}({escapedPath}, typeof({generatedTypeName}), {escapedRoutePrefix})]";
} }
else else
@ -61,7 +66,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
documentNode.Children.Insert(index, pageAttribute); documentNode.Children.Insert(index, pageAttribute);
} }
private static string EscapeAsVerbatimLiteral(string value) private static string MakeVerbatimStringLiteral(string value)
{ {
if (value == null) if (value == null)
{ {
@ -71,5 +76,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
value = value.Replace("\"", "\"\""); value = value.Replace("\"", "\"\"");
return $"@\"{value}\""; return $"@\"{value}\"";
} }
private static string ConvertToViewEnginePath(string relativePath)
{
if (string.IsNullOrEmpty(relativePath))
{
return null;
}
// Checking for both / and \ because a \ will become a /.
if (!relativePath.StartsWith("/") && !relativePath.StartsWith("\\"))
{
relativePath = "/" + relativePath;
}
relativePath = relativePath.Replace('\\', '/');
return relativePath;
}
} }
} }

View File

@ -26,13 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
Options.DefaultImports = GetDefaultImports(); Options.DefaultImports = GetDefaultImports();
} }
/// <inheritsdoc />
public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem) public override RazorCodeDocument CreateCodeDocument(RazorProjectItem projectItem)
{ {
var codeDocument = base.CreateCodeDocument(projectItem); return base.CreateCodeDocument(projectItem);
codeDocument.SetRelativePath(projectItem.FilePath);
return codeDocument;
} }
// Internal for testing. // Internal for testing.

View File

@ -20,12 +20,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
ClassDeclarationIntermediateNode @class, ClassDeclarationIntermediateNode @class,
MethodDeclarationIntermediateNode method) MethodDeclarationIntermediateNode method)
{ {
var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@namespace.Content = "AspNetCore"; @namespace.Content = "AspNetCore";
var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath;
@class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>"; @class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>";
@class.Modifiers.Clear(); @class.Modifiers.Clear();

View File

@ -1,34 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{
internal static class RazorCodeDocumentExtensions
{
private const string RelativePathKey = "relative-path";
public static string GetRelativePath(this RazorCodeDocument document)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
return document.Items[RelativePathKey] as string;
}
public static void SetRelativePath(this RazorCodeDocument document, string relativePath)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
document.Items[RelativePathKey] = relativePath;
}
}
}

View File

@ -24,13 +24,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
ClassDeclarationIntermediateNode @class, ClassDeclarationIntermediateNode @class,
MethodDeclarationIntermediateNode method) MethodDeclarationIntermediateNode method)
{ {
var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method); base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@namespace.Content = "AspNetCore"; @namespace.Content = "AspNetCore";
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page"; @class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page";
var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath;
@class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath); @class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath);
@class.Modifiers.Clear(); @class.Modifiers.Clear();

View File

@ -201,7 +201,37 @@ namespace Microsoft.AspNetCore.Razor.Language
/// <returns>The <see cref="RazorSourceDocument"/>.</returns> /// <returns>The <see cref="RazorSourceDocument"/>.</returns>
/// <remarks>Uses <see cref="System.Text.Encoding.UTF8" /></remarks> /// <remarks>Uses <see cref="System.Text.Encoding.UTF8" /></remarks>
public static RazorSourceDocument Create(string content, string fileName) public static RazorSourceDocument Create(string content, string fileName)
=> Create(content, fileName, Encoding.UTF8); {
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}
return Create(content, fileName, Encoding.UTF8);
}
/// <summary>
/// Creates a <see cref="RazorSourceDocument"/> from the specified <paramref name="content"/>.
/// </summary>
/// <param name="content">The source document content.</param>
/// <param name="properties">Properties to configure the <see cref="RazorSourceDocument"/>.</param>
/// <returns>The <see cref="RazorSourceDocument"/>.</returns>
/// <remarks>Uses <see cref="System.Text.Encoding.UTF8" /></remarks>
public static RazorSourceDocument Create(string content, RazorSourceDocumentProperties properties)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}
if (properties == null)
{
throw new ArgumentNullException(nameof(properties));
}
return Create(content, Encoding.UTF8, properties);
}
/// <summary> /// <summary>
/// Creates a <see cref="RazorSourceDocument"/> from the specified <paramref name="content"/>. /// Creates a <see cref="RazorSourceDocument"/> from the specified <paramref name="content"/>.

View File

@ -175,8 +175,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{ {
Engine = RazorEngine.Create(), Engine = RazorEngine.Create(),
}; };
var document = TestRazorCodeDocument.CreateEmpty();
document.SetRelativePath("/Views/Index.cshtml"); var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml"));
var document = RazorCodeDocument.Create(source);
// Act // Act
pass.Execute(document, irDocument); pass.Execute(document, irDocument);
@ -197,7 +198,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void Execute_EscapesViewPathWhenAddingAttributeToViews() public void Execute_EscapesViewPathWhenAddingAttributeToViews()
{ {
// Arrange // Arrange
var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"\\test\\\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]";
var irDocument = new DocumentIntermediateNode var irDocument = new DocumentIntermediateNode
{ {
DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind,
@ -226,8 +227,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{ {
Engine = RazorEngine.Create(), Engine = RazorEngine.Create(),
}; };
var document = TestRazorCodeDocument.CreateEmpty();
document.SetRelativePath("\\test\\\"Index.cshtml"); var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "\\test\\\"Index.cshtml"));
var document = RazorCodeDocument.Create(source);
// Act // Act
pass.Execute(document, irDocument); pass.Execute(document, irDocument);
@ -283,8 +285,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{ {
Engine = RazorEngine.Create(), Engine = RazorEngine.Create(),
}; };
var document = TestRazorCodeDocument.CreateEmpty();
document.SetRelativePath("/Views/Index.cshtml"); var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "/Views/Index.cshtml"));
var document = RazorCodeDocument.Create(source);
// Act // Act
pass.Execute(document, irDocument); pass.Execute(document, irDocument);
@ -306,7 +309,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void Execute_EscapesViewPathAndRouteWhenAddingAttributeToPage() public void Execute_EscapesViewPathAndRouteWhenAddingAttributeToPage()
{ {
// Arrange // Arrange
var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"\\test\\\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]"; var expectedAttribute = "[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@\"/test/\"\"Index.cshtml\", typeof(SomeNamespace.SomeName))]";
var irDocument = new DocumentIntermediateNode var irDocument = new DocumentIntermediateNode
{ {
DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind, DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind,
@ -336,8 +339,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
{ {
Engine = RazorEngine.Create(), Engine = RazorEngine.Create(),
}; };
var document = TestRazorCodeDocument.CreateEmpty();
document.SetRelativePath("\\test\\\"Index.cshtml"); var source = TestRazorSourceDocument.Create("test", new RazorSourceDocumentProperties(filePath: null, relativePath: "test\\\"Index.cshtml"));
var document = RazorCodeDocument.Create(source);
// Act // Act
pass.Execute(document, irDocument); pass.Execute(document, irDocument);

View File

@ -2,10 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
@ -86,28 +84,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent); Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent);
} }
[Fact]
public void CreateCodeDocument_SetsRelativePathOnOutput()
{
// Arrange
var path = "/Views/Home/Index.cshtml";
var item = new TestRazorProjectItem(path)
{
Content = "Hello world",
};
var project = new TestRazorProject(new List<RazorProjectItem>() { item, });
var mvcRazorTemplateEngine = new MvcRazorTemplateEngine(
RazorEngine.Create(),
project);
// Act
var codeDocument = mvcRazorTemplateEngine.CreateCodeDocument(path);
// Assert
Assert.Equal(path, codeDocument.GetRelativePath());
}
private string GetContent(RazorSourceDocument imports) private string GetContent(RazorSourceDocument imports)
{ {
var contentChars = new char[imports.Length]; var contentChars = new char[imports.Length];

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Xunit; using Xunit;
@ -14,7 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void MvcViewDocumentClassifierPass_SetsDocumentKind() public void MvcViewDocumentClassifierPass_SetsDocumentKind()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -33,7 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
irDocument.DocumentKind = "some-value"; irDocument.DocumentKind = "some-value";
@ -53,7 +54,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void MvcViewDocumentClassifierPass_SetsNamespace() public void MvcViewDocumentClassifierPass_SetsNamespace()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -74,14 +76,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void MvcViewDocumentClassifierPass_SetsClass() public void MvcViewDocumentClassifierPass_SetsClass()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml");
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
{ {
Engine = engine Engine = engine
}; };
codeDocument.SetRelativePath("Test.cshtml");
// Act // Act
pass.Execute(codeDocument, irDocument); pass.Execute(codeDocument, irDocument);
@ -100,8 +103,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected)
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath);
codeDocument.SetRelativePath(relativePath); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -122,9 +126,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet()
{ {
// Arrange // Arrange
var expected = "x___application_Views_Home_Index"; var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null);
var path = @"x::\application\Views\Home\Index.cshtml"; var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
var codeDocument = CreateDocument("some-content", path);
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -138,16 +142,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument); visitor.Visit(irDocument);
// Assert // Assert
Assert.Equal(expected, visitor.Class.ClassName); Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName);
} }
[Fact] [Fact]
public void MvcViewDocumentClassifierPass_SanitizesClassName() public void MvcViewDocumentClassifierPass_SanitizesClassName()
{ {
// Arrange // Arrange
var expected = "path_with_invalid_chars"; var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars");
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
codeDocument.SetRelativePath("path.with+invalid-chars");
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -161,14 +165,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument); visitor.Visit(irDocument);
// Assert // Assert
Assert.Equal(expected, visitor.Class.ClassName); Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName);
} }
[Fact] [Fact]
public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod() public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -187,14 +192,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers);
} }
private static RazorCodeDocument CreateDocument(string content, string filePath = null)
{
filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml");
var source = RazorSourceDocument.Create(content, filePath);
return RazorCodeDocument.Create(source);
}
private static RazorEngine CreateEngine() => RazorEngine.Create(); private static RazorEngine CreateEngine() => RazorEngine.Create();
private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument)

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Xunit; using Xunit;
@ -40,7 +39,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_SetsDocumentKind() public void RazorPageDocumentClassifierPass_SetsDocumentKind()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
@ -59,7 +59,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() public void RazorPageDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
irDocument.DocumentKind = "some-value"; irDocument.DocumentKind = "some-value";
@ -79,7 +80,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_NoOpsIfPageDirectiveIsMalformed() public void RazorPageDocumentClassifierPass_NoOpsIfPageDirectiveIsMalformed()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page+1"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page+1", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
irDocument.DocumentKind = "some-value"; irDocument.DocumentKind = "some-value";
@ -99,7 +101,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_SetsNamespace() public void RazorPageDocumentClassifierPass_SetsNamespace()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
@ -120,14 +123,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_SetsClass() public void RazorPageDocumentClassifierPass_SetsClass()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page"); var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml");
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
{ {
Engine = engine Engine = engine
}; };
codeDocument.SetRelativePath("Test.cshtml");
// Act // Act
pass.Execute(codeDocument, irDocument); pass.Execute(codeDocument, irDocument);
@ -146,8 +150,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) public void RazorPageDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected)
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page"); var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath);
codeDocument.SetRelativePath(relativePath); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
@ -168,9 +173,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() public void RazorPageDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet()
{ {
// Arrange // Arrange
var expected = "x___application_Views_Home_Index"; var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null);
var path = @"x::\application\Views\Home\Index.cshtml"; var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
var codeDocument = CreateDocument("@page", path);
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
@ -184,16 +189,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument); visitor.Visit(irDocument);
// Assert // Assert
Assert.Equal(expected, visitor.Class.ClassName); Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName);
} }
[Fact] [Fact]
public void RazorPageDocumentClassifierPass_SanitizesClassName() public void RazorPageDocumentClassifierPass_SanitizesClassName()
{ {
// Arrange // Arrange
var expected = "path_with_invalid_chars"; var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars");
var codeDocument = CreateDocument("@page"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
codeDocument.SetRelativePath("path.with+invalid-chars");
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
@ -207,14 +212,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
visitor.Visit(irDocument); visitor.Visit(irDocument);
// Assert // Assert
Assert.Equal(expected, visitor.Class.ClassName); Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName);
} }
[Fact] [Fact]
public void RazorPageDocumentClassifierPass_SetsUpExecuteAsyncMethod() public void RazorPageDocumentClassifierPass_SetsUpExecuteAsyncMethod()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("@page"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new RazorPageDocumentClassifierPass var pass = new RazorPageDocumentClassifierPass
@ -233,14 +239,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers);
} }
private static RazorCodeDocument CreateDocument(string content, string filePath = null)
{
filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml");
var source = RazorSourceDocument.Create(content, filePath);
return RazorCodeDocument.Create(source);
}
private static RazorEngine CreateEngine() private static RazorEngine CreateEngine()
{ {
return RazorEngine.Create(b => return RazorEngine.Create(b =>

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives")]
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives), null)]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports")]
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports), null)]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective")]
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective), null)]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace")]
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)]
namespace Test.Namespace namespace Test.Namespace
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace), null)]
NamespaceDeclaration - - Test.Namespace NamespaceDeclaration - - Test.Namespace
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel")]
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel), null)]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), @"mvc.1.0.razor-page", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages")]
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages), null)]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))]
namespace Test.Namespace namespace Test.Namespace
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml", typeof(Test.Namespace.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace))]
NamespaceDeclaration - - Test.Namespace NamespaceDeclaration - - Test.Namespace
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,7 +2,7 @@
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports), @"mvc.1.0.view", @"TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports")]
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))]
namespace AspNetCore namespace AspNetCore
{ {
#line hidden #line hidden

View File

@ -1,7 +1,7 @@
Document - Document -
RazorCompiledItemAttribute - RazorCompiledItemAttribute -
CSharpCode - CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))] IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml", typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports))]
NamespaceDeclaration - - AspNetCore NamespaceDeclaration - - AspNetCore
UsingDirective - (1:0,1 [14] ) - System UsingDirective - (1:0,1 [14] ) - System
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic UsingDirective - (16:1,1 [34] ) - System.Collections.Generic

View File

@ -2,10 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
@ -84,28 +82,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent); Assert.Contains("@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor", importContent);
} }
[Fact]
public void CreateCodeDocument_SetsRelativePathOnOutput()
{
// Arrange
var path = "/Views/Home/Index.cshtml";
var item = new TestRazorProjectItem(path)
{
Content = "Hello world",
};
var project = new TestRazorProject(new List<RazorProjectItem>() { item, });
var mvcRazorTemplateEngine = new MvcRazorTemplateEngine(
RazorEngine.Create(),
project);
// Act
var codeDocument = mvcRazorTemplateEngine.CreateCodeDocument(path);
// Assert
Assert.Equal(path, codeDocument.GetRelativePath());
}
private string GetContent(RazorSourceDocument imports) private string GetContent(RazorSourceDocument imports)
{ {
var contentChars = new char[imports.Length]; var contentChars = new char[imports.Length];

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Xunit; using Xunit;
@ -14,7 +13,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public void MvcViewDocumentClassifierPass_SetsDocumentKind() public void MvcViewDocumentClassifierPass_SetsDocumentKind()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -33,7 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet() public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
irDocument.DocumentKind = "some-value"; irDocument.DocumentKind = "some-value";
@ -53,7 +54,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public void MvcViewDocumentClassifierPass_SetsNamespace() public void MvcViewDocumentClassifierPass_SetsNamespace()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -74,14 +76,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public void MvcViewDocumentClassifierPass_SetsClass() public void MvcViewDocumentClassifierPass_SetsClass()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml");
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
{ {
Engine = engine Engine = engine
}; };
codeDocument.SetRelativePath("Test.cshtml");
// Act // Act
pass.Execute(codeDocument, irDocument); pass.Execute(codeDocument, irDocument);
@ -100,8 +103,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected) public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected)
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath);
codeDocument.SetRelativePath(relativePath); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -122,9 +126,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet() public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet()
{ {
// Arrange // Arrange
var expected = "x___application_Views_Home_Index"; var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null);
var path = @"x::\application\Views\Home\Index.cshtml"; var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
var codeDocument = CreateDocument("some-content", path);
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -138,16 +142,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
visitor.Visit(irDocument); visitor.Visit(irDocument);
// Assert // Assert
Assert.Equal(expected, visitor.Class.ClassName); Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName);
} }
[Fact] [Fact]
public void MvcViewDocumentClassifierPass_SanitizesClassName() public void MvcViewDocumentClassifierPass_SanitizesClassName()
{ {
// Arrange // Arrange
var expected = "path_with_invalid_chars"; var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars");
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
codeDocument.SetRelativePath("path.with+invalid-chars");
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -161,14 +165,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
visitor.Visit(irDocument); visitor.Visit(irDocument);
// Assert // Assert
Assert.Equal(expected, visitor.Class.ClassName); Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName);
} }
[Fact] [Fact]
public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod() public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod()
{ {
// Arrange // Arrange
var codeDocument = CreateDocument("some-content"); var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
var engine = CreateEngine(); var engine = CreateEngine();
var irDocument = CreateIRDocument(engine, codeDocument); var irDocument = CreateIRDocument(engine, codeDocument);
var pass = new MvcViewDocumentClassifierPass var pass = new MvcViewDocumentClassifierPass
@ -187,14 +192,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers); Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers);
} }
private static RazorCodeDocument CreateDocument(string content, string filePath = null)
{
filePath = filePath ?? Path.Combine(Directory.GetCurrentDirectory(), "Test.cshtml");
var source = RazorSourceDocument.Create(content, filePath);
return RazorCodeDocument.Create(source);
}
private static RazorEngine CreateEngine() => RazorEngine.Create(); private static RazorEngine CreateEngine() => RazorEngine.Create();
private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument) private static DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument)