dotnet / dotnet/dotnet-api-docs

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

Open
#10,799 3 comments 0 reactions 0 assignees View on GitHub
area-System.Text.Json untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### 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:
```csharp
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.