Skip to content
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

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

Open
vincent1405 opened this issue Jan 2, 2025 · 3 comments
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner

Comments

@vincent1405
Copy link

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

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 2, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 2, 2025
Copy link

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.

1 similar comment
Copy link

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.

@eiriktsarpalis eiriktsarpalis added area-System.Text.Json and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 7, 2025
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants