Runtime: Move JsonSerializer to the root namespace - System.Text.Json

Created on 23 May 2019  路  8Comments  路  Source: dotnet/runtime

Motivation:
Since JsonSerializer is the more commonly used API, move it to the root namespace. This means move JsonSerializer and JsonSerializerOptions into the root namespace, System.Text.Json:

Proposed API surface:
https://github.com/dotnet/corefx/blob/510ab9e6433ff0df29e0ae080140f4f2c1b69abd/src/System.Text.Json/ref/System.Text.Json.cs#L349

namespace System.Text.Json
JsonCommentHandling
JsonDocument
JsonElement
JsonEncodedText
JsonException
JsonProperty
JsonReaderOptions
JsonReaderState
JsonTokenType
JsonValueType
JsonWriterOptions
Utf8JsonReader
Utf8JsonWriter 
+ JsonNamingPolicy
+ JsonSerializer
+ JsonSerializerOptions

System.Text.Json.Serialization
JsonAttribute 
JsonExtensionDataAttribute 
JsonIgnoreAttribute 
- JsonNamingPolicy
JsonPropertyNameAttribute 
- JsonSerializer
- JsonSerializerOptions

Questions:
1) Rename System.Text.Json.Serialization to something to indicate "extensibility". Maybe Converters given we plan to add JsonConverter there? Custom?
2) Should we move reader/writer to a nested namespace?

cc @steveharter

api-approved area-System.Text.Json easy

Most helpful comment

Per offline discussion, I agree with this concern. However since we already have a mix of physical folders and namespaces that don't align we should refactor all of this after the usability studies and when we know the namespaces are correct (if we agree it makes sense to do that at that time).

Otherwise it just adds short-team overhead and the possibility of additional file moves.

All 8 comments

Keep the nested namespace as root.Serialization.

P.S. This was written by @ahsonkhan (on Ryan's machine).

For the three file moves let's be sure to coordinate with other active PRs and be sure to preserve git history.

I can't help to think that this should me more in pair with XML.

For starters, it should be System.Json and System.Json.Serialization as it is System.Xml and System.Xml.Serialization and so on.

@ahsonkhan should we move the internal types used by the JsonSerializer to System.Text.Json namespace ?

should we move the internal types used by the JsonSerializer to System.Text.Json namespace ?

I would say yes, but just confirm with @steveharter.

Should we move the internal types used by the JsonSerializer to System.Text.Json namespace ?

Sure.

For the three file moves let's be sure to coordinate with other active PRs and be sure to preserve git history.

Actually, I don't think we want to physically move any files in the repo. The reader\writer\document all have their own directories even though they are in the root System.Text.Json namespace.

The reader\writer\document all have their own directories even though they are in the root System.Text.Json namespace.

All the files in reader\writer\document are in the same namespace. If we dont move the files, some of the files\classes will be in System.Text.Json and some System.Text.Json.Serialization

Per offline discussion, I agree with this concern. However since we already have a mix of physical folders and namespaces that don't align we should refactor all of this after the usability studies and when we know the namespaces are correct (if we agree it makes sense to do that at that time).

Otherwise it just adds short-team overhead and the possibility of additional file moves.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omajid picture omajid  路  3Comments

bencz picture bencz  路  3Comments

EgorBo picture EgorBo  路  3Comments

yahorsi picture yahorsi  路  3Comments

jzabroski picture jzabroski  路  3Comments