Add ReferenceHandler to JsonSourceGenerationOptions - #109174
Conversation
|
Note regarding the |
1 similar comment
|
Note regarding the |
|
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
| => SourceGeneratorHelpers.FormatEnumLiteral(JsonSerializerDefaultsTypeRef, defaults); | ||
|
|
||
| private static string FormatReferenceHandler(JsonKnownReferenceHandler referenceHandler) | ||
| => SourceGeneratorHelpers.FormatEnumLiteral(ReferenceHandlerTypeRef, referenceHandler); |
There was a problem hiding this comment.
Not saying that this wouldn't work, but ReferenceHandler isn't technically an enum. It's a class with static properties, so perhaps different concerns apply to formatting it?
There was a problem hiding this comment.
The default value of the enum didn't map to a default reference handler in the first iteration of this PR. Updated the PR to handle this enum -> reference handler object conversion. Note that for the naming policy, we actually have the policy classes in the Common folder so nameof works there. I tried to see if I could also move ReferenceHandler to Common but it has a couple of dependencies so I just left it as it is instead of adding a bunch of types to Common. I just hardcoded the property names for this PR.
eiriktsarpalis
left a comment
There was a problem hiding this comment.
Left some feedback, but this looks great so far 👍
Adds a
ReferenceHandlerproperty toJsonSourceGenerationOptionsto allow users to specify how references are handled when generating source code for JSON types.Implements #107597