Skip to content

Commit

Permalink
Be more resilient against invalid metadata in fields (#99944)
Browse files Browse the repository at this point in the history
Addresses some of the problems seen in #99580.

We already check methods and types are loadable. Should do the same for fields.
  • Loading branch information
MichalStrehovsky committed Mar 19, 2024
1 parent be76968 commit 8fbfb32
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ public static bool TryGetDependenciesForReflectedField(ref DependencyList depend
((MetadataType)owningType).MakeInstantiatedType(inst));
}

try
{
// Make sure we're not putting something into the graph that will crash later.
factory.TypeSystemContext.EnsureLoadableType(field.FieldType);
}
catch (TypeSystemException)
{
return false;
}

dependencies.Add(factory.ReflectedField(field), reason);

return true;
Expand Down

0 comments on commit 8fbfb32

Please sign in to comment.