fastBinaryJSON icon indicating copy to clipboard operation
fastBinaryJSON copied to clipboard

Added support for deserializing properties/fields of collection interfaces

Open rbeurskens opened this issue 7 years ago • 8 comments

rbeurskens avatar Aug 18 '17 14:08 rbeurskens

Thanks!

Personally I would cache the MakeGenericType since it is a performance hog, have you tested the performance?

mgholam avatar Aug 18 '17 15:08 mgholam

No, not yet. I will take a look at the performance next week.

rbeurskens avatar Aug 18 '17 18:08 rbeurskens

Did you get any timing difference?

mgholam avatar Aug 21 '17 11:08 mgholam

Also instead of Tuple try using a struct

mgholam avatar Aug 21 '17 11:08 mgholam

In my own project I'm using C#7 System.ValueTuple (which is a struct), but I don't know what the minimum c# / .net version is that should be supported. I found that with some additions, it could work for .NET 4.0, but I'm not sure about IDE support. I'll just add a custom struct instead to be sure I'm not using language features that are 'too new'.

rbeurskens avatar Aug 21 '17 12:08 rbeurskens

(I have not tested if caching improves performance, but I'm quite confident a dictionary lookup will be faster than repeated calls to MakeGenericType. However, it will only make a difference when the type is used more than once, of course. I could also make the dictionary creation lazy, as it won't always be used. )

rbeurskens avatar Aug 21 '17 15:08 rbeurskens

Note: ~~there's still a bug when deserializing ISet<T>: An instance of List<T> is used, bypassing the type system as IL is used in the setter, causing EntryPointNotFoundException to be thrown when accessing members of ISet<T>. (also none of the ISet<T> implementations are supported such as HashSet<T> and OrderedSet<T> )~~ Edit: this is now resolved with commit e015487

rbeurskens avatar Oct 16 '17 11:10 rbeurskens

Sorry for the delay in resolving the conflicts. I switched jobs in the meantime and just found I had something unfinished. (I could not test if my changes still work after any changes on master in the meantime, but I did my best adjusting it just looking at the code )

rbeurskens avatar Aug 13 '20 06:08 rbeurskens