Skip to content

[src] Fix checking if a constraint implements INativeObject. Fixes #23070. #23110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2025
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
2 changes: 1 addition & 1 deletion src/ObjCRuntime/DynamicRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public override bool VerifyIsConstrainedToNSObject (Type type, out Type constrai
// First look for a more specific constraint
var constraints = type.GetGenericParameterConstraints ();
foreach (var constraint in constraints) {
if (constraint.IsSubclassOf (typeof (INativeObject))) {
if (typeof (INativeObject).IsAssignableFrom (constraint)) {
constrained_type = constraint;
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/monotouch-test/ObjCRuntime/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5524,6 +5524,15 @@ void PreserveIUIApplicationDelegate (IUIApplicationDelegate obj)
GC.KeepAlive (obj);
}
#endif // HAS_UIKIT

#if HAS_UIKIT
// This is a test case for https://github.com/dotnet/macios/issues/23070.
// It only needs to exist in the source code, it doesn't have to do anything.
private void Issue23070TestCase (UIView origin, UIView target)
{
origin.LeftAnchor.ConstraintEqualTo (target.LeftAnchor);
}
#endif // HAS_UIKIT
}

[Category (typeof (CALayer))]
Expand Down