This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for types derived from supported BCL collections (#39001)
* Add support for types derived from supported BCL collections * Fix merge issues * Re-add commented-out tests * Address review comments
- Loading branch information
Showing
29 changed files
with
3,488 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...t.Json/src/System/Text/Json/Serialization/Converters/DefaultDerivedDictionaryConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections; | ||
|
||
namespace System.Text.Json.Serialization.Converters | ||
{ | ||
internal sealed class DefaultDerivedDictionaryConverter : JsonDictionaryConverter | ||
{ | ||
public override object CreateFromDictionary(ref ReadStack state, IDictionary sourceDictionary, JsonSerializerOptions options) | ||
{ | ||
JsonPropertyInfo collectionPropertyInfo = state.Current.JsonPropertyInfo; | ||
JsonPropertyInfo elementPropertyInfo = options.GetJsonPropertyInfoFromClassInfo(collectionPropertyInfo.ElementClassInfo, options); | ||
return elementPropertyInfo.CreateDerivedDictionaryInstance(collectionPropertyInfo, sourceDictionary, state.JsonPath, options); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...t.Json/src/System/Text/Json/Serialization/Converters/DefaultDerivedEnumerableConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections; | ||
|
||
namespace System.Text.Json.Serialization.Converters | ||
{ | ||
internal sealed class DefaultDerivedEnumerableConverter : JsonEnumerableConverter | ||
{ | ||
public override IEnumerable CreateFromList(ref ReadStack state, IList sourceList, JsonSerializerOptions options) | ||
{ | ||
JsonPropertyInfo collectionPropertyInfo = state.Current.JsonPropertyInfo; | ||
JsonPropertyInfo elementPropertyInfo = options.GetJsonPropertyInfoFromClassInfo(collectionPropertyInfo.ElementClassInfo, options); | ||
return elementPropertyInfo.CreateDerivedEnumerableInstance(collectionPropertyInfo, sourceList, state.JsonPath, options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.