Skip to content

Commit fc12232

Browse files
committed
Merge branch 'main' into all-assemblies-per-rid
* main: [Xamarin.Android.Build.Tasks] Add support for $(AndroidEnableObsoleteOverrideInheritance). (dotnet#8393) [Xamarin.Android.Build.Tasks] Make manifestmerger.jar the default. (dotnet#8392)
2 parents a298f00 + 1a309b6 commit fc12232

File tree

7 files changed

+25
-4
lines changed

7 files changed

+25
-4
lines changed

Documentation/guides/building-apps/build-properties.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,15 @@ Support for this property was added in Xamarin.Android 5.1.
469469

470470
This property is `False` by default.
471471

472+
## AndroidEnableObsoleteOverrideInheritance
473+
474+
A boolean property that determines if bound methods automatically inherit `[Obsolete]`
475+
attributes from methods they override.
476+
477+
Support for this property was added in .NET 8.
478+
479+
This property is `True` by default.
480+
472481
## AndroidEnablePreloadAssemblies
473482

474483
A boolean property that controls
@@ -987,9 +996,12 @@ merging *AndroidManifest.xml* files. This is an enum-style property
987996
where `legacy` selects the original C# implementation
988997
and `manifestmerger.jar` selects Google's Java implementation.
989998

990-
The default value is currently `legacy`. This will change to
991-
`manifestmerger.jar` in a future release to align behavior with
992-
Android Studio.
999+
The default value is currently `manifestmerger.jar`. If you want to
1000+
use the old version add the following to your csproj
1001+
1002+
```xml
1003+
<AndroidManifestMerger>legacy</AndroidManifestMerger>
1004+
```
9931005

9941006
Google's merger enables support for `xmlns:tools="http://schemas.android.com/tools"`
9951007
as described in the [Android documentation][manifest-merger].

src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ It is shared between "legacy" binding projects and .NET 5 projects.
9999
EnableBindingNestedInterfaceTypes="$(AndroidBoundInterfacesContainTypes)"
100100
EnableBindingInterfaceConstants="$(AndroidBoundInterfacesContainConstants)"
101101
EnableRestrictToAttributes="$(AndroidEnableRestrictToAttributes)"
102+
EnableObsoleteOverrideInheritance="$(AndroidEnableObsoleteOverrideInheritance)"
102103
Nullable="$(Nullable)"
103104
UseJavaLegacyResolver="$(_AndroidUseJavaLegacyResolver)"
104105
NamespaceTransforms="@(AndroidNamespaceReplacement)"

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods Condition=" '$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)' == '' ">true</AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods>
4040
<AndroidBoundInterfacesContainTypes Condition=" '$(AndroidBoundInterfacesContainTypes)' == '' ">true</AndroidBoundInterfacesContainTypes>
4141
<AndroidBoundInterfacesContainConstants Condition=" '$(AndroidBoundInterfacesContainConstants)' == '' ">true</AndroidBoundInterfacesContainConstants>
42+
<AndroidEnableObsoleteOverrideInheritance Condition=" '$(AndroidEnableObsoleteOverrideInheritance)' == '' ">true</AndroidEnableObsoleteOverrideInheritance>
4243
<AndroidEnableRestrictToAttributes Condition=" '$(AndroidEnableRestrictToAttributes)' == '' ">obsolete</AndroidEnableRestrictToAttributes>
4344

4445
<!-- Mono components -->

src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class BindingsGenerator : AndroidDotnetToolTask
5252
public bool EnableBindingNestedInterfaceTypes { get; set; }
5353
public bool EnableBindingInterfaceConstants { get; set; }
5454
public string EnableRestrictToAttributes { get; set; }
55+
public bool EnableObsoleteOverrideInheritance { get; set; }
5556
public string Nullable { get; set; }
5657

5758
public ITaskItem[] TransformFiles { get; set; }
@@ -217,6 +218,9 @@ protected override string GenerateCommandLineCommands ()
217218
if (EnableBindingStaticAndDefaultInterfaceMethods)
218219
features.Add ("default-interface-methods");
219220

221+
if (!EnableObsoleteOverrideInheritance)
222+
features.Add ("do-not-fix-obsolete-overrides");
223+
220224
if (string.Equals (EnableRestrictToAttributes, "obsolete", StringComparison.OrdinalIgnoreCase))
221225
features.Add ("restrict-to-attributes");
222226

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2, [V
670670
if (Builder.UseDotNet) {
671671
lib.RemoveProperty ("OutputType");
672672
}
673+
lib.AndroidManifest = lib.AndroidManifest.
674+
Replace ("application android:label=\"${PROJECT_NAME}\"", "application android:label=\"com.test.foo\" ");
673675

674676
// Create an "app" that is basically empty and references the library
675677
var app = new XamarinAndroidLibraryProject {

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ public void MergeLibraryManifest ()
755755
KnownPackages.SupportV7AppCompat_27_0_2_1,
756756
},
757757
};
758+
proj.SetProperty ("AndroidManifestMerger", "legacy");
758759
proj.Sources.Add (new BuildItem.Source ("TestActivity1.cs") {
759760
TextContent = () => @"using System;
760761
using System.Collections.Generic;

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
270270
<AndroidCreatePackagePerAbi Condition=" '$(AndroidCreatePackagePerAbi)' == 'aab' ">False</AndroidCreatePackagePerAbi>
271271
<AndroidApkSigningAlgorithm Condition=" '$(AndroidApkSigningAlgorithm)' == '' ">SHA256withRSA</AndroidApkSigningAlgorithm>
272272
<AndroidApkDigestAlgorithm Condition=" '$(AndroidApkDigestAlgorithm)' == '' ">SHA-256</AndroidApkDigestAlgorithm>
273-
<AndroidManifestMerger Condition=" '$(AndroidManifestMerger)' == '' ">legacy</AndroidManifestMerger>
273+
<AndroidManifestMerger Condition=" '$(AndroidManifestMerger)' == '' ">manifestmerger.jar</AndroidManifestMerger>
274274

275275
<!-- Default Java heap size to 1GB (-Xmx1G) if not specified-->
276276
<JavaMaximumHeapSize Condition=" '$(JavaMaximumHeapSize)' == '' ">1G</JavaMaximumHeapSize>

0 commit comments

Comments
 (0)