Skip to content

Fix escaping string literals#793

Merged
Arlodotexe merged 3 commits intomainfrom
user/sergiopedri/fix-string-escaping
Apr 14, 2026
Merged

Fix escaping string literals#793
Arlodotexe merged 3 commits intomainfrom
user/sergiopedri/fix-string-escaping

Conversation

@Sergio0694
Copy link
Copy Markdown
Member

Closes #788

Sergio0694 and others added 3 commits April 14, 2026 14:51
Use SyntaxFactory.Literal() to produce properly escaped C# string literals
for string default values in generated dependency property metadata, instead
of manually wrapping the value in quotes. The previous approach did not handle
special characters (eg. backslashes, quotes, newlines, tabs, null characters),
resulting in invalid generated code.

Fixes #788.

Co-authored-by: Copilot <[email protected]>
Add a data-driven test covering string default values with various special
characters including tabs, newlines, carriage returns, backslashes, quotes,
null characters, and combinations thereof. This validates that the generator
correctly emits properly escaped C# string literals for all these cases.

Co-authored-by: Copilot <[email protected]>
Update SingleProperty_String_WithNoCaching_WithDefaultValue to take both the
input literal and the expected output literal as separate parameters. Add test
cases using verbatim string literals as input, verifying that the generator
correctly normalizes them to regular escaped string literals in the output.
This covers the @"C:\Users\Test" scenario from issue #788.

Co-Authored-By: Copilot <[email protected]>
Copy link
Copy Markdown
Member

@Arlodotexe Arlodotexe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and approved, easy fix and great test coverage.

@Arlodotexe Arlodotexe merged commit ec21c94 into main Apr 14, 2026
24 checks passed
@Arlodotexe Arlodotexe deleted the user/sergiopedri/fix-string-escaping branch April 14, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DependencyPropertyGenerator] string bug

2 participants