Skip to content

Commit

Permalink
Change ' AndroidEnableRestrictToAttributes' to enum style for future-…
Browse files Browse the repository at this point in the history
…proofing.
  • Loading branch information
jpobst committed May 2, 2023
1 parent 0f30f6a commit 9e30ada
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions Documentation/guides/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,21 @@ This property is `False` by default.

## AndroidEnableRestrictToAttributes

A boolean property that determines whether types and members marked with
the Java annotation `androidx.annotation.RestrictTo` will be marked with an
`[Obsolete]` attribute in the C# binding.
An enum-style property with valid values of `obsolete` and `disable`.

When set to `obsolete`, types and members that are marked with the Java annotation
`androidx.annotation.RestrictTo` *or* are in non-exported Java packages will
be marked with an `[Obsolete]` attribute in the C# binding.

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

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

When set to `disable`, API will be generated as normal with no additional
attributes. (This is the same behavior as before .NET 8.)

Adding `[Obsolete]` attributes instead of automatically removing the API was done to
preserve API compatibility with existing packages. If you would instead prefer to
*remove* members that have the `@RestrictTo` annotation *or* are in non-exported
Expand All @@ -510,7 +515,7 @@ this property to prevent these types from being bound:

Support for this property was added in .NET 8.

This property is `True` by default.
This property is set to `obsolete` by default.

## AndroidEnableSGenConcurrent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods Condition=" '$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)' == '' ">true</AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods>
<AndroidBoundInterfacesContainTypes Condition=" '$(AndroidBoundInterfacesContainTypes)' == '' ">true</AndroidBoundInterfacesContainTypes>
<AndroidBoundInterfacesContainConstants Condition=" '$(AndroidBoundInterfacesContainConstants)' == '' ">true</AndroidBoundInterfacesContainConstants>
<AndroidEnableRestrictToAttributes Condition=" '$(AndroidEnableRestrictToAttributes)' == '' ">true</AndroidEnableRestrictToAttributes>
<AndroidEnableRestrictToAttributes Condition=" '$(AndroidEnableRestrictToAttributes)' == '' ">obsolete</AndroidEnableRestrictToAttributes>

<!-- Mono components -->
<AndroidEnableProfiler Condition=" '$(AndroidEnableProfiler)' == ''">false</AndroidEnableProfiler>
Expand Down
4 changes: 2 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class BindingsGenerator : AndroidDotnetToolTask
public bool EnableBindingStaticAndDefaultInterfaceMethods { get; set; }
public bool EnableBindingNestedInterfaceTypes { get; set; }
public bool EnableBindingInterfaceConstants { get; set; }
public bool EnableRestrictToAttributes { get; set; }
public string EnableRestrictToAttributes { get; set; }
public string Nullable { get; set; }

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

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

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

0 comments on commit 9e30ada

Please sign in to comment.