Skip to content

Commit 02644ca

Browse files
authored
[NET 6 Attribute Conversion] AddressBook (#13715)
1 parent 39467f8 commit 02644ca

File tree

10 files changed

+396
-286
lines changed

10 files changed

+396
-286
lines changed

src/AddressBook/ABAddressBook.cs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@
4646
#endif
4747

4848
namespace AddressBook {
49-
#if !NET
50-
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
51-
[Introduced (PlatformName.MacCatalyst, 14, 0)]
52-
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
53-
#else
54-
[UnsupportedOSPlatform ("ios9.0")]
55-
[UnsupportedOSPlatform ("maccatalyst14.0")]
49+
#if NET
5650
[SupportedOSPlatform ("maccatalyst14.0")]
57-
#if IOS
58-
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
59-
#elif __MACCATALYST__
51+
[UnsupportedOSPlatform ("maccatalyst14.0")]
52+
[UnsupportedOSPlatform ("ios9.0")]
53+
#if __MACCATALYST__
6054
[Obsolete ("Starting with maccatalyst14.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
55+
#elif IOS
56+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
6157
#endif
58+
#else
59+
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
60+
[Introduced (PlatformName.MacCatalyst, 14, 0)]
61+
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
6262
#endif
6363
public class ExternalChangeEventArgs : EventArgs {
6464
public ExternalChangeEventArgs (ABAddressBook addressBook, NSDictionary? info)
@@ -116,19 +116,19 @@ static InitConstants ()
116116
}
117117
}
118118

119-
#if !NET
120-
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
121-
[Introduced (PlatformName.MacCatalyst, 14, 0)]
122-
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
123-
#else
124-
[UnsupportedOSPlatform ("ios9.0")]
125-
[UnsupportedOSPlatform ("maccatalyst14.0")]
119+
#if NET
126120
[SupportedOSPlatform ("maccatalyst14.0")]
127-
#if IOS
128-
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
129-
#elif __MACCATALYST__
121+
[UnsupportedOSPlatform ("maccatalyst14.0")]
122+
[UnsupportedOSPlatform ("ios9.0")]
123+
#if __MACCATALYST__
130124
[Obsolete ("Starting with maccatalyst14.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
125+
#elif IOS
126+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
131127
#endif
128+
#else
129+
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
130+
[Introduced (PlatformName.MacCatalyst, 14, 0)]
131+
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
132132
#endif
133133
public class ABAddressBook : NativeObject, IEnumerable<ABRecord> {
134134

@@ -139,13 +139,17 @@ public class ABAddressBook : NativeObject, IEnumerable<ABRecord> {
139139
[DllImport (Constants.AddressBookLibrary)]
140140
internal extern static IntPtr ABAddressBookCreate ();
141141

142-
#if !NET
143-
[Deprecated (PlatformName.iOS, 6, 0, message : "Use the static Create method instead")]
144-
#else
142+
#if NET
143+
[SupportedOSPlatform ("maccatalyst14.0")]
144+
[UnsupportedOSPlatform ("maccatalyst14.0")]
145145
[UnsupportedOSPlatform ("ios6.0")]
146-
#if IOS
146+
#if __MACCATALYST__
147+
[Obsolete ("Starting with maccatalyst14.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
148+
#elif IOS
147149
[Obsolete ("Starting with ios6.0 use the static Create method instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
148150
#endif
151+
#else
152+
[Deprecated (PlatformName.iOS, 6, 0, message : "Use the static Create method instead")]
149153
#endif
150154
public ABAddressBook ()
151155
: this (ABAddressBookCreate (), true)

src/AddressBook/ABEnums.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,48 @@
2828
#if !MONOMAC
2929

3030
using System;
31+
using System.Runtime.Versioning;
3132

3233
using Foundation;
3334
using CoreFoundation;
3435
using ObjCRuntime;
3536

3637
namespace AddressBook {
38+
#if NET
39+
[SupportedOSPlatform ("maccatalyst14.0")]
40+
[UnsupportedOSPlatform ("maccatalyst14.0")]
41+
[UnsupportedOSPlatform ("ios9.0")]
42+
#if __MACCATALYST__
43+
[Obsolete ("Starting with maccatalyst14.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
44+
#elif IOS
45+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
46+
#endif
47+
#else
3748
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
3849
[Introduced (PlatformName.MacCatalyst, 14, 0)]
3950
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
51+
#endif
4052
[Native]
4153
[ErrorDomain ("ABAddressBookErrorDomain")]
4254
public enum ABAddressBookError : long {
4355
OperationNotPermittedByStore = 0,
4456
OperationNotPermittedByUserError
4557
}
4658

59+
#if NET
60+
[SupportedOSPlatform ("maccatalyst14.0")]
61+
[UnsupportedOSPlatform ("maccatalyst14.0")]
62+
[UnsupportedOSPlatform ("ios9.0")]
63+
#if __MACCATALYST__
64+
[Obsolete ("Starting with maccatalyst14.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
65+
#elif IOS
66+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
67+
#endif
68+
#else
4769
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
4870
[Introduced (PlatformName.MacCatalyst, 14, 0)]
4971
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
72+
#endif
5073
[Native]
5174
public enum ABAuthorizationStatus : long {
5275
NotDetermined = 0,
@@ -55,19 +78,40 @@ public enum ABAuthorizationStatus : long {
5578
Authorized
5679
}
5780

81+
#if NET
82+
[UnsupportedOSPlatform ("ios9.0")]
83+
#if IOS
84+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
85+
#endif
86+
#else
5887
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
88+
#endif
5989
public enum ABPersonSortBy : uint /* uint32_t */ {
6090
FirstName = 0,
6191
LastName = 1,
6292
}
6393

94+
#if NET
95+
[UnsupportedOSPlatform ("ios9.0")]
96+
#if IOS
97+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
98+
#endif
99+
#else
64100
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
101+
#endif
65102
public enum ABPersonCompositeNameFormat : uint /* uint32_t */ {
66103
FirstNameFirst = 0,
67104
LastNameFirst = 1,
68105
}
69106

107+
#if NET
108+
[UnsupportedOSPlatform ("ios9.0")]
109+
#if IOS
110+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
111+
#endif
112+
#else
70113
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
114+
#endif
71115
public enum ABPersonProperty {
72116
Address,
73117
Birthday,
@@ -96,28 +140,56 @@ public enum ABPersonProperty {
96140
SocialProfile,
97141
}
98142

143+
#if NET
144+
[UnsupportedOSPlatform ("ios9.0")]
145+
#if IOS
146+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
147+
#endif
148+
#else
99149
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
150+
#endif
100151
[Native]
101152
public enum ABPersonImageFormat : long {
102153
Thumbnail = 0,
103154
OriginalSize = 2,
104155
}
105156

157+
#if NET
158+
[UnsupportedOSPlatform ("ios9.0")]
159+
#if IOS
160+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
161+
#endif
162+
#else
106163
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
164+
#endif
107165
public enum ABPersonKind {
108166
None,
109167
Organization,
110168
Person,
111169
}
112170

171+
#if NET
172+
[UnsupportedOSPlatform ("ios9.0")]
173+
#if IOS
174+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
175+
#endif
176+
#else
113177
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
178+
#endif
114179
public enum ABRecordType : uint /* uint32_t */ {
115180
Person = 0,
116181
Group = 1,
117182
Source = 2,
118183
}
119184

185+
#if NET
186+
[UnsupportedOSPlatform ("ios9.0")]
187+
#if IOS
188+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
189+
#endif
190+
#else
120191
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
192+
#endif
121193
public enum ABPropertyType : uint /* uint32_t */ {
122194
Invalid = 0,
123195
String = 0x1,
@@ -135,7 +207,14 @@ public enum ABPropertyType : uint /* uint32_t */ {
135207
}
136208

137209
// note: not a true flag
210+
#if NET
211+
[UnsupportedOSPlatform ("ios9.0")]
212+
#if IOS
213+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
214+
#endif
215+
#else
138216
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
217+
#endif
139218
public enum ABSourceType : int /* typedef int */ {
140219
Local = 0x0,
141220
Exchange = 0x1,
@@ -148,7 +227,14 @@ public enum ABSourceType : int /* typedef int */ {
148227
SearchableMask = 0x01000000,
149228
};
150229

230+
#if NET
231+
[UnsupportedOSPlatform ("ios9.0")]
232+
#if IOS
233+
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
234+
#endif
235+
#else
151236
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
237+
#endif
152238
public enum ABSourceProperty {
153239
Name,
154240
Type,

src/AddressBook/ABGroup.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ internal static void Init ()
6060
}
6161
}
6262

63-
#if !NET
64-
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
65-
[Introduced (PlatformName.MacCatalyst, 14, 0)]
66-
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
67-
#else
68-
[UnsupportedOSPlatform ("ios9.0")]
69-
[UnsupportedOSPlatform ("maccatalyst14.0")]
63+
#if NET
7064
[SupportedOSPlatform ("maccatalyst14.0")]
65+
[UnsupportedOSPlatform ("maccatalyst14.0")]
66+
[UnsupportedOSPlatform ("ios9.0")]
7167
#if __MACCATALYST__
7268
[Obsolete ("Starting with maccatalyst14.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
7369
#elif IOS
7470
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
7571
#endif
72+
#else
73+
[Deprecated (PlatformName.iOS, 9, 0, message : "Use the 'Contacts' API instead.")]
74+
[Introduced (PlatformName.MacCatalyst, 14, 0)]
75+
[Deprecated (PlatformName.MacCatalyst, 14, 0, message : "Use the 'Contacts' API instead.")]
7676
#endif
7777
public class ABGroup : ABRecord, IEnumerable<ABRecord> {
7878

0 commit comments

Comments
 (0)