-
Notifications
You must be signed in to change notification settings - Fork 555
Closed
Copy link
Labels
bugIf an issue is a bug or a pull request a bug fixIf an issue is a bug or a pull request a bug fix
Milestone
Description
Example code:
var a = new NSDictionary<NSString, NSObject> ();
var b = new NSDictionary<NSString, NSString> ();
var c = new NSDictionary ();
Console.WriteLine ($"a: 0x{a.Handle:X}");
Console.WriteLine ($"b: 0x{b.Handle:X}");
Console.WriteLine ($"c: 0x{c.Handle:X}");prints the same handle for both instances:
a: 0x0x7fff80821080
b: 0x0x7fff80821080
c: 0x0x7fff80821080
This is unfortunately a problem.
Say you have a type with two properties:
NSDictionary<NSString, NSObject> PropertyA { get; set; }
NSDictionary<NSString, NSString> PropertyB { get; set; }and native code has set them both to an empty NSDictionary, then fetching one will make the other break, because this happens:
Unable to cast object of type 'Foundation.NSDictionary`2[[Foundation.NSString, Xamarin.MacCatalyst, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065],[Foundation.NSObject, Xamarin.MacCatalyst, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]]' to type 'Foundation.NSDictionary`2[[Foundation.NSString, Xamarin.MacCatalyst, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065],[Foundation.NSString, Xamarin.MacCatalyst, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]]'
The generic versions of NSArray, NSSet and NSOrderedSet probably have the same problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIf an issue is a bug or a pull request a bug fixIf an issue is a bug or a pull request a bug fix