From 751daefd21192b4fa7900c06a04418263c55ce76 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 24 Feb 2025 16:49:59 -0600 Subject: [PATCH 1/3] [Xamarin.Android.Build.Tasks] emit XA1040 for experimental runtimes MonoVM is currently the default (and supported!) runtime for .NET for Android. Emit `XA1040` when the user opts into using the experimental runtimes, such as: * `$(UseMonoRuntime)=false` CoreCLR * `$(PublishAot)=true` NativeAOT If desired, you can opt out of the warning completely with `$(AndroidAllowExperimentalRuntime)=true`, or use existing MSBuild mechanisms to suppress it. --- Documentation/docs-mobile/messages/xa1040.md | 32 +++++++++++++++++++ .../Properties/Resources.Designer.cs | 9 ++++++ .../Properties/Resources.resx | 5 +++ .../Xamarin.Android.Common.targets | 5 +++ 4 files changed, 51 insertions(+) create mode 100644 Documentation/docs-mobile/messages/xa1040.md diff --git a/Documentation/docs-mobile/messages/xa1040.md b/Documentation/docs-mobile/messages/xa1040.md new file mode 100644 index 00000000000..634605bf6e0 --- /dev/null +++ b/Documentation/docs-mobile/messages/xa1040.md @@ -0,0 +1,32 @@ +--- +title: .NET for Android warning XA1040 +description: XA1040 warning code +ms.date: 02/24/2025 +--- +# .NET for Android warning XA1040 + +## Example messages + +``` +warning XA1040: The CoreCLR runtime is currently experimental in .NET for Android. +warning XA1040: The NativeAOT runtime is currently experimental in .NET for Android. +``` + +## Issue + +MonoVM is the default, supported runtime for .NET for Android. + +Other runtimes are currently experimental, such as: + +* CoreCLR, used via `$(UseMonoRuntime)=false` +* NativeAOT, used via `$(PublishAot)=true` + +## Solution + +To silence this warning, you can either: + +* Use MonoVM by removing `$(UseMonoRuntime)=false` or + `$(PublishAot)=true` from your project file. + +* Set `$(AndroidAllowExperimentalRuntime)` to `true` in your project + file. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs index 636e491f4a9..7eff7e38644 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs @@ -884,6 +884,15 @@ public static string XA1039 { } } + /// + /// Looks up a localized string similar to The {0} runtime is currently experimental in .NET for Android. + /// + public static string XA1040 { + get { + return ResourceManager.GetString("XA1040", resourceCulture); + } + } + /// /// Looks up a localized string similar to Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET for Android once .NET 6 is released.. /// diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index d58057272af..3df528a8523 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -1016,6 +1016,11 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/net-android/androidx for more details. The following are literal names and should not be translated: Android Support, AndroidX, .NET. + + The {0} runtime is currently experimental in .NET for Android. + The following are literal names and should not be translated: .NET. +{0} - The name of the .NET runtime, such as CoreCLR or NativeAOT. + Java dependency '{0}' is not satisfied. The following are literal names and should not be translated: Java. diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 94b8bb823b0..0c6bd2ae761 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -553,6 +553,11 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. FormatArguments="AndroidFastDeploymentType;9" Condition=" '$(AndroidFastDeploymentType)' != '' " /> + Date: Wed, 26 Feb 2025 13:01:28 -0600 Subject: [PATCH 2/3] New warning text Based kind of around the messaging EF has here: https://learn.microsoft.com/en-us/ef/core/performance/nativeaot-and-precompiled-queries --- Documentation/docs-mobile/messages/xa1040.md | 4 ++-- .../Properties/Resources.Designer.cs | 2 +- src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/docs-mobile/messages/xa1040.md b/Documentation/docs-mobile/messages/xa1040.md index 634605bf6e0..40ff5b9e356 100644 --- a/Documentation/docs-mobile/messages/xa1040.md +++ b/Documentation/docs-mobile/messages/xa1040.md @@ -8,8 +8,8 @@ ms.date: 02/24/2025 ## Example messages ``` -warning XA1040: The CoreCLR runtime is currently experimental in .NET for Android. -warning XA1040: The NativeAOT runtime is currently experimental in .NET for Android. +warning XA1040: The CoreCLR runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues +warning XA1040: The NativeAOT runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues ``` ## Issue diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs index 7eff7e38644..b5c8c7e201a 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs @@ -885,7 +885,7 @@ public static string XA1039 { } /// - /// Looks up a localized string similar to The {0} runtime is currently experimental in .NET for Android. + /// Looks up a localized string similar to The {0} runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues /// public static string XA1040 { get { diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index 3df528a8523..85dcb5e973a 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -1017,7 +1017,7 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS The following are literal names and should not be translated: Android Support, AndroidX, .NET. - The {0} runtime is currently experimental in .NET for Android. + The {0} runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues The following are literal names and should not be translated: .NET. {0} - The name of the .NET runtime, such as CoreCLR or NativeAOT. From 29f8973808051ad2e83f7b2b69d2b202038606ab Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 27 Feb 2025 21:10:59 -0500 Subject: [PATCH 3/3] Use $(EnablePreviewFeatures) --- Documentation/docs-mobile/messages/xa1040.md | 3 +-- src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Documentation/docs-mobile/messages/xa1040.md b/Documentation/docs-mobile/messages/xa1040.md index 40ff5b9e356..14e461a9c34 100644 --- a/Documentation/docs-mobile/messages/xa1040.md +++ b/Documentation/docs-mobile/messages/xa1040.md @@ -28,5 +28,4 @@ To silence this warning, you can either: * Use MonoVM by removing `$(UseMonoRuntime)=false` or `$(PublishAot)=true` from your project file. -* Set `$(AndroidAllowExperimentalRuntime)` to `true` in your project - file. +* Set `$(EnablePreviewFeatures)` to `true` in your project file. diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 0c6bd2ae761..ab8252d33f8 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -556,7 +556,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.