Update the static driver sample code to detect Context properties of type IEnumerable<T>.
The UniversalStaticDriver class does not detect the properties of the customType parameter that are directly of type IEnumerable<T>. If the customType inherits IEnumerable<T> (like say via IList<T>) then the property is detected. But if the property is actually declared as IEnumerable<T> then it is passed over.
I changed the line that declared ienumerableOfT from:
let ienumerableOfT = prop.PropertyType.GetInterface ("System.Collections.Generic.IEnumerable`1")
where ienumerableOfT != null
to
let ienumerableOfT = (prop.PropertyType.GetGenericTypeDefinition() == typeof(IEnumerable<>) ? prop.PropertyType : null)
?? prop.PropertyType.GetInterface("System.Collections.Generic.IEnumerable`1")
Kinda hacky, but it fixed the problem for me. Probably a better solution would be to recurse through the type and all inherited types till an IEnumerable<T> is found.
-
Josh Buedel commented
The greater and less thans were stripped from my submission. In the first paragraph all mentions of IEnumerable should be IEnumerable lt T gt. (And IEnumerable with a single type parameter).