RicoSuter / Namotion.Reflection

.NET library with advanced reflection APIs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Overloaded GetEnumerator

ryanwilliams83 opened this issue · comments

I'm trying to use JsonSchema.FromType<System.DirectoryServices.AccountManagement.UserPrincipal>()
but it's throwing an InvalidOperationException.

I suspect the reason is that ArrayList.GetEnumerator has an overload which is not working with
https://github.com/RicoSuter/Namotion.Reflection/blob/master/src/Namotion.Reflection/Context/ContextualType.cs#L146

I don't fully understand your code but I'd like to suggest the following possible solution
var getEnumeratorMethod = Methods.SingleOrDefault(m => m.Name == "GetEnumerator" && m.Parameters.Length == 0);