-
Notifications
You must be signed in to change notification settings - Fork 548
Description
This is not really a bug, but more of an open discussion about how some things are bound.
Take for example, NSRange: https://github.com/xamarin/xamarin-macios/blob/master/src/Foundation/NSRange.cs#L27
The struct is guidelines are for the struct to be immutable. (https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/struct)
Cocoa API doesn't seem to let it be mutated either: https://developer.apple.com/documentation/foundation/nsrange?language=objc
In case of structs, when a struct is in a readonly field/property or is passed as arguments to in parameters, the compiler generates a defensive copy.
This happens because this is mutable by default.
C# 7.2 has some nice-ness that allows for structs to be marked as readonly, thus not allowing the this variable to be set, but that requires the property to be fully readonly.
Why was NSRange designed mutable? Might be the case for most structs bound