Skip to content

[cDac] Fix failing cDac test on OSX#129462

Merged
leculver merged 2 commits into
dotnet:mainfrom
leculver:cdac-osx-objc-fix
Jun 16, 2026
Merged

[cDac] Fix failing cDac test on OSX#129462
leculver merged 2 commits into
dotnet:mainfrom
leculver:cdac-osx-objc-fix

Conversation

@leculver

Copy link
Copy Markdown
Contributor

Fixes failing OSX cDac test. I think this is a regression from #128961.

This pull request updates the handling of pointer types in managed code to better align with how .NET expresses raw pointers. The main change is to allow fields typed as IntPtr/UIntPtr (reported as "nint"/"nuint") to be treated as pointers by the contract reader, improving compatibility and correctness when reading pointer-sized fields.

Improvements to pointer type handling:

  • Updated AssertPointerType in TargetFieldExtensions.cs to accept "nint" and "nuint" as valid pointer type names, in addition to "pointer", enabling proper handling of managed fields typed as IntPtr/UIntPtr.

Test and contract descriptor alignment:

  • Modified the test contract for the _memory field in ObjectiveCMarshalTests.cs to explicitly set its type as "nint", ensuring that the pointer read path is validated against the real managed contract descriptor.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates cDAC’s managed contract type validation for pointer-sized fields so that fields reported as "nint"/"nuint" can be consumed via the pointer read/write helpers, aligning debug-time validation with how managed signatures encode IntPtr/UIntPtr.

Changes:

  • Extend TargetFieldExtensions.AssertPointerType to accept "nint" and "nuint" in addition to "pointer".
  • Update ObjectiveCMarshalTests’ mocked contract descriptor for ObjcTrackingInformation._memory to use TypeName = "nint".
Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/ObjectiveCMarshalTests.cs Adjusts the mocked type descriptor so the test reflects the real managed descriptor type name for IntPtr.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/TargetFieldExtensions.cs Broadens debug-only pointer type validation to treat "nint"/"nuint" as valid pointer-sized representations for pointer reads/writes.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new

@leculver

Copy link
Copy Markdown
Contributor Author

/ba-g This resolves a real test break and needs to be checked in, the arm64 timeouts are unrelated...and I haven't been able to get them to run all day.

@leculver leculver merged commit 581acb2 into dotnet:main Jun 16, 2026
72 of 75 checks passed
@leculver leculver deleted the cdac-osx-objc-fix branch June 16, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants