Skip to content

Commit 9e30ada

Browse files
committed
Change ' AndroidEnableRestrictToAttributes' to enum style for future-proofing.
1 parent 0f30f6a commit 9e30ada

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,21 @@ This property is `False` by default.
488488

489489
## AndroidEnableRestrictToAttributes
490490

491-
A boolean property that determines whether types and members marked with
492-
the Java annotation `androidx.annotation.RestrictTo` will be marked with an
493-
`[Obsolete]` attribute in the C# binding.
491+
An enum-style property with valid values of `obsolete` and `disable`.
492+
493+
When set to `obsolete`, types and members that are marked with the Java annotation
494+
`androidx.annotation.RestrictTo` *or* are in non-exported Java packages will
495+
be marked with an `[Obsolete]` attribute in the C# binding.
494496

495497
This `[Obsolete]` attribute has a descriptive message explaining that the
496498
Java package owner considers the API to be "internal" and warns against its use.
497499

498500
This attribute also has a custom warning code `XAOBS001` so that it can be suppressed
499501
independently of "normal" obsolete API.
500502

503+
When set to `disable`, API will be generated as normal with no additional
504+
attributes. (This is the same behavior as before .NET 8.)
505+
501506
Adding `[Obsolete]` attributes instead of automatically removing the API was done to
502507
preserve API compatibility with existing packages. If you would instead prefer to
503508
*remove* members that have the `@RestrictTo` annotation *or* are in non-exported
@@ -510,7 +515,7 @@ this property to prevent these types from being bound:
510515

511516
Support for this property was added in .NET 8.
512517

513-
This property is `True` by default.
518+
This property is set to `obsolete` by default.
514519

515520
## AndroidEnableSGenConcurrent
516521

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods Condition=" '$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)' == '' ">true</AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods>
3737
<AndroidBoundInterfacesContainTypes Condition=" '$(AndroidBoundInterfacesContainTypes)' == '' ">true</AndroidBoundInterfacesContainTypes>
3838
<AndroidBoundInterfacesContainConstants Condition=" '$(AndroidBoundInterfacesContainConstants)' == '' ">true</AndroidBoundInterfacesContainConstants>
39-
<AndroidEnableRestrictToAttributes Condition=" '$(AndroidEnableRestrictToAttributes)' == '' ">true</AndroidEnableRestrictToAttributes>
39+
<AndroidEnableRestrictToAttributes Condition=" '$(AndroidEnableRestrictToAttributes)' == '' ">obsolete</AndroidEnableRestrictToAttributes>
4040

4141
<!-- Mono components -->
4242
<AndroidEnableProfiler Condition=" '$(AndroidEnableProfiler)' == ''">false</AndroidEnableProfiler>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class BindingsGenerator : AndroidDotnetToolTask
5151
public bool EnableBindingStaticAndDefaultInterfaceMethods { get; set; }
5252
public bool EnableBindingNestedInterfaceTypes { get; set; }
5353
public bool EnableBindingInterfaceConstants { get; set; }
54-
public bool EnableRestrictToAttributes { get; set; }
54+
public string EnableRestrictToAttributes { get; set; }
5555
public string Nullable { get; set; }
5656

5757
public ITaskItem[] TransformFiles { get; set; }
@@ -217,7 +217,7 @@ protected override string GenerateCommandLineCommands ()
217217
if (EnableBindingStaticAndDefaultInterfaceMethods)
218218
features.Add ("default-interface-methods");
219219

220-
if (EnableRestrictToAttributes)
220+
if (string.Equals (EnableRestrictToAttributes, "obsolete", StringComparison.OrdinalIgnoreCase))
221221
features.Add ("restrict-to-attributes");
222222

223223
if (string.Equals (Nullable, "enable", StringComparison.OrdinalIgnoreCase))

0 commit comments

Comments
 (0)