Skip to content

How to support .NET MAUI on .NET 10? #1084

Open
@jonathanpeppers

Description

@jonathanpeppers

Android framework version

Other

Affected platform version

.NET 10, NativeAOT

Description

For NativeAOT-friendly support, there are some generator changes to emit methods like:

[global::System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
static void n_OnCreate_Landroid_os_Bundle_Landroid_os_PersistableBundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState, IntPtr native_persistentState)
{
 if (!global::Java.Interop.JniEnvironment.BeginMarshalMethod (jnienv, out var __envp, out var __r))
  return;
 try {
  var __this = global::Java.Lang.Object.GetObject<Android.App.Activity> (jnienv, native__this, JniHandleOwnership.DoNotTransfer)!;
  var savedInstanceState = global::Java.Lang.Object.GetObject<Android.OS.Bundle> (native_savedInstanceState, JniHandleOwnership.DoNotTransfer);
  var persistentState = global::Java.Lang.Object.GetObject<Android.OS.PersistableBundle> (native_persistentState, JniHandleOwnership.DoNotTransfer);
  __this.OnCreate (savedInstanceState, persistentState);
 } catch (global::System.Exception __e) {
  __r.OnUserUnhandledException (ref __envp, __e);
 } finally {
  global::Java.Interop.JniEnvironment.EndMarshalMethod (ref __envp);
 }
}

These use:

  • New Java.Interop.dll methods that are only present in .NET 10
  • OnUserUnhandledException() relies on a feature that only works in ICorDebug (not Mono debugger)

I have a PR here that builds this repo with a net10.0-android tfm:

So, how do we build .NET MAUI for .NET 10 and rely on new AndroidX binding packages?

Idea 1

Multi-target for .NET 8, .NET 9, .NET 10.

This would require:

  • .NET 10 Android workload to support .NET 8 for a period of time

Potential blocker:

  • We would build all frameworks with either a preview or nightly Roslyn (C# compiler). If you have a .NET 10 SDK, you get the .NET 10 C# compiler for the other target frameworks.
  • Alternatively build the repo twice w/ stable and preview .NET SDKs, and somehow "merge" the .NET 10 assemblies inside.

Idea 2

  • Build a "preview" set of AndroidX and GPS NuGets with a version number like -preview-net10 or similar.

  • Publish these to NuGet.org.

  • .NET MAUI relies on these for .NET 10.

Potential blocker:

  • It appears that "binderator" (unsure of exact details) emits supported ranges of dependent versions between the various AndroidX packages.
  • This would need to be removed, to only depend on the .NET 10 preview versions.
  • Customers could see the -preview-net10 packages and try to use them.
  • Customers might have trouble trying out .NET 10, updating from .NET 9 to 10?

Conclusion

I am somewhat leaning towards no. 2, but @jpobst or @Redth open to other ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions