Skip to content

Commit

Permalink
Fix #9996 and #15622 (#15642)
Browse files Browse the repository at this point in the history
As discussed in #9996 the CPListSection constructors are not fully correct, since the CPListImageRowItem can't be added to it, which is possible in the native iOS SDK.
This PR fixes that. With that, also #15622 seems to be fixed.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
  • Loading branch information
5 people authored Aug 22, 2022
1 parent 599ae5a commit e515b5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ObjCRuntime/ObsoleteConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.";

}
}
28 changes: 25 additions & 3 deletions src/carplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:")]
Expand All @@ -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:")]
Expand Down

6 comments on commit e515b5c

@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.

Please sign in to comment.