-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Support special characters in [JsonPropertyName] #58054
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
Conversation
|
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsAddresses #57836 for Test changes:
|
src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs
Outdated
Show resolved
Hide resolved
| foreach (string propName in _currentContext.RuntimePropertyNames) | ||
| foreach (KeyValuePair<string, string> name_varName_pair in _currentContext.RuntimePropertyNames) | ||
| { | ||
| sb.Append($@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also emit an XML comment declaring the unencoded form?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open on this. We could add the first occurrence easily. Also discussed in the future options in the bottom of #57836 (comment).
|
|
||
| private static string DeterminePropNameVarName(string runtimePropName) | ||
| { | ||
| const string PropName = "PropName_"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this now uses a prefix literal instead of a postfix. The reason is that the hex format may start with a number, which is not a valid identifier in C#.
Also an underscore was added. I think it is more readable that way.
|
/backport to release/6.0-rc1 |
|
Started backporting to release/6.0-rc1: https://github.com/dotnet/runtime/actions/runs/1164424729 |
Addresses #57836 for
main; will be ported torelease\60.Test changes:
PropertyNameTests.SpecialCharacters()./Serialization/PropertyNameTests.cswere moved to/Common/PropertyNameTests.cs. There were some "extension property tests" were moved to/Serialization/ExtensionDataTests.cs. These do not work with source-gen yet./Common/PropertyNameTests.csagainst the source-gen'd context. These continue to also run the reflection-based serializer.