From 024d688b52111530b85aa2c8670244f37183fe97 Mon Sep 17 00:00:00 2001 From: Jan Wiebe Date: Fri, 5 Aug 2022 15:11:06 +0200 Subject: [PATCH 01/12] Fix #9996 by using ICPListTemplateItem[] in every constructor of CPListSection --- src/carplay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/carplay.cs b/src/carplay.cs index e4f0c5a0d38e..04c39b113244 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -573,10 +573,10 @@ interface CPListItem : CPSelectableListItem, NSSecureCoding { interface CPListSection : NSSecureCoding { [Export ("initWithItems:header:sectionIndexTitle:")] - NativeHandle Constructor (CPListItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); + NativeHandle Constructor (ICPListTemplateItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); [Export ("initWithItems:")] - NativeHandle Constructor (CPListItem [] items); + NativeHandle Constructor (ICPListTemplateItem [] items); [iOS (15,0), MacCatalyst (15,0)] [Export ("initWithItems:header:headerSubtitle:headerImage:headerButton:sectionIndexTitle:")] From 5760a349111f2e1950852ec1da2a08c7f8c77c86 Mon Sep 17 00:00:00 2001 From: Jan Wiebe Date: Fri, 5 Aug 2022 15:41:51 +0200 Subject: [PATCH 02/12] Try to provide upgrade path. Added Items[] as well, to conform to iOS SDK https://developer.apple.com/documentation/carplay/cplistsection --- src/carplay.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/carplay.cs b/src/carplay.cs index 04c39b113244..2abb561483cb 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -572,6 +572,14 @@ interface CPListItem : CPSelectableListItem, NSSecureCoding { [DisableDefaultCtor] interface CPListSection : NSSecureCoding { + [Export ("initWithItems:header:sectionIndexTitle:")] + [Obsolete ("Use 'CPListSection (ICPListTemplateItem [], string, string)' constructor instead.")] + NativeHandle Constructor (CPListItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); + + [Export ("initWithItems:")] + [Obsolete ("Use 'CPListSection (ICPListTemplateItem [])' constructor instead.")] + NativeHandle Constructor (CPListItem [] items); + [Export ("initWithItems:header:sectionIndexTitle:")] NativeHandle Constructor (ICPListTemplateItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); @@ -589,8 +597,12 @@ interface CPListSection : NSSecureCoding { string SectionIndexTitle { get; } [Export ("items", ArgumentSemantic.Copy)] + [Obsolete ("Use 'Items : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } + [Export ("items", ArgumentSemantic.Copy)] + ICPListTemplateItem [] Items { get; } + [iOS (14,0)] [Export ("indexOfItem:")] nuint GetIndex (ICPListTemplateItem item); From 8ef1194a7d497fab59373604e13c441052075d01 Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 17:29:01 +0200 Subject: [PATCH 03/12] Wrap old api in #if XAMCORE_5_0 Co-authored-by: Manuel de la Pena --- src/carplay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/carplay.cs b/src/carplay.cs index 2abb561483cb..70356c32b9ba 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -596,9 +596,11 @@ interface CPListSection : NSSecureCoding { [NullAllowed, Export ("sectionIndexTitle")] string SectionIndexTitle { get; } +#if !XAMCORE_5_0 [Export ("items", ArgumentSemantic.Copy)] [Obsolete ("Use 'Items : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } +#endif [Export ("items", ArgumentSemantic.Copy)] ICPListTemplateItem [] Items { get; } From 8a913185c93a5d8ce52155c37e2ec7b812e42dac Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 17:29:10 +0200 Subject: [PATCH 04/12] Wrap old api in #if XAMCORE_5_0 Co-authored-by: Manuel de la Pena --- src/carplay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/carplay.cs b/src/carplay.cs index 70356c32b9ba..708f2fb238e0 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -576,9 +576,11 @@ interface CPListSection : NSSecureCoding { [Obsolete ("Use 'CPListSection (ICPListTemplateItem [], string, string)' constructor instead.")] NativeHandle Constructor (CPListItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); +#if !XAMCORE_5_0 [Export ("initWithItems:")] [Obsolete ("Use 'CPListSection (ICPListTemplateItem [])' constructor instead.")] NativeHandle Constructor (CPListItem [] items); +#endif [Export ("initWithItems:header:sectionIndexTitle:")] NativeHandle Constructor (ICPListTemplateItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); From 644347e496cc5b707dd645126f9b6bd51ede72d0 Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 17:29:20 +0200 Subject: [PATCH 05/12] Wrap old api in #if XAMCORE_5_0 Co-authored-by: Manuel de la Pena --- src/carplay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/carplay.cs b/src/carplay.cs index 708f2fb238e0..6cf51a5ce775 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -572,9 +572,11 @@ interface CPListItem : CPSelectableListItem, NSSecureCoding { [DisableDefaultCtor] interface CPListSection : NSSecureCoding { +#if !XAMCORE_5_0 [Export ("initWithItems:header:sectionIndexTitle:")] [Obsolete ("Use 'CPListSection (ICPListTemplateItem [], string, string)' constructor instead.")] NativeHandle Constructor (CPListItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); +#endif #if !XAMCORE_5_0 [Export ("initWithItems:")] From 71c1aa93de9c2f884434016d2dfcb1e6805efaf5 Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 19:16:17 +0200 Subject: [PATCH 06/12] Apply proposed fix vor CPListSection.Items[] Co-authored-by: Manuel de la Pena --- src/carplay.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/carplay.cs b/src/carplay.cs index 6cf51a5ce775..fa6acc496bb5 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -601,13 +601,18 @@ interface CPListSection : NSSecureCoding { string SectionIndexTitle { get; } #if !XAMCORE_5_0 + [Sealed] [Export ("items", ArgumentSemantic.Copy)] - [Obsolete ("Use 'Items : ICPListTemplateItem []' instead.")] + [Obsolete ("Use 'Items2 : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } -#endif +#eendif [Export ("items", ArgumentSemantic.Copy)] +#if !XAMCORE_5_0 + ICPListTemplateItem [] Items2 { get; } +#else ICPListTemplateItem [] Items { get; } +#endif [iOS (14,0)] [Export ("indexOfItem:")] From 535f2accb6b5e8ea5d83965f551c47b58b942414 Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 20:24:31 +0200 Subject: [PATCH 07/12] Update src/carplay.cs Co-authored-by: Alex Soto --- src/carplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/carplay.cs b/src/carplay.cs index fa6acc496bb5..d85277734ffd 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -574,7 +574,7 @@ interface CPListSection : NSSecureCoding { #if !XAMCORE_5_0 [Export ("initWithItems:header:sectionIndexTitle:")] - [Obsolete ("Use 'CPListSection (ICPListTemplateItem [], string, string)' constructor instead.")] + [Obsolete ("Use '.ctor (ICPListTemplateItem [], string, string)' constructor instead.")] NativeHandle Constructor (CPListItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); #endif From 1231f050dec6f01615db8915d7e85983a8610324 Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 20:24:37 +0200 Subject: [PATCH 08/12] Update src/carplay.cs Co-authored-by: Alex Soto --- src/carplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/carplay.cs b/src/carplay.cs index d85277734ffd..41d238e06571 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -605,7 +605,7 @@ interface CPListSection : NSSecureCoding { [Export ("items", ArgumentSemantic.Copy)] [Obsolete ("Use 'Items2 : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } -#eendif +#endif [Export ("items", ArgumentSemantic.Copy)] #if !XAMCORE_5_0 From 93f9fb8f208d9b24cd539bbb56f6f77779d3b7fc Mon Sep 17 00:00:00 2001 From: janwiebe-jump <64576907+janwiebe-jump@users.noreply.github.com> Date: Fri, 5 Aug 2022 20:24:42 +0200 Subject: [PATCH 09/12] Update src/carplay.cs Co-authored-by: Alex Soto --- src/carplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/carplay.cs b/src/carplay.cs index 41d238e06571..6a8af1b049a3 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -580,7 +580,7 @@ interface CPListSection : NSSecureCoding { #if !XAMCORE_5_0 [Export ("initWithItems:")] - [Obsolete ("Use 'CPListSection (ICPListTemplateItem [])' constructor instead.")] + [Obsolete ("Use '.ctor (ICPListTemplateItem [])' constructor instead.")] NativeHandle Constructor (CPListItem [] items); #endif From ba73e1f451a5d6b4c0e57f8757ce5644662b6786 Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Mon, 8 Aug 2022 16:51:40 -0500 Subject: [PATCH 10/12] Update broken ctors to throw and fix build --- src/ObjCRuntime/ObsoleteConstants.cs | 2 ++ src/carplay.cs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ObjCRuntime/ObsoleteConstants.cs b/src/ObjCRuntime/ObsoleteConstants.cs index 5d37e8ae35d2..9af119ff7172 100644 --- a/src/ObjCRuntime/ObsoleteConstants.cs +++ b/src/ObjCRuntime/ObsoleteConstants.cs @@ -27,5 +27,7 @@ partial class Constants { internal const string RemovedFromChip = "This API has been removed from the 'CHIP' framework."; + internal const string BrokenBinding = "This API was incorrectly bound and does not work correctly. Use the new version indicated in the associated Obsolete attribute."; + } } diff --git a/src/carplay.cs b/src/carplay.cs index 6a8af1b049a3..c923f8fcf826 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -573,14 +573,14 @@ interface CPListItem : CPSelectableListItem, NSSecureCoding { interface CPListSection : NSSecureCoding { #if !XAMCORE_5_0 - [Export ("initWithItems:header:sectionIndexTitle:")] - [Obsolete ("Use '.ctor (ICPListTemplateItem [], string, string)' constructor instead.")] + [Wrap ("base (true ? throw new InvalidOperationException (Constants.BrokenBinding) : NSObjectFlag.Empty)")] + [Obsolete ("Use '.ctor (ICPListTemplateItem [], string, string)' constructor instead. Warning: this will throw InvalidOperationException at runtime.")] NativeHandle Constructor (CPListItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); #endif #if !XAMCORE_5_0 - [Export ("initWithItems:")] - [Obsolete ("Use '.ctor (ICPListTemplateItem [])' constructor instead.")] + [Wrap ("base (true ? throw new InvalidOperationException (Constants.BrokenBinding) : NSObjectFlag.Empty)")] + [Obsolete ("Use '.ctor (ICPListTemplateItem [], string, string)' constructor instead. Warning: this will throw InvalidOperationException at runtime.")] NativeHandle Constructor (CPListItem [] items); #endif From 8e48b2dbfebfc6aacf048270c31d6cedd17f4640 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Fri, 12 Aug 2022 10:25:47 -0400 Subject: [PATCH 11/12] Remove breaking change --- src/carplay.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/carplay.cs b/src/carplay.cs index c923f8fcf826..0c7d4b49ec5f 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -601,8 +601,7 @@ interface CPListSection : NSSecureCoding { string SectionIndexTitle { get; } #if !XAMCORE_5_0 - [Sealed] - [Export ("items", ArgumentSemantic.Copy)] + [Wrap ("throw new InvalidOperationException (Constants.BrokenBinding)", IsVirtual = true)] [Obsolete ("Use 'Items2 : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } #endif From 1fcaeca530e72a118d9e4292b849dd9aedc199bf Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Fri, 19 Aug 2022 20:47:44 -0400 Subject: [PATCH 12/12] [CarPlay] Fix build --- src/carplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/carplay.cs b/src/carplay.cs index 0c7d4b49ec5f..a50f77e692ca 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -601,7 +601,7 @@ interface CPListSection : NSSecureCoding { string SectionIndexTitle { get; } #if !XAMCORE_5_0 - [Wrap ("throw new InvalidOperationException (Constants.BrokenBinding)", IsVirtual = true)] + [Wrap ("true ? throw new InvalidOperationException (Constants.BrokenBinding) : new NSArray ()", IsVirtual = true)] [Obsolete ("Use 'Items2 : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } #endif