{
// Runtime reflection stack needs to obtain the type handle of the field
// (but there's no type handles for function pointers)
- TypeDesc fieldTypeToCheck = _field.FieldType;
- while (fieldTypeToCheck.IsParameterizedType)
- fieldTypeToCheck = ((ParameterizedType)fieldTypeToCheck).ParameterType;
+ static bool ContainsFunctionPointers(TypeDesc type)
+ {
+ if (type.IsParameterizedType)
+ return ContainsFunctionPointers(((ParameterizedType)type).ParameterType);
+ foreach (TypeDesc instArg in type.Instantiation)
+ if (ContainsFunctionPointers(instArg))
+ return true;
+ return type.IsFunctionPointer;
+ }
- if (!fieldTypeToCheck.IsFunctionPointer)
+ if (!ContainsFunctionPointers(_field.FieldType))
dependencies.Add(factory.MaximallyConstructableType(_field.FieldType.NormalizeInstantiation()), "Type of the field");
}
// Function pointers are not supported yet.
// https://github.com/dotnet/runtime/issues/71883
- if (type.IsFunctionPointer)
+ static bool ContainsFunctionPointers(TypeDesc type)
+ {
+ if (type.IsParameterizedType)
+ return ContainsFunctionPointers(((ParameterizedType)type).ParameterType);
+ foreach (TypeDesc instArg in type.Instantiation)
+ if (ContainsFunctionPointers(instArg))
+ return true;
+ return type.IsFunctionPointer;
+ }
+ if (ContainsFunctionPointers(type))
return;
TypeDesc canonType = type.ConvertToCanonForm(CanonicalFormKind.Specific);