[cecil-tests] Fix blittability check for parameters whose types are pointers. (#20683)
This commit is contained in:
Родитель
2abbaf900b
Коммит
5566f4912c
|
@ -66,6 +66,8 @@ namespace Cecil.Tests {
|
|||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)",
|
||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)",
|
||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
||||
"System.Byte GameController.GCExtendedGamepadSnapshot::GCExtendedGamepadSnapshotDataFromNSData(GameController.GCExtendedGamepadSnapshotData*,System.IntPtr)",
|
||||
"System.IntPtr GameController.GCExtendedGamepadSnapshotData::NSDataFromGCExtendedGamepadSnapshotData(GameController.GCExtendedGamepadSnapshotData*)",
|
||||
"System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)",
|
||||
"System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalResistiveStrengths(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalResistiveStrengths)",
|
||||
"System.Void ObjCRuntime.Messaging::void_objc_msgSendSuper_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)",
|
||||
|
|
|
@ -326,11 +326,13 @@ namespace Cecil.Tests {
|
|||
blitCache [type.Name] = new BlitAndReason (true, "");
|
||||
return true;
|
||||
}
|
||||
if (IsBlittablePointer (type)) {
|
||||
var localResult = new StringBuilder ();
|
||||
if (IsBlittablePointer (assembly, type, provider, localResult, blitCache)) {
|
||||
blitCache [type.Name] = new BlitAndReason (true, "");
|
||||
return true;
|
||||
}
|
||||
var localResult = new StringBuilder ();
|
||||
result.Append (localResult);
|
||||
localResult.Clear ();
|
||||
if (IsBlittableValueType (assembly, type, localResult, blitCache)) {
|
||||
blitCache [type.Name] = new BlitAndReason (true, "");
|
||||
return true;
|
||||
|
@ -365,9 +367,24 @@ namespace Cecil.Tests {
|
|||
return typesWeLike.Contains (t.ToString ());
|
||||
}
|
||||
|
||||
bool IsBlittablePointer (TypeReference type)
|
||||
bool IsBlittablePointer (AssemblyDefinition assembly, TypeReference type, IMarshalInfoProvider provider, StringBuilder result, Dictionary<string, BlitAndReason> blitCache)
|
||||
{
|
||||
return type.IsPointer || type.IsFunctionPointer;
|
||||
if (type.IsFunctionPointer)
|
||||
return true;
|
||||
|
||||
if (!type.IsPointer)
|
||||
return false;
|
||||
|
||||
var localResult = new StringBuilder ();
|
||||
if (!IsTypeBlittable (assembly, type.GetElementType (), provider, localResult, blitCache)) {
|
||||
var pointerResult = new StringBuilder ();
|
||||
pointerResult.Append ($" {type.Name}: {localResult}");
|
||||
result.Append (pointerResult);
|
||||
blitCache [type.Name] = new BlitAndReason (false, pointerResult.ToString ());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче