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 @@ -212,8 +212,12 @@ private static void AssertPrimitiveType<T>(Target.FieldInfo field, string fieldN
[Conditional("DEBUG")]
private static void AssertPointerType(Target.FieldInfo field, string fieldName)
{
// Managed field signatures report IntPtr/UIntPtr as native ints, which the contract descriptor maps to
// "nint"/"nuint" (as distinct from raw pointer element types which map to "pointer").
// Accept those in addition to "pointer" so pointer-valued fields on managed types can be
// read via ReadPointer, which reads the value unsigned at full pointer width.
Debug.Assert(
field.TypeName is null or "" or "pointer",
field.TypeName is null or "" or "pointer" or "nint" or "nuint",
$"Type mismatch reading field '{fieldName}': declared as '{field.TypeName}', expected pointer");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ private static TestPlaceholderTarget CreateObjectiveCMarshalTargetWithCWT(
};

// Register ObjcTrackingInformation type with a single pointer-sized _memory field at offset 0.
// The managed _memory field is an IntPtr, so the contract descriptor reports its type as "nint";
// model that here so the pointer read path is validated against the real descriptor type.
var trackingInfoType = new Target.TypeInfo
{
Size = (uint)helpers.PointerSize,
Fields = new Dictionary<string, Target.FieldInfo>
{
["_memory"] = new Target.FieldInfo { Offset = 0 }
["_memory"] = new Target.FieldInfo { Offset = 0, TypeName = "nint" }
}
};

Expand Down
Loading