Skip to content

Conversation

@steveharter
Copy link
Contributor

Addresses #57836 for main; will be ported to release\60.

Test changes:

  • No tests were removed
  • One new test: PropertyNameTests.SpecialCharacters().
  • Most tests in /Serialization/PropertyNameTests.cs were 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.
  • The source gen test project now runs the tests in /Common/PropertyNameTests.cs against the source-gen'd context. These continue to also run the reflection-based serializer.

@ghost
Copy link

ghost commented Aug 24, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Addresses #57836 for main; will be ported to release\60.

Test changes:

  • No tests were removed
  • One new test: PropertyNameTests.SpecialCharacters().
  • Most tests in /Serialization/PropertyNameTests.cs were 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.
  • The source gen test project now runs the tests in /Common/PropertyNameTests.cs against the source-gen'd context. These continue to also run the reflection-based serializer.
Author: steveharter
Assignees: steveharter
Labels:

area-System.Text.Json

Milestone: 6.0.0

foreach (string propName in _currentContext.RuntimePropertyNames)
foreach (KeyValuePair<string, string> name_varName_pair in _currentContext.RuntimePropertyNames)
{
sb.Append($@"
Copy link
Member

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?

Copy link
Contributor Author

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_";
Copy link
Contributor Author

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.

@steveharter steveharter merged commit ab02bf6 into dotnet:main Aug 24, 2021
@steveharter steveharter deleted the SrcGenSpecialChars branch August 24, 2021 22:37
@steveharter
Copy link
Contributor Author

/backport to release/6.0-rc1

@github-actions
Copy link
Contributor

Started backporting to release/6.0-rc1: https://github.com/dotnet/runtime/actions/runs/1164424729

@ghost ghost locked as resolved and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants