Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyV

private CacheEntry CreateCacheEntry(Type type)
{
var ti = type.GetTypeInfo();
var classDestructurer = ti.GetCustomAttribute<ITypeDestructuringAttribute>();
var classDestructurer = type.GetCustomAttribute<ITypeDestructuringAttribute>();
if (classDestructurer != null)
return new(classDestructurer.CreateLogEventPropertyValue);

Expand Down
2 changes: 1 addition & 1 deletion src/Destructurama.Attributed/Util/AttributeFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Destructurama.Util;

internal static class AttributeFinder
{
public static T GetCustomAttribute<T>(this TypeInfo typeInfo) =>
public static T GetCustomAttribute<T>(this Type typeInfo) =>
typeInfo.GetCustomAttributes().OfType<T>().FirstOrDefault();

public static T GetCustomAttribute<T>(this PropertyInfo propertyInfo) =>
Expand Down
9 changes: 3 additions & 6 deletions src/Destructurama.Attributed/Util/GetablePropertyFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ public static IEnumerable<PropertyInfo> GetPropertiesRecursive(this Type type)
{
var seenNames = new HashSet<string>();

var currentTypeInfo = type.GetTypeInfo();

while (currentTypeInfo.AsType() != typeof(object))
while (type != typeof(object))
{
var unseenProperties = currentTypeInfo.DeclaredProperties
var unseenProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
.Where(p => p.CanRead &&
p.GetMethod.IsPublic &&
!p.GetMethod.IsStatic &&
(p.Name != "Item" || p.GetIndexParameters().Length == 0) &&
!seenNames.Contains(p.Name));

Expand All @@ -39,7 +36,7 @@ public static IEnumerable<PropertyInfo> GetPropertiesRecursive(this Type type)
yield return propertyInfo;
}

currentTypeInfo = currentTypeInfo.BaseType.GetTypeInfo();
type = type.BaseType;
}
}
}