Uh oh!
There was an error while loading. Please reload this page.
Support deserialization for Struct properties that implements IList<T> - #41223
Conversation
Add a new field into IListOfTConverter class to store the values to prevent unboxing when the TCollection is ValueType.
Dotnet-GitSync-Bot
commented
Aug 23, 2020
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ion<T>, IList Use constraint type instead of TCollection to avoid unboxing when TCollection is ValueType.
…T>, IDictionary<TKey, TValue>, IDictionary Use constraint type to cast to avoid unboxing when the target type is ValueType
RaymondHuy
commented
Sep 4, 2020
Hi @layomia@steveharter I have updated my PR to resolve your comments. Are there anything else I can do to get this PR approved ? |
layomia
left a comment
There was a problem hiding this comment.
Thanks for the changes.
We also need to update the Add methods of the following converter types and add corresponding tests:
ICollectionOfTConverterIDictionaryConverterIDictionaryOfTKeyTValueConverterIListConverterIListOfTConverterISetOfTConverter
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Modify the 'Add' method to use actual type casting.
RaymondHuy
commented
Sep 25, 2020
@layomia I have just updated my PR. BenchmarkDotNet=v0.12.1.1405-nightly, OS=Windows 10.0.18363.1082 (1909/November2019Update/19H2)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET Core SDK=5.0.100-preview.7.20366.6
[Host] : .NET Core 5.0.0 (CoreCLR 5.0.20.36411, CoreFX 5.0.20.36411), X64 RyuJIT
Job-WVOCPJ : .NET Core 5.0 (CoreCLR 42.42.42.42424, CoreFX 42.42.42.42424), X64 RyuJIT
PowerPlanMode=00000000-0000-0000-0000-000000000000 Arguments=/p:DebugType=portable Toolchain=CoreRun IterationTime=250.0000 ms MaxIterationCount=20 MinIterationCount=15 WarmupCount=1 ArrayList
BinaryData
Dictionary_string, string
HashSet_String
HashTable
ImmutableDictionary_String, String
ImmutableSortedDictionary_String, String
IndexViewModel
Int32
LargeStructWithProperties
Location
LoginViewModel
MyEventListerViewModel
SimpleStructWithProperties
|
layomia
left a comment
There was a problem hiding this comment.
Thanks for sharing the benchmarks. The change is close to ready, I just have a few comments on the tests.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| } | ||
| { | ||
| GenericStructIDictionaryWrapper<string, string>? obj = JsonSerializer.Deserialize<GenericStructIDictionaryWrapper<string, string>?>("null"); |
There was a problem hiding this comment.
What happens when serializing a default instance of GenericStructIDictionaryWrapper<string, string>? Test this for GenericStructIListWrapper<int> as well.
- Serializing a default instance. - Deserializing a null json string.
RaymondHuy
commented
Sep 27, 2020
@layomia Thanks for your comments. I've updated my PR, can you check if it is satisfied ? |
Fixes#1998
Add a new field into IListOfTConverter class to store the values to prevent unboxing when the TCollection is ValueType.