diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorIRLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorIRLoweringPhase.cs index 99eae8977f..2582765413 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorIRLoweringPhase.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/DefaultRazorIRLoweringPhase.cs @@ -390,9 +390,15 @@ namespace Microsoft.AspNetCore.Razor.Evolution Source = BuildSourceSpanFromNode(block) }); + var tagName = tagHelperBlock.TagName; + if (tagHelperBlock.Descriptors.First().Prefix != null) + { + tagName = tagName.Substring(tagHelperBlock.Descriptors.First().Prefix.Length); + } + _builder.Push(new InitializeTagHelperStructureIRNode() { - TagName = tagHelperBlock.TagName, + TagName = tagName, TagMode = tagHelperBlock.TagMode }); } diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs b/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs index b021ca2039..3c5d162581 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs @@ -12,6 +12,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution internal IReadOnlyList LineMappings { get; set; } - internal IReadOnlyList Diagnostics { get; set; } + public IReadOnlyList Diagnostics { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Intermediate/DefaultRazorIRLoweringPhaseIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Intermediate/DefaultRazorIRLoweringPhaseIntegrationTest.cs index 3ca28364e8..dd4267e18b 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Intermediate/DefaultRazorIRLoweringPhaseIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/Intermediate/DefaultRazorIRLoweringPhaseIntegrationTest.cs @@ -194,6 +194,49 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate }); } + [Fact] + public void Lower_TagHelpers_WithPrefix() + { + // Arrange + var codeDocument = TestRazorCodeDocument.Create(@"@addTagHelper *, TestAssembly +@tagHelperPrefix cool: +"); + var tagHelpers = new[] + { + new TagHelperDescriptor + { + TagName = "span", + TypeName = "SpanTagHelper", + AssemblyName = "TestAssembly", + } + }; + + // Act + var irDocument = Lower(codeDocument, tagHelpers: tagHelpers); + + // Assert + Children(irDocument, + n => Checksum(n), + n => Using("System", n), + n => Using(typeof(Task).Namespace, n), + n => TagHelperFieldDeclaration(n, "SpanTagHelper"), + n => + { + var tagHelperNode = Assert.IsType(n); + Children( + tagHelperNode, + c => TagHelperStructure("span", TagMode.StartTagAndEndTag, c), // Note: this is span not cool:span + c => Assert.IsType(c), + c => TagHelperHtmlAttribute( + "val", + HtmlAttributeValueStyle.DoubleQuotes, + c, + v => CSharpAttributeValue(string.Empty, "Hello", v), + v => LiteralAttributeValue(" ", "World", v)), + c => Assert.IsType(c)); + }); + } + [Fact] public void Lower_TagHelper_InSection() { diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs index b25fe00f74..266086a73a 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_Runtime.codegen.cs @@ -33,9 +33,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles public async System.Threading.Tasks.Task ExecuteAsync() { WriteLiteral("\r\n\r\n "); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("THSp", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => { WriteLiteral("\r\n

\r\n \r\n "); - __tagHelperExecutionContext = __tagHelperScopeManager.Begin("THSinput", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { + __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "test", async() => { } ); __TestNamespace_InputTagHelper = CreateTagHelper();