-
Notifications
You must be signed in to change notification settings - Fork 233
Add test validating current behavior for extra parenthesis in Blazor attribute bindings #12690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: dbreshears <3432571+dbreshears@users.noreply.github.com>
Co-authored-by: dbreshears <3432571+dbreshears@users.noreply.github.com>
|
@copilot update the test so that instead of failing it just validates the current behavior. |
|
This is valid razor and C# but ends up with invalid HTML. We should add an analyzer that attempts to detect these scenarios and warns when the resulting expression is not valid HTML. |
Changed AttributeBinding_ExtraClosingParenthesis test to document and validate the current behavior where extra parenthesis is treated as literal text. Test now passes with Assert.Empty instead of expecting diagnostics. Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
Updated the test to validate current behavior. The test now passes by asserting that no diagnostics are generated ( 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Isn't this "mixed content", which isn't allowed in attributes? I would have thought the existing diagnostic would catch this. |
Summary of the changes
Added a regression test for dotnet/aspnetcore#23228 where an extra closing parenthesis in a Blazor attribute binding causes silent runtime errors without compilation diagnostics.
The Bug:
The Razor compiler treats the extra
)as literal text and generates:This produces syntactically valid C# that concatenates a boolean with
")", resulting in attribute values like"True)"instead oftrue. The UI state becomes out of sync with the component state, but no error is reported at compile or runtime.Test Added:
ComponentDiagnosticRazorIntegrationTest.csAttributeBinding_ExtraClosingParenthesis_TreatedAsLiteralTextThe test validates that
generated.RazorDiagnosticsis empty, confirming the current behavior where the compiler treats the extra parenthesis as literal text rather than reporting a diagnostic error.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.