Skip to content
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

[Generator] Ensure that selectors fields do not have overlapping names. Fixes #18645 #18646

Merged
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
8 changes: 4 additions & 4 deletions src/AppKit/Compat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public virtual void SetTextBlocks (NSTextBlock [] array)
throw new ArgumentNullException (nameof (array));
var nsa_array = NSArray.FromNSObjects (array);
if (IsDirectBinding) {
global::ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (this.Handle, selSetTextBlocks_Handle, nsa_array.Handle);
global::ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (this.Handle, selSetTextBlocks_XHandle, nsa_array.Handle);
} else {
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, selSetTextBlocks_Handle, nsa_array.Handle);
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, selSetTextBlocks_XHandle, nsa_array.Handle);
}
nsa_array.Dispose ();
}
Expand All @@ -35,9 +35,9 @@ public virtual void SetTextLists (NSTextList [] array)
throw new ArgumentNullException (nameof (array));
var nsa_array = NSArray.FromNSObjects (array);
if (IsDirectBinding) {
global::ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (this.Handle, selSetTextLists_Handle, nsa_array.Handle);
global::ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (this.Handle, selSetTextLists_XHandle, nsa_array.Handle);
} else {
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, selSetTextLists_Handle, nsa_array.Handle);
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, selSetTextLists_XHandle, nsa_array.Handle);
}
nsa_array.Dispose ();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Foundation/NSArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static public NSArray FromIntPtrs (NativeHandle [] vals)
internal static nuint GetCount (IntPtr handle)
{
#if MONOMAC
return (nuint) Messaging.UIntPtr_objc_msgSend (handle, selCountHandle);
return (nuint) Messaging.UIntPtr_objc_msgSend (handle, selCountXHandle);
#else
return (nuint) Messaging.UIntPtr_objc_msgSend (handle, Selector.GetHandle ("count"));
#endif
Expand All @@ -259,7 +259,7 @@ internal static NativeHandle GetAtIndex (NativeHandle handle, nuint i)
return Messaging.NativeHandle_objc_msgSend_UIntPtr (handle, Selector.GetHandle ("objectAtIndex:"), (UIntPtr) i);
#else
#if MONOMAC
return Messaging.IntPtr_objc_msgSend_UIntPtr (handle, selObjectAtIndex_Handle, (UIntPtr) i);
return Messaging.IntPtr_objc_msgSend_UIntPtr (handle, selObjectAtIndex_XHandle, (UIntPtr) i);
#else
return Messaging.IntPtr_objc_msgSend_UIntPtr (handle, Selector.GetHandle ("objectAtIndex:"), (UIntPtr) i);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Foundation/NSDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public IEnumerator<KeyValuePair<NSObject, NSObject>> GetEnumerator ()
public IntPtr LowlevelObjectForKey (IntPtr key)
{
#if MONOMAC
return ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, selObjectForKey_Handle, key);
return ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, selObjectForKey_XHandle, key);
#else
return ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, Selector.GetHandle ("objectForKey:"), key);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/Foundation/NSMutableDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public IEnumerator<KeyValuePair<NSObject, NSObject>> GetEnumerator ()
public static NSMutableDictionary LowlevelFromObjectAndKey (IntPtr obj, IntPtr key)
{
#if MONOMAC
return (NSMutableDictionary) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr, selDictionaryWithObject_ForKey_Handle, obj, key));
return (NSMutableDictionary) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr, selDictionaryWithObject_ForKey_XHandle, obj, key));
#else
return (NSMutableDictionary) Runtime.GetNSObject (ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle ("dictionaryWithObject:forKey:"), obj, key));
#endif
Expand All @@ -328,7 +328,7 @@ public static NSMutableDictionary LowlevelFromObjectAndKey (IntPtr obj, IntPtr k
public void LowlevelSetObject (IntPtr obj, IntPtr key)
{
#if MONOMAC
ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObject_ForKey_Handle, obj, key);
ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetObject_ForKey_XHandle, obj, key);
#else
ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, Selector.GetHandle ("setObject:forKey:"), obj, key);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/Foundation/NSObject2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,9 @@ public void SetValueForKeyPath (NativeHandle handle, NSString keyPath)
#else
#if MONOMAC
if (IsDirectBinding) {
ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetValue_ForKeyPath_Handle, handle, keyPath.Handle);
ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (this.Handle, selSetValue_ForKeyPath_XHandle, handle, keyPath.Handle);
} else {
ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, selSetValue_ForKeyPath_Handle, handle, keyPath.Handle);
ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_IntPtr (this.SuperHandle, selSetValue_ForKeyPath_XHandle, handle, keyPath.Handle);
}
#else
if (IsDirectBinding) {
Expand Down
4 changes: 2 additions & 2 deletions src/Foundation/NSUrlProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public NSUrlProtocol (NSUrlRequest request, NSCachedUrlResponse cachedResponse,
if (client is null)
throw new ArgumentNullException ("client");
if (IsDirectBinding) {
InitializeHandle (IntPtr_objc_msgSend_IntPtr_IntPtr_IntPtr (this.Handle, selInitWithRequest_CachedResponse_Client_Handle, request.Handle, cachedResponse is null ? IntPtr.Zero : cachedResponse.Handle, client.Handle), "initWithRequest:cachedResponse:client:");
InitializeHandle (IntPtr_objc_msgSend_IntPtr_IntPtr_IntPtr (this.Handle, selInitWithRequest_CachedResponse_Client_XHandle, request.Handle, cachedResponse is null ? IntPtr.Zero : cachedResponse.Handle, client.Handle), "initWithRequest:cachedResponse:client:");
} else {
InitializeHandle (IntPtr_objc_msgSendSuper_IntPtr_IntPtr_IntPtr (this.SuperHandle, selInitWithRequest_CachedResponse_Client_Handle, request.Handle, cachedResponse is null ? IntPtr.Zero : cachedResponse.Handle, client.Handle), "initWithRequest:cachedResponse:client:");
InitializeHandle (IntPtr_objc_msgSendSuper_IntPtr_IntPtr_IntPtr (this.SuperHandle, selInitWithRequest_CachedResponse_Client_XHandle, request.Handle, cachedResponse is null ? IntPtr.Zero : cachedResponse.Handle, client.Handle), "initWithRequest:cachedResponse:client:");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/bgen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ public string SelectorField (string s, bool ignore_inline_directive = false)
sb.Append (c);
}
if (!InlineSelectors)
sb.Append ("Handle");
sb.Append ("XHandle");
name = sb.ToString ();
selector_names [s] = name;
return name;
Expand Down
3 changes: 3 additions & 0 deletions tests/generator/BGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ public void DiamondProtocol ()
[Test]
public void GHIssue9065_Sealed () => BuildFile (Profile.iOS, nowarnings: true, "ghissue9065.cs");

[Test]
public void GHIssue18645_DuplicatedFiled () => BuildFile (Profile.iOS, nowarnings: true, "ghissue18645.cs");

// looking for [BindingImpl (BindingImplOptions.Optimizable)]
bool IsOptimizable (MethodDefinition method)
{
Expand Down
44 changes: 44 additions & 0 deletions tests/generator/ghissue18645.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Foundation;
using ObjCRuntime;

namespace GHIssue18645 {

[Protocol]
[BaseType (typeof (NSObject))]
interface ASCredentialIdentity {

[Abstract]
[Export ("user")]
string User { get; }

[Abstract]
[NullAllowed, Export ("recordIdentifier")]
string RecordIdentifier { get; }

[Abstract]
[Export ("rank")]
nint Rank { get; set; }
}

[BaseType (typeof (NSObject))]
interface ASPasskeyCredentialIdentity : ASCredentialIdentity {
[Export ("relyingPartyIdentifier")]
string RelyingPartyIdentifier { get; }

[Export ("userName")]
string UserName { get; }

[Export ("credentialID", ArgumentSemantic.Copy)]
NSData CredentialID { get; }

[Export ("userHandle", ArgumentSemantic.Copy)]
NSData UserHandle { get; }

[NullAllowed, Export ("recordIdentifier")]
new string RecordIdentifier { get; }

[Export ("rank")]
new nint Rank { get; set; }
}

}
6 changes: 3 additions & 3 deletions tests/mmp-regression/link-frameworks-1/LinkFrameworks1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ static void TestFrameworks ()

switch (field.Name) {
case "selConformsToProtocolHandle":
case "selDescriptionHandle":
case "selHashHandle":
case "selIsEqual_Handle":
case "selDescriptionXHandle":
case "selHashXHandle":
case "selIsEqual_XHandle":
case "class_ptr":
// Unrelated fields
continue;
Expand Down
Loading