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 e4f0c5a0d38e..a50f77e692ca 100644 --- a/src/carplay.cs +++ b/src/carplay.cs @@ -572,11 +572,23 @@ interface CPListItem : CPSelectableListItem, NSSecureCoding { [DisableDefaultCtor] interface CPListSection : NSSecureCoding { - [Export ("initWithItems:header:sectionIndexTitle:")] +#if !XAMCORE_5_0 + [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 - [Export ("initWithItems:")] +#if !XAMCORE_5_0 + [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 + + [Export ("initWithItems:header:sectionIndexTitle:")] + NativeHandle Constructor (ICPListTemplateItem [] items, [NullAllowed] string header, [NullAllowed] string sectionIndexTitle); + + [Export ("initWithItems:")] + NativeHandle Constructor (ICPListTemplateItem [] items); [iOS (15,0), MacCatalyst (15,0)] [Export ("initWithItems:header:headerSubtitle:headerImage:headerButton:sectionIndexTitle:")] @@ -588,8 +600,18 @@ interface CPListSection : NSSecureCoding { [NullAllowed, Export ("sectionIndexTitle")] string SectionIndexTitle { get; } - [Export ("items", ArgumentSemantic.Copy)] +#if !XAMCORE_5_0 + [Wrap ("true ? throw new InvalidOperationException (Constants.BrokenBinding) : new NSArray ()", IsVirtual = true)] + [Obsolete ("Use 'Items2 : ICPListTemplateItem []' instead.")] CPListItem [] Items { get; } +#endif + + [Export ("items", ArgumentSemantic.Copy)] +#if !XAMCORE_5_0 + ICPListTemplateItem [] Items2 { get; } +#else + ICPListTemplateItem [] Items { get; } +#endif [iOS (14,0)] [Export ("indexOfItem:")]