dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

Missing example or documentation on the meaning of parameters of JsonPropertyInfo.Set delegate

Open vincent1405 opened this issue 1 year ago • 3 comments

Type of issue

Missing information

Description

I do not find the value corresponding to the two parameters of JsonPropertyInfo.Set delegate. I finally found that:

  • The first one is the instance being deserialized
  • The second one is the value of the JsonPropertyInfo property that will be set.

I think that an explanation could be useful. As an example, we could use:

jsonPropertyInfo.Set = (instance, propertyValue) =>
{
    instance.GetType().GetProperty(jsonPropertyInfo.Name)!.DeclaringType!.GetProperty(jsonPropertyInfo.Name)!.GetSetMethod(true)!.Invoke(instance, [propertyValue]);
};

I wrote it myself to call private setters on public properties.

Thank you

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.metadata.jsonpropertyinfo.set?view=net-9.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Text.Json.Serialization.Metadata/JsonPropertyInfo.xml

Document Version Independent Id

ffedbd9c-8ac4-1dee-863a-467e64ad5ff7

Article author

@dotnet-bot

vincent1405 avatar Jan 02 '25 11:01 vincent1405

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Jan 02 '25 11:01 ghost

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Jan 02 '25 11:01 ghost

Tagging subscribers to this area: @dotnet/area-system-text-json