Then l195/197 could be changed accordingly. The only thing I'm a bit dubious on is the where constraint, I've a feeling it would let a Dictionary<T, V> through, and then BuildList would fail. So the constraint might not be necessary, and the test would have to be on l195 instead.private T BuildList<T>(T type, JEnumerable<JToken> elements) where T : IEnumerable<T>{var list = Activator.CreateInstance<T>();var itemType = type.GetGenericArguments()[0];
List<Product> products = JsonConvert.DeserializeObject<List<Product>>(json);As to why Rest# doesn't use this, I'm not sure. I remember submitting a patch that was to do with deserializing into a generic list several months ago... perhaps I overlooked the capabilities of json.net at the time. Or it could be for another reason. When I get chance I'll write some unit tests and dig into it. Maybe John will have a more definite answer.
If I recall correctly it's based off of List because IEnumerable does
not have an Add() method and I didn't spend any time trying to figure
out how to get around that. I think IList<> would work (and that's
really how it should be) but beyond that, I'm happy to take
suggestions to make it more flexible.