-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserializing to a custom model containing an IEnumerable<sometype> #75
Comments
@xoofx Did you have something like this in mind?
It works well enough for my use case, I am just not sure whether |
Yep
That's ok, I think that using PR welcome, there are currently not so many tests, so you will have likely to add one to cover this specific case. |
I had pretty much this issue, using an array as the property type: Old:
A workaround is to provide a non-null List:
|
That's not a good idea — when writing interfaces you want to use as generic as possible types in the interface definition (hence the |
Please consider this code sample:
And this TOML file:
Should this be possible to deserialize or not?
Currently it doesn't work (the error I get is
error : Unexpected error when creating object for property Items on object type TestNamespace.Test. Reason: Cannot create an instance of an interface.
which is expected because interfaces cannot be instantiated).The reason why I use
IEnumerable
instead of sayList
is to keep datatypes as generic as possible (they are used in an interface definition which shouldn't care what the actual type is as long as it has IEnumerable implementation).Is there some workaround for this without changing the datatype?
Note that Newtonsoft.Json has no problem deserializing to those IEnumerable properties.
The text was updated successfully, but these errors were encountered: