Skip to content

Commit

Permalink
Comments added.
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnetjunkie committed Feb 22, 2021
1 parent 692d360 commit e784a93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/SimpleInjector/Internals/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>WARNING: Only returns properties of the given type; NOT its base types.</summary>
public static PropertyInfo[] GetProperties(this Type type) => type.GetTypeInfo().DeclaredProperties.ToArray();
public static Guid GetGuid(this Type type) => type.GetTypeInfo().GUID;

Expand Down
3 changes: 3 additions & 0 deletions src/SimpleInjector/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ internal static IEnumerable<Type> 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<Type> GetBaseTypes(this Type type)
{
Type? baseType = type.BaseType() ?? (type != typeof(object) ? typeof(object) : null);
Expand Down

0 comments on commit e784a93

Please sign in to comment.