Skip to content

[mono] Validate UnsafeAccessor generic constraints - #134142

Open
tayfuryldz wants to merge 1 commit into
dotnet:mainfrom
tayfuryldz:fix/102942-mono-unsafeaccessor-constraints
Open

tayfuryldz wants to merge 1 commit into
dotnet:mainfrom
tayfuryldz:fix/102942-mono-unsafeaccessor-constraints

Conversation

@tayfuryldz

Copy link
Copy Markdown

Fixes #102942

Summary

Add generic constraint validation for Mono UnsafeAccessor binding, matching the CoreCLR behavior.

The Mono wrapper now validates the target type and method generic constraints against the UnsafeAccessor declaration before inflating the target method. Mismatched declarations throw InvalidProgramException.

This also re-enables the existing generic constraint tests on Mono. The old Mono project build disable referenced #116937, which is now closed; MonoAotIncompatible remains in place.

Validation

  • ./build.sh -subset mono -c Release --gcc
  • UnsafeAccessorsTests on the patched Mono runtime: pass (RC=100)
  • Baseline A/B: current main without the runtime fix fails Verify_Generic_MethodConstraintEnforcement because no InvalidProgramException is thrown (RC=101)
  • The patched runtime passes both Verify_Generic_MethodConstraintEnforcement and Verify_Generic_ClassConstraintEnforcement
  • git diff --check

Note

This pull request was prepared with AI assistance.

Copilot AI lite review requested due to automatic review settings September 17, 2026 15:12

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 17, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI review requested due to automatic review settings September 17, 2026 15:33
@tayfuryldz
tayfuryldz force-pushed the fix/102942-mono-unsafeaccessor-constraints branch from b81b82e to e23a8ac Compare September 17, 2026 15:33

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@tayfuryldz

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-meta-mono community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Mono] Add support for UnsafeAccessor mismatched generic constraint checking

2 participants