-
Notifications
You must be signed in to change notification settings - Fork 548
Description
In order to fully support the new native types in C# (nint, nuint), we’ve unfortunately realized that we can’t keep compatibility with existing code or assemblies built for Xamarin.iOS or Xamarin.Mac.
The consequences are as follows when upgrading a project to .NET 6:
- All code must be recompiled to support .NET 6. Existing assemblies (such as NuGets built for the old TargetFrameworkIdentifier xamarinios10) won’t work and won’t be supported. Non-xamarin specific assets for net4.x, netstandard, netcoreapp, net5.0+, etc. will work fine however.
- Existing code might need to be modified. We’ll post a more detailed document with examples of code changes that might be required at a later point.
In addition, we’re taking the opportunity to fix a few mistakes we’ve made in the past, that we’ve been unable able to address because they were breaking changes.
These are the main changes:
- Removal of the System.nint and System.nuint types. We’re going to use the
nint
andnuint
types as defined by C# (they are System.IntPtr and System.UIntPtr under the hood). - Removal of the System.nfloat type. We're going to use the System.Runtime.InteropServices.NFloat type instead.
For the System.nfloat type we’re probably going to keep the type [1], but move it to a different namespace. - Use a different type than System.IntPtr for handles (the NSObject.Handle property): ObjCRuntime.NativeHandle. This is to avoid confusion between nint/nuint and handles.
- Move all the types in the OpenTK namespace elsewhere.
We also have a list of minor changes we’ve wanted to do for a long time: #5107. We’ll be going through this list and implement the ones that make sense and that we have time to complete.
The first preview with these breaking changes will be Preview 11.
Reference: #10508
Reference: dotnet/designs#252
Reference: NuGet/Home#11338
[1]: System.Runtime.InteropServices.NFloat is not a good replacement for System.nfloat, because it’s a very basic type intended only for interop scenarios. For instance, it does not have any operators, so code like “NFloat + NFloat” does not compile. The operators were implemented and back ported to .NET 6, so the concerns with System.Runtime.InteropServices.NFloat went away.