Skip to content

Commit bf8f472

Browse files
authored
[AppKit] Fix return type for NSStoryboard.InstantiateController / InstantiateInitialController. Fixes #23373. (#23400)
These two methods were bound with the wrong return type. Unfortunately there's no nice way of fixing APIs with the wrong return type, so there was no pretty way to do it. Fixes #23373.
1 parent 7dafe6c commit bf8f472

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/appkit.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18422,12 +18422,57 @@ interface NSStoryboard {
1842218422
[NullAllowed, Export ("mainStoryboard", ArgumentSemantic.Strong)]
1842318423
NSStoryboard MainStoryboard { get; }
1842418424

18425+
#if !XAMCORE_5_0
18426+
// Bound using the wrong return type, fix like this so that consuming code will work through breaking changes as long as warnings are fixed:
18427+
// * Add a '2' variant for !XAMCORE_5_0 with the correct return type
18428+
// * Obsolete the original variant in !XAMCORE_5_0 (with the wrong return type)
18429+
// * Obsolete the '2' variant for XAMCORE_5_0 (with the correct return type, but ugly name)
18430+
// * Make the original variant have the correct return type in XAMCORE_5_0
18431+
// * Remove the '2' variant in XAMCORE_6_0
18432+
[Obsolete ("Use 'InstantiateInitialController2' instead.")]
18433+
#endif
1842518434
[Export ("instantiateInitialControllerWithCreator:")]
1842618435
[return: NullAllowed]
18436+
#if XAMCORE_5_0
18437+
NSObject InstantiateInitialController ([NullAllowed] NSStoryboardControllerCreator handler);
18438+
#else
1842718439
NSViewController InstantiateInitialController ([NullAllowed] NSStoryboardControllerCreator handler);
18440+
#endif
1842818441

18442+
#if !XAMCORE_5_0
18443+
// Bound using the wrong return type, fix like this so that consuming code will work through breaking changes as long as warnings are fixed:
18444+
// * Add a '2' variant for !XAMCORE_5_0 with the correct return type
18445+
// * Obsolete the original variant in !XAMCORE_5_0 (with the wrong return type)
18446+
// * Obsolete the '2' variant for XAMCORE_5_0 (with the correct return type, but ugly name)
18447+
// * Make the original variant have the correct return type in XAMCORE_5_0
18448+
// * Remove the '2' variant in XAMCORE_6_0
18449+
[Obsolete ("Use 'InstantiateController2' instead.")]
18450+
#endif // !XAMCORE_5_0
1842918451
[Export ("instantiateControllerWithIdentifier:creator:")]
18452+
#if XAMCORE_5_0
18453+
NSObject InstantiateController (string identifier, [NullAllowed] NSStoryboardControllerCreator handler);
18454+
#else
1843018455
NSViewController InstantiateController (string identifier, [NullAllowed] NSStoryboardControllerCreator handler);
18456+
#endif
18457+
18458+
#if !XAMCORE_6_0
18459+
#if XAMCORE_5_0
18460+
[Obsolete ("Use 'InstantiateController' instead.")]
18461+
#else
18462+
[Sealed]
18463+
#endif // XAMCORE_5_0
18464+
[Export ("instantiateInitialControllerWithCreator:")]
18465+
[return: NullAllowed]
18466+
NSObject InstantiateInitialController2 ([NullAllowed] NSStoryboardControllerCreator handler);
18467+
18468+
#if XAMCORE_5_0
18469+
[Obsolete ("Use 'InstantiateController' instead.")]
18470+
#else
18471+
[Sealed]
18472+
#endif // XAMCORE_5_0
18473+
[Export ("instantiateControllerWithIdentifier:creator:")]
18474+
NSObject InstantiateController2 (string identifier, [NullAllowed] NSStoryboardControllerCreator handler);
18475+
#endif // XAMCORE_6_0
1843118476
}
1843218477

1843318478
[NoMacCatalyst]

tests/cecil-tests/Documentation.KnownFailures.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7894,6 +7894,8 @@ M:AppKit.NSStatusItem.add_DoubleClick(System.EventHandler)
78947894
M:AppKit.NSStatusItem.Dispose(System.Boolean)
78957895
M:AppKit.NSStatusItem.remove_DoubleClick(System.EventHandler)
78967896
M:AppKit.NSStepperTouchBarItem.Dispose(System.Boolean)
7897+
M:AppKit.NSStoryboard.InstantiateController2(System.String,AppKit.NSStoryboardControllerCreator)
7898+
M:AppKit.NSStoryboard.InstantiateInitialController2(AppKit.NSStoryboardControllerCreator)
78977899
M:AppKit.NSStringAttributes.SetStrikethroughStyle(Foundation.NSUnderlineStyle,AppKit.NSUnderlinePattern,System.Boolean)
78987900
M:AppKit.NSStringAttributes.SetUnderlineStyle(Foundation.NSUnderlineStyle,AppKit.NSUnderlinePattern,System.Boolean)
78997901
M:AppKit.NSTableCellView.Dispose(System.Boolean)

0 commit comments

Comments
 (0)