applejag/Newtonsoft.Json-for-Unity

Suggestion: AOTHelper methods with type parameter

hhhmmmmmm opened this issue · 1 comments

https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Reference-Newtonsoft.Json.Utilities.AotHelper

It would be nice to have AOTHelper methods with Type parameter in addition to the generic version. My use case is I have a collection of types, and I want to ensure lists exist for every one of them, so calling EnsureList(Type type) instead of EnsureList() would be better in this situation.

Nice work, by the way! I'm glad to have found this.

I'm sorry to say that this cannot be done :(

The AotHelper works just because it's generic. It's magic comes from tricking the compiler on generating the types specified from the generic type parameter. Something that cannot be done with regular type parameters.

You will have to specify all the types that will be used explicitly via the AotHelper or via link.xml.