diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs
index 5d5666fc1bd..c9a50288e04 100644
--- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/CodeGenerationIntegrationTest.cs
@@ -203,6 +203,9 @@ public void ConditionalAttributes2()
[IntegrationTestFact]
public void TagHelpersWithBoundAttributes() => RunTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors);
+ [IntegrationTestFact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
+ public void TagHelpersWithBoundAttributesAndRazorComment() => RunTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors);
+
[IntegrationTestFact]
public void TagHelpersWithPrefix() => RunTagHelpersTest(TestTagHelperDescriptors.SimpleTagHelperDescriptors);
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs
index b18e427c6c9..1451c93a79a 100644
--- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs
@@ -344,6 +344,12 @@ public void ConditionalAttribute_CommentBefore()
ParseDocumentTest("""
""");
}
+ [Fact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
+ public void AttributeAfterComment()
+ {
+ ParseDocumentTest("""""");
+ }
+
[Fact]
public void EscapedAttributeName_WithValue()
{
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs
index 8791613215c..3bbcb7584ee 100644
--- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs
@@ -2472,4 +2472,104 @@ public void Rewrites_MinimizedComponentDirectiveAttributes()
builder.AllowCSharpInMarkupAttributeArea = false;
});
}
+
+ [Fact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
+ public void TagHelper_AttributeAfterRazorComment()
+ {
+ // Arrange
+ var descriptors = ImmutableArray.Create(
+ TagHelperDescriptorBuilder.CreateTagHelper("PTagHelper", "TestAssembly")
+ .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p"))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("attribute-1")
+ .PropertyName("Attribute1")
+ .TypeName(typeof(string).FullName))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("not-visible")
+ .PropertyName("NotVisible")
+ .TypeName(typeof(bool).FullName))
+ .Build());
+
+ // Act & Assert
+ EvaluateData(descriptors, """
+
+
+ """);
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
+ public void TagHelper_MultipleAttributesAfterRazorComment()
+ {
+ // Arrange
+ var descriptors = ImmutableArray.Create(
+ TagHelperDescriptorBuilder.CreateTagHelper("PTagHelper", "TestAssembly")
+ .TagMatchingRuleDescriptor(rule => rule.RequireTagName("p"))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("attr-1")
+ .PropertyName("Attr1")
+ .TypeName(typeof(string).FullName))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("attr-2")
+ .PropertyName("Attr2")
+ .TypeName(typeof(string).FullName))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("attr-3")
+ .PropertyName("Attr3")
+ .TypeName(typeof(string).FullName))
+ .Build());
+
+ // Act & Assert
+ EvaluateData(descriptors, """
+
+ """);
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
+ public void TagHelper_MultipleInterleavedRazorComments()
+ {
+ // Arrange
+ var descriptors = ImmutableArray.Create(
+ TagHelperDescriptorBuilder.CreateTagHelper("InputTagHelper", "TestAssembly")
+ .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input"))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("type")
+ .PropertyName("Type")
+ .TypeName(typeof(string).FullName))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("value")
+ .PropertyName("Value")
+ .TypeName(typeof(string).FullName))
+ .Build());
+
+ // Act & Assert
+ EvaluateData(descriptors, """
+
+ """);
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
+ public void TagHelper_MinimizedAttributeAfterRazorComment()
+ {
+ // Arrange
+ var descriptors = ImmutableArray.Create(
+ TagHelperDescriptorBuilder.CreateTagHelper("InputTagHelper", "TestAssembly")
+ .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input"))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("type")
+ .PropertyName("Type")
+ .TypeName(typeof(string).FullName))
+ .BoundAttributeDescriptor(attribute => attribute
+ .Name("checked")
+ .PropertyName("Checked")
+ .TypeName(typeof(bool).FullName))
+ .Build());
+
+ // Act & Assert
+ EvaluateData(descriptors, """
+
+ """);
+ }
}
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml
new file mode 100644
index 00000000000..98c530e372f
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper *, TestAssembly
+
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.codegen.cs
new file mode 100644
index 00000000000..442c0bcc6e3
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.codegen.cs
@@ -0,0 +1,76 @@
+//
+#pragma warning disable 1591
+namespace AspNetCoreGeneratedDocument
+{
+ #line default
+ using TModel = global::System.Object;
+ using global::System;
+ using global::System.Collections.Generic;
+ using global::System.Linq;
+ using global::System.Threading.Tasks;
+ using global::Microsoft.AspNetCore.Mvc;
+ using global::Microsoft.AspNetCore.Mvc.Rendering;
+ using global::Microsoft.AspNetCore.Mvc.ViewFeatures;
+ #line default
+ #line hidden
+ [global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("Identifier", "/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml")]
+ [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdateAttribute]
+ #nullable restore
+ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributesAndRazorComment : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage
+ #nullable disable
+ {
+ #line hidden
+ #pragma warning disable 0649
+ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
+ #pragma warning restore 0649
+ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
+ private global::InputTagHelper __InputTagHelper;
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ ((global::System.Action)(() => {
+#nullable restore
+#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml"
+global::System.Object __typeHelper = "*, TestAssembly";
+
+#line default
+#line hidden
+#nullable disable
+ }
+ ))();
+ }
+ #pragma warning restore 219
+ #pragma warning disable 0414
+ private static object __o = null;
+ #pragma warning restore 0414
+ #pragma warning disable 1998
+ public async override global::System.Threading.Tasks.Task ExecuteAsync()
+ {
+ __InputTagHelper = CreateTagHelper();
+ __InputTagHelper.FooProp = "Hello";
+ __InputTagHelper.BoundProp = "World";
+ await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
+ }
+ #pragma warning restore 1998
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } = default!;
+ #nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.codegen.html b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.codegen.html
new file mode 100644
index 00000000000..d792289b490
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.codegen.html
@@ -0,0 +1,2 @@
+/*~~~~~~~~~*/ ~~ /*~~~~~~~~*/
+
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.ir.txt
new file mode 100644
index 00000000000..5e08128ca7e
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.ir.txt
@@ -0,0 +1,56 @@
+Document -
+ NamespaceDeclaration - - AspNetCoreGeneratedDocument
+ UsingDirective - - TModel = global::System.Object
+ UsingDirective - (1:0,1 [20] ) - global::System
+ UsingDirective - (24:1,1 [40] ) - global::System.Collections.Generic
+ UsingDirective - (67:2,1 [25] ) - global::System.Linq
+ UsingDirective - (95:3,1 [36] ) - global::System.Threading.Tasks
+ UsingDirective - (134:4,1 [38] ) - global::Microsoft.AspNetCore.Mvc
+ UsingDirective - (175:5,1 [48] ) - global::Microsoft.AspNetCore.Mvc.Rendering
+ UsingDirective - (226:6,1 [51] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures
+ RazorCompiledItemMetadataAttribute -
+ CreateNewOnMetadataUpdateAttribute -
+ ClassDeclaration - - internal sealed - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributesAndRazorComment - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage -
+ DefaultTagHelperRuntime -
+ FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper
+ DesignTimeDirective -
+ DirectiveToken - (287:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
+ DirectiveToken - (350:7,71 [4] ) - Html
+ DirectiveToken - (364:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
+ DirectiveToken - (419:8,63 [4] ) - Json
+ DirectiveToken - (433:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
+ DirectiveToken - (487:9,62 [9] ) - Component
+ DirectiveToken - (506:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
+ DirectiveToken - (550:10,52 [3] ) - Url
+ DirectiveToken - (563:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
+ DirectiveToken - (634:11,79 [23] ) - ModelExpressionProvider
+ DirectiveToken - (673:12,14 [104] ) - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
+ DirectiveToken - (793:13,14 [95] ) - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor
+ DirectiveToken - (904:14,14 [95] ) - global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor
+ DirectiveToken - (14:0,14 [15] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - *, TestAssembly
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning disable 0414
+ CSharpCode -
+ IntermediateToken - - CSharp - private static object __o = null;
+ CSharpCode -
+ IntermediateToken - - CSharp - #pragma warning restore 0414
+ MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
+ HtmlContent - (29:0,29 [2] TagHelpersWithBoundAttributesAndRazorComment.cshtml)
+ LazyIntermediateToken - (29:0,29 [2] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - Html - \n
+ TagHelper - (31:1,0 [70] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - input - TagMode.SelfClosing
+ DefaultTagHelperBody -
+ DefaultTagHelperCreate - - InputTagHelper
+ DefaultTagHelperProperty - (45:1,14 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - value - string InputTagHelper.FooProp - HtmlAttributeValueStyle.DoubleQuotes
+ HtmlContent - (45:1,14 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml)
+ LazyIntermediateToken - (45:1,14 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - Html - Hello
+ DefaultTagHelperProperty - (92:1,61 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - bound - string InputTagHelper.BoundProp - HtmlAttributeValueStyle.DoubleQuotes
+ HtmlContent - (92:1,61 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml)
+ LazyIntermediateToken - (92:1,61 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - Html - World
+ DefaultTagHelperExecute -
+ HtmlContent - (101:1,70 [2] TagHelpersWithBoundAttributesAndRazorComment.cshtml)
+ LazyIntermediateToken - (101:1,70 [2] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - Html - \n
+ Inject -
+ Inject -
+ Inject -
+ Inject -
+ Inject -
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.mappings.txt
new file mode 100644
index 00000000000..028a3d9c61f
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_DesignTime.mappings.txt
@@ -0,0 +1,5 @@
+Source Location: (14:0,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml)
+|*, TestAssembly|
+Generated Location: (1815:32,38 [15] )
+|*, TestAssembly|
+
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_Runtime.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_Runtime.codegen.cs
new file mode 100644
index 00000000000..574d420dee9
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_Runtime.codegen.cs
@@ -0,0 +1,91 @@
+#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "b8bba79998ca63f9eff59848ecc1f209c12647e1a3daab7d4bfd0d04e156cd62"
+//
+#pragma warning disable 1591
+[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCoreGeneratedDocument.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributesAndRazorComment), @"mvc.1.0.view", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml")]
+namespace AspNetCoreGeneratedDocument
+{
+ #line default
+ using global::System;
+ using global::System.Collections.Generic;
+ using global::System.Linq;
+ using global::System.Threading.Tasks;
+ using global::Microsoft.AspNetCore.Mvc;
+ using global::Microsoft.AspNetCore.Mvc.Rendering;
+ using global::Microsoft.AspNetCore.Mvc.ViewFeatures;
+ #line default
+ #line hidden
+ [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"Sha256", @"b8bba79998ca63f9eff59848ecc1f209c12647e1a3daab7d4bfd0d04e156cd62", @"/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml")]
+ [global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemMetadataAttribute("Identifier", "/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment.cshtml")]
+ [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdateAttribute]
+ #nullable restore
+ internal sealed class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributesAndRazorComment : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage
+ #nullable disable
+ {
+ private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("value", "Hello", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
+ private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("bound", "World", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
+ #line hidden
+ #pragma warning disable 0649
+ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
+ #pragma warning restore 0649
+ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
+ #pragma warning disable 0169
+ private string __tagHelperStringValueBuffer;
+ #pragma warning restore 0169
+ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __backed__tagHelperScopeManager = null;
+ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __tagHelperScopeManager
+ {
+ get
+ {
+ if (__backed__tagHelperScopeManager == null)
+ {
+ __backed__tagHelperScopeManager = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager(StartTagHelperWritingScope, EndTagHelperWritingScope);
+ }
+ return __backed__tagHelperScopeManager;
+ }
+ }
+ private global::InputTagHelper __InputTagHelper;
+ #pragma warning disable 1998
+ public async override global::System.Threading.Tasks.Task ExecuteAsync()
+ {
+ __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "__UniqueIdSuppressedForTesting__", async() => {
+ }
+ );
+ __InputTagHelper = CreateTagHelper();
+ __tagHelperExecutionContext.Add(__InputTagHelper);
+ __InputTagHelper.FooProp = (string)__tagHelperAttribute_0.Value;
+ __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
+ __InputTagHelper.BoundProp = (string)__tagHelperAttribute_1.Value;
+ __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
+ await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
+ if (!__tagHelperExecutionContext.Output.IsContentModified)
+ {
+ await __tagHelperExecutionContext.SetOutputContentAsync();
+ }
+ Write(__tagHelperExecutionContext.Output);
+ __tagHelperExecutionContext = __tagHelperScopeManager.End();
+ WriteLiteral("\r\n");
+ }
+ #pragma warning restore 1998
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } = default!;
+ #nullable disable
+ #nullable restore
+ [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
+ public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper Html { get; private set; } = default!;
+ #nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_Runtime.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_Runtime.ir.txt
new file mode 100644
index 00000000000..2ef84eed9e7
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributesAndRazorComment_Runtime.ir.txt
@@ -0,0 +1,32 @@
+Document -
+ RazorCompiledItemAttribute -
+ NamespaceDeclaration - - AspNetCoreGeneratedDocument
+ UsingDirective - (1:0,1 [20] ) - global::System
+ UsingDirective - (24:1,1 [40] ) - global::System.Collections.Generic
+ UsingDirective - (67:2,1 [25] ) - global::System.Linq
+ UsingDirective - (95:3,1 [36] ) - global::System.Threading.Tasks
+ UsingDirective - (134:4,1 [38] ) - global::Microsoft.AspNetCore.Mvc
+ UsingDirective - (175:5,1 [48] ) - global::Microsoft.AspNetCore.Mvc.Rendering
+ UsingDirective - (226:6,1 [51] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures
+ RazorSourceChecksumAttribute -
+ RazorCompiledItemMetadataAttribute -
+ CreateNewOnMetadataUpdateAttribute -
+ ClassDeclaration - - internal sealed - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributesAndRazorComment - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage -
+ PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_0 - value - Hello - HtmlAttributeValueStyle.DoubleQuotes
+ PreallocatedTagHelperPropertyValue - - __tagHelperAttribute_1 - bound - World - HtmlAttributeValueStyle.DoubleQuotes
+ DefaultTagHelperRuntime -
+ FieldDeclaration - - private - global::InputTagHelper - __InputTagHelper
+ MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
+ TagHelper - (31:1,0 [70] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - input - TagMode.SelfClosing
+ DefaultTagHelperBody -
+ DefaultTagHelperCreate - - InputTagHelper
+ PreallocatedTagHelperProperty - (45:1,14 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - __tagHelperAttribute_0 - value - FooProp
+ PreallocatedTagHelperProperty - (92:1,61 [5] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - __tagHelperAttribute_1 - bound - BoundProp
+ DefaultTagHelperExecute -
+ HtmlContent - (101:1,70 [2] TagHelpersWithBoundAttributesAndRazorComment.cshtml)
+ LazyIntermediateToken - (101:1,70 [2] TagHelpersWithBoundAttributesAndRazorComment.cshtml) - Html - \n
+ Inject -
+ Inject -
+ Inject -
+ Inject -
+ Inject -
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/AttributeAfterComment.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/AttributeAfterComment.cspans.txt
new file mode 100644
index 00000000000..bc6094e2c6c
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/AttributeAfterComment.cspans.txt
@@ -0,0 +1,14 @@
+Markup span at (0:0,0 [2] ) - Parent: Tag block at (0:0,0 [53] )
+Markup span at (2:0,2 [8] ) - Parent: Markup block at (2:0,2 [14] )
+Markup span at (10:0,10 [5] ) - Parent: Markup block at (2:0,2 [14] )
+Markup span at (15:0,15 [1] ) - Parent: Markup block at (2:0,2 [14] )
+Markup span at (16:0,16 [1] ) - Parent: Tag block at (0:0,0 [53] )
+Transition span at (17:0,17 [1] ) - Parent: Comment block at (17:0,17 [13] )
+MetaCode span at (18:0,18 [1] ) - Parent: Comment block at (17:0,17 [13] )
+Comment span at (19:0,19 [9] ) - Parent: Comment block at (17:0,17 [13] )
+MetaCode span at (28:0,28 [1] ) - Parent: Comment block at (17:0,17 [13] )
+Transition span at (29:0,29 [1] ) - Parent: Comment block at (17:0,17 [13] )
+Markup span at (30:0,30 [13] ) - Parent: Markup block at (30:0,30 [20] )
+Markup span at (43:0,43 [6] ) - Parent: Markup block at (30:0,30 [20] )
+Markup span at (49:0,49 [1] ) - Parent: Markup block at (30:0,30 [20] )
+Markup span at (50:0,50 [3] ) - Parent: Tag block at (0:0,0 [53] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/AttributeAfterComment.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/AttributeAfterComment.stree.txt
new file mode 100644
index 00000000000..a7c66afe93f
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlAttributeTest/AttributeAfterComment.stree.txt
@@ -0,0 +1,47 @@
+RazorDocument - [0..53)::53 - []
+ MarkupBlock - [0..53)::53
+ MarkupElement - [0..53)::53
+ MarkupStartTag - [0..53)::53 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ MarkupAttributeBlock - [2..16)::14 - [ class="first"]
+ MarkupTextLiteral - [2..3)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [3..8)::5 - [class] - Gen
+ Text;[class];
+ Equals;[=];
+ MarkupTextLiteral - [9..10)::1 - ["] - Gen
+ DoubleQuote;["];
+ GenericBlock - [10..15)::5
+ MarkupLiteralAttributeValue - [10..15)::5 - [first]
+ MarkupTextLiteral - [10..15)::5 - [first] - Gen
+ Text;[first];
+ MarkupTextLiteral - [15..16)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTextLiteral - [16..17)::1 - [ ] - Gen
+ Whitespace;[ ];
+ RazorComment - [17..30)::13
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ comment ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupAttributeBlock - [30..50)::20 - [ data-value="second"]
+ MarkupTextLiteral - [30..31)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [31..41)::10 - [data-value] - Gen
+ Text;[data-value];
+ Equals;[=];
+ MarkupTextLiteral - [42..43)::1 - ["] - Gen
+ DoubleQuote;["];
+ GenericBlock - [43..49)::6
+ MarkupTextLiteral - [43..49)::6 - [second] - Gen
+ Text;[second];
+ MarkupTextLiteral - [49..50)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupMiscAttributeContent - [50..51)::1
+ MarkupTextLiteral - [50..51)::1 - [ ] - Gen
+ Whitespace;[ ];
+ ForwardSlash;[/];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.cspans.txt
new file mode 100644
index 00000000000..adc84df169a
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.cspans.txt
@@ -0,0 +1,2 @@
+Markup span at (19:1,15 [4] ) - Parent: Tag block at (0:0,0 [63] )
+Markup span at (57:3,14 [2] ) - Parent: Tag block at (0:0,0 [63] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.stree.txt
new file mode 100644
index 00000000000..07ed19732c6
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.stree.txt
@@ -0,0 +1,45 @@
+RazorDocument - [0..63)::63 - [LF]
+ MarkupBlock - [0..63)::63
+ MarkupTagHelperElement - [0..63)::63 - p[StartTagAndEndTag] - PTagHelper
+ MarkupTagHelperStartTag - [0..57)::57 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ MarkupTagHelperAttribute - [2..24)::22 - attribute-1 - DoubleQuotes - Bound - [LF attribute-1="true"]
+ MarkupTextLiteral - [2..6)::4 - [LF ] - Gen
+ NewLine;[LF];
+ Whitespace;[ ];
+ MarkupTextLiteral - [6..17)::11 - [attribute-1] - Gen
+ Text;[attribute-1];
+ Equals;[=];
+ MarkupTextLiteral - [18..19)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [19..23)::4
+ MarkupTextLiteral - [19..23)::4 - [true] - Gen
+ Text;[true];
+ MarkupTextLiteral - [23..24)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTextLiteral - [24..28)::4 - [LF ] - Gen
+ NewLine;[LF];
+ Whitespace;[ ];
+ RazorComment - [28..41)::13
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ visible ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupEphemeralTextLiteral - [41..43)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupMinimizedAttributeBlock - [43..56)::13 - [ not-visible]
+ MarkupTextLiteral - [43..45)::2 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [45..56)::11 - [not-visible] - Gen
+ Text;[not-visible];
+ CloseAngle;[>];
+ MarkupTextLiteral - [57..59)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupTagHelperEndTag - [59..63)::4 - []
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.tspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.tspans.txt
new file mode 100644
index 00000000000..c1795990c0d
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_AttributeAfterRazorComment.tspans.txt
@@ -0,0 +1 @@
+TagHelper span at (0:0,0 [63] ) - PTagHelper
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.cspans.txt
new file mode 100644
index 00000000000..206cd3ed238
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.cspans.txt
@@ -0,0 +1 @@
+Markup span at (13:0,13 [8] ) - Parent: Tag block at (0:0,0 [47] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.stree.txt
new file mode 100644
index 00000000000..ec052cdc574
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.stree.txt
@@ -0,0 +1,38 @@
+RazorDocument - [0..47)::47 - []
+ MarkupBlock - [0..47)::47
+ MarkupTagHelperElement - [0..47)::47 - input[SelfClosing] - InputTagHelper
+ MarkupTagHelperStartTag - [0..47)::47 - [] - Gen
+ OpenAngle;[<];
+ Text;[input];
+ MarkupTagHelperAttribute - [6..22)::16 - type - DoubleQuotes - Bound - [ type="checkbox"]
+ MarkupTextLiteral - [6..7)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [7..11)::4 - [type] - Gen
+ Text;[type];
+ Equals;[=];
+ MarkupTextLiteral - [12..13)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [13..21)::8
+ MarkupTextLiteral - [13..21)::8 - [checkbox] - Gen
+ Text;[checkbox];
+ MarkupTextLiteral - [21..22)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTextLiteral - [22..23)::1 - [ ] - Gen
+ Whitespace;[ ];
+ RazorComment - [23..36)::13
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ comment ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupMinimizedTagHelperAttribute - [36..44)::8 - checked - Minimized - Bound - [ checked]
+ MarkupTextLiteral - [36..37)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [37..44)::7 - [checked] - Gen
+ Text;[checked];
+ MarkupMiscAttributeContent - [44..45)::1
+ MarkupTextLiteral - [44..45)::1 - [ ] - Gen
+ Whitespace;[ ];
+ ForwardSlash;[/];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.tspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.tspans.txt
new file mode 100644
index 00000000000..954aa78dc5e
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MinimizedAttributeAfterRazorComment.tspans.txt
@@ -0,0 +1 @@
+TagHelper span at (0:0,0 [47] ) - InputTagHelper
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.cspans.txt
new file mode 100644
index 00000000000..20c83fa23b2
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.cspans.txt
@@ -0,0 +1,3 @@
+Markup span at (11:0,11 [5] ) - Parent: Tag block at (0:0,0 [67] )
+Markup span at (40:0,40 [6] ) - Parent: Tag block at (0:0,0 [67] )
+Markup span at (56:0,56 [5] ) - Parent: Tag block at (0:0,0 [67] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.stree.txt
new file mode 100644
index 00000000000..4dc635f6069
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.stree.txt
@@ -0,0 +1,60 @@
+RazorDocument - [0..67)::67 - []
+ MarkupBlock - [0..67)::67
+ MarkupTagHelperElement - [0..67)::67 - p[StartTagAndEndTag] - PTagHelper
+ MarkupTagHelperStartTag - [0..63)::63 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ MarkupTagHelperAttribute - [2..17)::15 - attr-1 - DoubleQuotes - Bound - [ attr-1="first"]
+ MarkupTextLiteral - [2..3)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [3..9)::6 - [attr-1] - Gen
+ Text;[attr-1];
+ Equals;[=];
+ MarkupTextLiteral - [10..11)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [11..16)::5
+ MarkupTextLiteral - [11..16)::5 - [first] - Gen
+ Text;[first];
+ MarkupTextLiteral - [16..17)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTextLiteral - [17..18)::1 - [ ] - Gen
+ Whitespace;[ ];
+ RazorComment - [18..31)::13
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ comment ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupTagHelperAttribute - [31..47)::16 - attr-2 - DoubleQuotes - Bound - [ attr-2="second"]
+ MarkupTextLiteral - [31..32)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [32..38)::6 - [attr-2] - Gen
+ Text;[attr-2];
+ Equals;[=];
+ MarkupTextLiteral - [39..40)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [40..46)::6
+ MarkupTextLiteral - [40..46)::6 - [second] - Gen
+ Text;[second];
+ MarkupTextLiteral - [46..47)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttribute - [47..62)::15 - attr-3 - DoubleQuotes - Bound - [ attr-3="third"]
+ MarkupTextLiteral - [47..48)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [48..54)::6 - [attr-3] - Gen
+ Text;[attr-3];
+ Equals;[=];
+ MarkupTextLiteral - [55..56)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [56..61)::5
+ MarkupTextLiteral - [56..61)::5 - [third] - Gen
+ Text;[third];
+ MarkupTextLiteral - [61..62)::1 - ["] - Gen
+ DoubleQuote;["];
+ CloseAngle;[>];
+ MarkupTagHelperEndTag - [63..67)::4 - [
]
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.tspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.tspans.txt
new file mode 100644
index 00000000000..ef555c6c2fd
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleAttributesAfterRazorComment.tspans.txt
@@ -0,0 +1 @@
+TagHelper span at (0:0,0 [67] ) - PTagHelper
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.cspans.txt
new file mode 100644
index 00000000000..cb21d41e420
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.cspans.txt
@@ -0,0 +1,2 @@
+Markup span at (28:0,28 [4] ) - Parent: Tag block at (0:0,0 [79] )
+Markup span at (56:0,56 [4] ) - Parent: Tag block at (0:0,0 [79] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.stree.txt
new file mode 100644
index 00000000000..5c0787eb390
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.stree.txt
@@ -0,0 +1,62 @@
+RazorDocument - [0..79)::79 - []
+ MarkupBlock - [0..79)::79
+ MarkupTagHelperElement - [0..79)::79 - input[SelfClosing] - InputTagHelper
+ MarkupTagHelperStartTag - [0..79)::79 - [] - Gen
+ OpenAngle;[<];
+ Text;[input];
+ MarkupTextLiteral - [6..7)::1 - [ ] - Gen
+ Whitespace;[ ];
+ RazorComment - [7..21)::14
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ comment1 ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupTagHelperAttribute - [21..33)::12 - type - DoubleQuotes - Bound - [ type="text"]
+ MarkupTextLiteral - [21..22)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [22..26)::4 - [type] - Gen
+ Text;[type];
+ Equals;[=];
+ MarkupTextLiteral - [27..28)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [28..32)::4
+ MarkupTextLiteral - [28..32)::4 - [text] - Gen
+ Text;[text];
+ MarkupTextLiteral - [32..33)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTextLiteral - [33..34)::1 - [ ] - Gen
+ Whitespace;[ ];
+ RazorComment - [34..48)::14
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ comment2 ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupTagHelperAttribute - [48..61)::13 - value - DoubleQuotes - Bound - [ value="test"]
+ MarkupTextLiteral - [48..49)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [49..54)::5 - [value] - Gen
+ Text;[value];
+ Equals;[=];
+ MarkupTextLiteral - [55..56)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTagHelperAttributeValue - [56..60)::4
+ MarkupTextLiteral - [56..60)::4 - [test] - Gen
+ Text;[test];
+ MarkupTextLiteral - [60..61)::1 - ["] - Gen
+ DoubleQuote;["];
+ MarkupTextLiteral - [61..62)::1 - [ ] - Gen
+ Whitespace;[ ];
+ RazorComment - [62..76)::14
+ RazorCommentTransition;[@];
+ RazorCommentStar;[*];
+ RazorCommentLiteral;[ comment3 ];
+ RazorCommentStar;[*];
+ RazorCommentTransition;[@];
+ MarkupMiscAttributeContent - [76..77)::1
+ MarkupTextLiteral - [76..77)::1 - [ ] - Gen
+ Whitespace;[ ];
+ ForwardSlash;[/];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.tspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.tspans.txt
new file mode 100644
index 00000000000..607765625ef
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperBlockRewriterTest/TagHelper_MultipleInterleavedRazorComments.tspans.txt
@@ -0,0 +1 @@
+TagHelper span at (0:0,0 [79] ) - InputTagHelper
diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TagHelperBlockRewriter.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TagHelperBlockRewriter.cs
index d1cb2fdd148..debec884d2a 100644
--- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TagHelperBlockRewriter.cs
+++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/TagHelperBlockRewriter.cs
@@ -133,6 +133,26 @@ public static MarkupTagHelperStartTagSyntax Rewrite(
result = null;
}
+ else if (child is RazorCommentBlockSyntax razorComment)
+ {
+ // Razor comments in attribute lists should be preserved but not treated as attributes.
+ // Continue processing subsequent attributes.
+ attributeBuilder.Add(razorComment);
+ continue;
+ }
+ else if (child is MarkupTextLiteralSyntax textLiteral)
+ {
+ // Whitespace between attributes should be preserved but not treated as attributes.
+ // Continue processing subsequent attributes.
+ var content = textLiteral.GetContent();
+ if (string.IsNullOrWhiteSpace(content))
+ {
+ attributeBuilder.Add(textLiteral);
+ continue;
+ }
+
+ result = null;
+ }
else
{
result = null;