Skip to content

Commit

Permalink
[AddressBook[UI]] Fix all availability attributes in these frameworks. (
Browse files Browse the repository at this point in the history
#22252)

* Add missing availability attributes for .NET.
* Remove !.NET availability attributes / code.

This is a step towards fixing #21185.
  • Loading branch information
rolfbjarne authored Feb 27, 2025
1 parent dfb9a22 commit 91e1d8e
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 371 deletions.
46 changes: 21 additions & 25 deletions src/AddressBook/ABAddressBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@
#endif

namespace AddressBook {
#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ExternalChangeEventArgs : EventArgs {
public ExternalChangeEventArgs (ABAddressBook addressBook, NSDictionary? info)
{
Expand All @@ -78,6 +74,12 @@ public ExternalChangeEventArgs (ABAddressBook addressBook, NSDictionary? info)
// Note that the above comment was removed from iOS 6.0+ documentation (and were not part of OSX docs AFAIK).
// It make sense since it's not possible to call those functions, from 6.0+ they will return NULL on devices,
// unless the application has been authorized to access the address book.
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
static class InitConstants {
public static void Init () { }

Expand Down Expand Up @@ -111,16 +113,12 @@ static InitConstants ()
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABAddressBook : NativeObject, IEnumerable<ABRecord> {

public static readonly NSString ErrorDomain;
Expand All @@ -130,14 +128,12 @@ public class ABAddressBook : NativeObject, IEnumerable<ABRecord> {
[DllImport (Constants.AddressBookLibrary)]
internal extern static IntPtr ABAddressBookCreate ();

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios6.0", "Use the static Create method instead.")]
#else
[Deprecated (PlatformName.iOS, 6, 0, message: "Use the static Create method instead")]
#endif
[ObsoletedOSPlatform ("ios", "Use the static Create method instead")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the static Create method instead")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public ABAddressBook ()
: this (ABAddressBookCreate (), true)
{
Expand Down
20 changes: 11 additions & 9 deletions src/AddressBook/ABGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
#endif

namespace AddressBook {
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
static class ABGroupProperty {

public static int Name { get; private set; }
Expand All @@ -61,16 +67,12 @@ internal static void Init ()
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABGroup : ABRecord, IEnumerable<ABRecord> {

[DllImport (Constants.AddressBookLibrary)]
Expand Down
98 changes: 35 additions & 63 deletions src/AddressBook/ABMultiValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@

namespace AddressBook {

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0)]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
static class ABMultiValue {
public const uint Mask = (1 << 8);

Expand Down Expand Up @@ -105,16 +101,12 @@ static class ABMultiValue {
public static extern byte RemoveValueAndLabelAtIndex (IntPtr multiValue, nint index);
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public struct ABMultiValueEntry<T> {
ABMultiValue<T> self;
nint index;
Expand Down Expand Up @@ -185,16 +177,12 @@ public int Identifier {
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABMultiValue<T> : NativeObject, IEnumerable<ABMultiValueEntry<T>> {
internal Converter<NativeHandle, T> toManaged;
internal Converter<T, NativeHandle> toNative;
Expand Down Expand Up @@ -280,16 +268,12 @@ public ABMutableMultiValue<T> ToMutableMultiValue ()
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABMutableMultiValue<T> : ABMultiValue<T> {
[Preserve (Conditional = true)]
internal ABMutableMultiValue (NativeHandle handle, bool owns)
Expand Down Expand Up @@ -334,50 +318,38 @@ public bool RemoveAt (nint index)
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABMutableDateMultiValue : ABMutableMultiValue<NSDate> {
public ABMutableDateMultiValue ()
: base (ABMultiValue.CreateMutable (ABPropertyType.MultiDateTime), true)
{
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABMutableDictionaryMultiValue : ABMutableMultiValue<NSDictionary> {
public ABMutableDictionaryMultiValue ()
: base (ABMultiValue.CreateMutable (ABPropertyType.MultiDictionary), true)
{
}
}

#if NET
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("ios")]
[ObsoletedOSPlatform ("maccatalyst14.0", "Use the 'Contacts' API instead.")]
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
#else
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Deprecated (PlatformName.MacCatalyst, 14, 0, message: "Use the 'Contacts' API instead.")]
#endif
[ObsoletedOSPlatform ("ios", "Use the 'Contacts' API instead.")]
[SupportedOSPlatform ("maccatalyst")]
[ObsoletedOSPlatform ("maccatalyst", "Use the 'Contacts' API instead.")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public class ABMutableStringMultiValue : ABMutableMultiValue<string> {
public ABMutableStringMultiValue ()
: base (ABMultiValue.CreateMutable (ABPropertyType.MultiString),
Expand Down
Loading

8 comments on commit 91e1d8e

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ [CI Build #91e1d8e] Build passed (CodeQL) ✅

Pipeline on Agent
Hash: 91e1d8e6f50b6da01f14500108683bc4ee6e5d34 [CI build]

Please sign in to comment.