Previously I could use this to get the generic types on a class;
typeof(MyClass).GetTypeInfo().DeclaredProperties.Any(p => p.PropertyType.IsGenericType)
However, in DNX Core 5.0, IsGenericType
is not supported. What can I use now?
Just looked through some source here that confirms there is still a IsGenericType property in the framework.
https://github.com/aspnet/Common/blob/dev/src/Microsoft.Framework.ClosedGenericMatcher.Sources/ClosedGenericMatcher.cs#L44
Does the following work?
typeof(MyClass).GetTypeInfo().DeclaredProperties.Any(p => p.PropertyType.GetTypeInfo().IsGenericType)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With