私は次のことを確認しようとしています
typeof( ICollection<> ).GetTypeInfo().IsAssignableFrom( targetProperty.PropertyType.GetTypeInfo() )
に渡される引数IsAssignableFrom
はIList<Something>
. しかし、それはfalseを返しています。
以下も false を返します。
typeof( ICollection<> ).GetTypeInfo().IsAssignableFrom( targetProperty.PropertyType.GetTypeInfo().GetGenericTypeDefinition() )
以下でもfalseを返しています。
typeof( ICollection<> ).GetTypeInfo().IsAssignableFrom( typeof(IList<>) )
後者は間違いなく true を返すべきではありませんか?
targetProperty.PropertyType
任意のタイプになる可能性がある場合、どうすれば正しい結果を得ることができますか? 、List<T>
、ObservableCollection<T>
、ReadOnlyCollection<T>
カスタム コレクション タイプなどです。