dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
738 stars 1.57k forks source link

JsonPropertyNameAttribute or JsonPropertyOrderAttribute? #10039

Open ygoe opened 5 months ago

ygoe commented 5 months ago

What does "JsonPropertyNameAttribute" do in that text?

And where is the documentation for this JsonPropertyOrderAttribute after all? I can't find it on that page. The text just states obvious things but with no word explains how to use this attribute.

.NET documentation isn't anymore what it used to be. Lots of gaps and missing explanations now.

dotnet-issue-labeler[bot] commented 5 months ago

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.

dotnet-issue-labeler[bot] commented 5 months ago

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.

elgonzo commented 5 months ago

What does "JsonPropertyNameAttribute" do in that text?

What text? You appear to refer to some documentation page, but you failed to mention which page you are referring to.

And where is the documentation for this JsonPropertyOrderAttribute after all?

Where all the documentation of all the types of the .NET BCL can be found, at https://learn.microsoft.com/en-us/dotnet/api, specifically https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonpropertyorderattribute

ygoe commented 5 months ago

Something must have gone wrong here. I clicked on the feedback link at the bottom of the page and usually this will be linked with the page I reported it from.

Here's the page: https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonpropertyorderattribute.-ctor?view=net-8.0&devlangs=csharp&f1url=%3FappId%3DDev17IDEF1%26l%3DEN-US%26k%3Dk(System.Text.Json.Serialization.JsonPropertyOrderAttribute.%2523ctor)%3Bk(DevLang-csharp)%26rd%3Dtrue

Meanwhile I found third-party information from others who have done some reverse-engineering. The default order value for all properties seems to be 0, also if unset. So to bring single properties to the top, they need to have negative numbers. This could have been mentioned somewhere with the documentation of that attribute.

elgonzo commented 5 months ago

This could have been mentioned somewhere with the documentation of that attribute.

It is mentioned in the attribute's documentation. Look at the documentation i linked to in my previous comment (https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonpropertyorderattribute), it says the following:

Specifies the property order that is present in the JSON when serializing. Lower values are serialized first. If the attribute is not specified, the default value is 0.

That said, i tend to agree that it would help to place this information also on the constructor's documentation page, because it is specifically about the constructor's order parameter.

dotnet-policy-service[bot] commented 4 months ago

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

eiriktsarpalis commented 4 months ago

That said, i tend to agree that it would help to place this information also on the constructor's documentation page, because it is specifically about the constructor's order parameter.

It's not something that we usually do for parameters if the corresponding concept is already documented on the type level. That being said, happy to review a PR that improves things.