Fix @@ escape handling in component attribute values#12754
Draft
Fix @@ escape handling in component attribute values#12754
@@ escape handling in component attribute values#12754Conversation
The issue was that @@ escape sequences were being parsed correctly but then treated as "complex content" during code generation, causing them to fail when used in component attributes. The fix modifies the VisitAttributeValue method to extract the literal @ token from the escaped @@ pattern and merge it with the rest of the attribute value as a simple string, rather than creating separate HTML content nodes. This allows component attributes to accept literal @ characters using the @@ escape syntax, e.g. <Weather Value="@@currentCount" /> now correctly passes the string "@currentCount" to the component. Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
The fix for @@ escape handling changed how source positions are tracked for escaped @ tokens in attribute values. The ComplexTagHelpers test baselines needed to be updated to reflect the new positions. Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix @@ escape in Razor component attribute values
Fix Feb 6, 2026
@@ escape handling in component attribute values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the changes
@@escape sequences now work consistently in component attribute values. Previously worked in HTML content but failed in component attributes with "complex content not supported" error.Root cause: During IR lowering,
@@created separate markup nodes that triggered the complex content validator. The ephemeral second@token wasn't being properly merged.Changes:
VisitAttributeValue()inDefaultRazorIntermediateNodeLoweringPhase.csto extract literal@tokens from@@patterns and merge them into the attribute value string before creating IR nodesExample:
Test updates:
ComplexTagHelpersbaseline (source position tracking changed)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
bcnvsblobprodcus378.vsblob.vsassets.io/usr/share/dotnet/dotnet dotnet test src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor.Language.Test.csproj --filter FullyQualifiedName~HtmlAttributeTest.EscapedAttributeValue --no-build --no-restore de/node/bin/grep stBase.*{ rPresentationPar-l rep grep -l stBase.*{ ation/MessagePack/Formatters/CachedStringFormatter.cs nfig/composer/vendor/bin/grep stBase.*{ ationParams.cs de/node/bin/grepabstract.*class.*ParserTestBase\|class.*ParserTestBase.*{ grep(dns block)/usr/share/dotnet/dotnet dotnet test src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor.Language.Test.csproj --filter FullyQualifiedName~HtmlAttributeTest.EscapedAttributeValue --no-restore ation/FetchTagHe--projects /home/REDACTED/.cosrc/Compiler/Microsoft.AspNetCore.Razor.Language/test/Microsoft.AspNetCore.Razor--noprofile stBase.*{ Service.cs k/_temp/ghcca-no.tools | has("runtimes") grep -l stBase.*{ kspaces/Serialization/MessagePack/Formatters/TagHelpers/ComponentMetadataFormatter.cs rep stBase.*{ r.cs /home/REDACTED/.co--restore grep(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.