Skip to content

Commit

Permalink
Delegates Cache Fix
Browse files Browse the repository at this point in the history
- Fixed issue in the delegates cache that purges delegates of objects.
  • Loading branch information
Jan Discart committed Jul 20, 2022
1 parent 22eb53a commit 38470a3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,20 @@ private static List<FieldInfo> GetDelegatesForType(Type type)

// Find all delegate fields through the type hierarchy.
List<FieldInfo> delegates = new List<FieldInfo>();
while ((type != null) && (type != typeof(object)))
Type typeIt = type;
while ((typeIt != null) && (typeIt != typeof(object)))
{
FieldInfo[] fields = type.GetFields(flags);
FieldInfo[] fields = typeIt.GetFields(flags);

foreach (FieldInfo field in fields)
{
if ((field.DeclaringType == type) && delegateType.IsAssignableFrom(field.FieldType))
if ((field.DeclaringType == typeIt) && delegateType.IsAssignableFrom(field.FieldType))
{
delegates.Add(field);
}
}

type = type.BaseType;
typeIt = typeIt.BaseType;
}

return delegateCache.GetOrAdd(type, delegates);
Expand Down

0 comments on commit 38470a3

Please # to comment.