diff --git a/src/SimpleInjector/Internals/ReflectionExtensions.cs b/src/SimpleInjector/Internals/ReflectionExtensions.cs index f96ada5b7..1f7b3dafd 100644 --- a/src/SimpleInjector/Internals/ReflectionExtensions.cs +++ b/src/SimpleInjector/Internals/ReflectionExtensions.cs @@ -40,6 +40,8 @@ public static Type[] GetGenericArguments(this Type type) => type.GetTypeInfo().I public static bool IsGenericParameter(this Type type) => type.GetTypeInfo().IsGenericParameter; public static GenericParameterAttributes GetGenericParameterAttributes(this Type type) => type.GetTypeInfo().GenericParameterAttributes; public static Assembly GetAssembly(this Type type) => type.GetTypeInfo().Assembly; + + /// WARNING: Only returns properties of the given type; NOT its base types. public static PropertyInfo[] GetProperties(this Type type) => type.GetTypeInfo().DeclaredProperties.ToArray(); public static Guid GetGuid(this Type type) => type.GetTypeInfo().GUID; diff --git a/src/SimpleInjector/Types.cs b/src/SimpleInjector/Types.cs index 9de62bd34..5f0469aeb 100644 --- a/src/SimpleInjector/Types.cs +++ b/src/SimpleInjector/Types.cs @@ -225,6 +225,9 @@ internal static IEnumerable GetTypeBaseTypesAndInterfaces(this Type type) return thisType.Concat(type.GetBaseTypesAndInterfaces()); } + // TODO: There is some weird inconsistency in this method. In case supplied type derives directly + // from System.Object, typeof(object) is returned. But if the supplid type has a different base type, + // the result will not include typeof(object). private static IEnumerable GetBaseTypes(this Type type) { Type? baseType = type.BaseType() ?? (type != typeof(object) ? typeof(object) : null);