Skip to content

fix: escape double quotes and line breaks on CSharp generation of default value of properties#6473

Merged
baywet merged 5 commits intomicrosoft:mainfrom
mchanyeechoy:fix-escape-double-quotes-and-line-breaks-on-cshar
May 13, 2025
Merged

fix: escape double quotes and line breaks on CSharp generation of default value of properties#6473
baywet merged 5 commits intomicrosoft:mainfrom
mchanyeechoy:fix-escape-double-quotes-and-line-breaks-on-cshar

Conversation

@mchanyeechoy
Copy link
Contributor

@mchanyeechoy mchanyeechoy commented Apr 16, 2025

This is a quick fix that escapes double quotes and line breaks from strings given.

fixes #6472

It is a bit of a hack since it seems like the parsing of properties at that point is already "unescaped" the values of the OpenApi document. This fix re-escapes the string that was unescaped, but only for characters that are invalid within a CSharp string.

Ideally there should be no need to re-escaping the string, since it seems like the OpenApiDocument object itself contains all the information.

2025-04-16-1744833352_devenv

Meanwhile the CodeClass.Properties has escaped everything:

2025-04-16-1744833400_devenv

@mchanyeechoy mchanyeechoy requested a review from a team as a code owner April 16, 2025 20:34
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

Can you also add a changelog entry please? (unreleased, changed)
Also, can you please sign the CLA (see the bots comment)

@mchanyeechoy
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Ubisoft"

@mchanyeechoy mchanyeechoy force-pushed the fix-escape-double-quotes-and-line-breaks-on-cshar branch from 0e45ac2 to 92562b8 Compare April 22, 2025 19:33
@mchanyeechoy mchanyeechoy requested a review from baywet April 24, 2025 15:30
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

@baywet baywet enabled auto-merge (squash) May 13, 2025 19:17
@baywet baywet merged commit 01777ce into microsoft:main May 13, 2025
450 of 458 checks passed
@mchanyeechoy mchanyeechoy deleted the fix-escape-double-quotes-and-line-breaks-on-cshar branch May 13, 2025 19:41
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.

CSharp client generation is wrongfully escaping characters from openapi file

3 participants