From dde10f274d067123eb39182e66d88fdf59cb0644 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 13 Apr 2023 12:28:48 +0200 Subject: [PATCH 1/2] [src] Fix containing namespace/framework for AVCustomRoutingControllerDelegate. The AVCustomRoutingControllerDelegate protocol was incorrectly placed in the AVKit framework, instead of the AVRouting framework where it currently belongs (this might have been a change between betas at some point). So move AVCustomRoutingControllerDelegate to the AVRouting namespace, but only in XAMCORE_5_0, because otherwise it would be a breaking change. In the meantime, special case the AVCustomRoutingControllerDelegate type so that we correctly link with the AVRouting framework when it's used. --- src/avkit.cs | 23 --------------------- src/avrouting.cs | 36 +++++++++++++++++++++++++++++++++ tools/common/Frameworks.cs | 11 ++++++++-- tools/common/StaticRegistrar.cs | 5 +++++ tools/common/Target.cs | 6 ++++++ 5 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/avkit.cs b/src/avkit.cs index 5ac8802e44a0..ca654b8a0af1 100644 --- a/src/avkit.cs +++ b/src/avkit.cs @@ -1135,27 +1135,4 @@ interface AVPlaybackSpeed { [Export ("localizedNumericName")] string LocalizedNumericName { get; } } - - delegate void AVCustomRoutingControllerDelegateCompletionHandler (bool success); - - interface IAVCustomRoutingControllerDelegate { } - - [NoWatch, NoTV, NoMac, iOS (16, 0), MacCatalyst (16, 0)] -#if NET - [Protocol, Model] -#else - [Protocol, Model (AutoGeneratedName = true)] -#endif - [BaseType (typeof (NSObject))] - interface AVCustomRoutingControllerDelegate { - [Abstract] - [Export ("customRoutingController:handleEvent:completionHandler:")] - void HandleEvent (AVCustomRoutingController controller, AVCustomRoutingEvent @event, AVCustomRoutingControllerDelegateCompletionHandler completionHandler); - - [Export ("customRoutingController:eventDidTimeOut:")] - void EventDidTimeOut (AVCustomRoutingController controller, AVCustomRoutingEvent @event); - - [Export ("customRoutingController:didSelectItem:")] - void DidSelectItem (AVCustomRoutingController controller, AVCustomRoutingActionItem customActionItem); - } } diff --git a/src/avrouting.cs b/src/avrouting.cs index 7ca0c4763cd6..04edb33fdf77 100644 --- a/src/avrouting.cs +++ b/src/avrouting.cs @@ -99,6 +99,42 @@ interface AVCustomRoutingController { NSString AuthorizedRoutesDidChangeNotification { get; } } +// The AVCustomRoutingControllerDelegate type was incorrectly placed in the AVKit framework. +#if !XAMCORE_5_0 +} +namespace AVKit { + using AVRouting; +#endif + + delegate void AVCustomRoutingControllerDelegateCompletionHandler (bool success); + + interface IAVCustomRoutingControllerDelegate { } + + [NoWatch, NoTV, NoMac, iOS (16, 0), MacCatalyst (16, 0)] +#if NET + [Protocol, Model] +#else + [Protocol, Model (AutoGeneratedName = true)] +#endif + [BaseType (typeof (NSObject))] + interface AVCustomRoutingControllerDelegate { + [Abstract] + [Export ("customRoutingController:handleEvent:completionHandler:")] + void HandleEvent (AVCustomRoutingController controller, AVCustomRoutingEvent @event, AVCustomRoutingControllerDelegateCompletionHandler completionHandler); + + [Export ("customRoutingController:eventDidTimeOut:")] + void EventDidTimeOut (AVCustomRoutingController controller, AVCustomRoutingEvent @event); + + [Export ("customRoutingController:didSelectItem:")] + void DidSelectItem (AVCustomRoutingController controller, AVCustomRoutingActionItem customActionItem); + } + +#if !XAMCORE_5_0 +} +namespace AVRouting { +#endif + + [NoWatch, NoTV, NoMac, iOS (16, 0), MacCatalyst (16, 0)] [BaseType (typeof (NSObject))] interface AVCustomRoutingEvent { diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index b73f53206883..06aaae243cf4 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -736,9 +736,16 @@ static void Gather (Application app, AssemblyDefinition product_assembly, HashSe var namespaces = new HashSet (); // Collect all the namespaces. - foreach (ModuleDefinition md in product_assembly.Modules) - foreach (TypeDefinition td in md.Types) + foreach (ModuleDefinition md in product_assembly.Modules) { + foreach (TypeDefinition td in md.Types) { +#if !XAMCORE_5_0 + // AVCustomRoutingControllerDelegate was incorrectly placed in AVKit + if (td.Namespace == "AVKit" && td.Name == "AVCustomRoutingControllerDelegate") + namespaces.Add ("AVRouting"); +#endif namespaces.Add (td.Namespace); + } + } // Iterate over all the namespaces and check which frameworks we need to link with. var all_frameworks = GetFrameworks (app.Platform, app.IsSimulatorBuild); diff --git a/tools/common/StaticRegistrar.cs b/tools/common/StaticRegistrar.cs index 5ca288786f2f..e71bc79917bb 100644 --- a/tools/common/StaticRegistrar.cs +++ b/tools/common/StaticRegistrar.cs @@ -2166,6 +2166,11 @@ void CheckNamespace (TypeReference type, List exceptions) var ns = type.Namespace; +#if !XAMCORE_5_0 + // AVCustomRoutingControllerDelegate was incorrectly placed in AVKit + if (type.Is ("AVKit", "AVCustomRoutingControllerDelegate")) + ns = "AVRouting"; +#endif Framework framework; if (Driver.GetFrameworks (App).TryGetValue (ns, out framework)) { if (framework.Version > App.SdkVersion) { diff --git a/tools/common/Target.cs b/tools/common/Target.cs index 30fd6c932125..169f6d7f43f8 100644 --- a/tools/common/Target.cs +++ b/tools/common/Target.cs @@ -199,6 +199,12 @@ public void GatherFrameworks () foreach (TypeDefinition td in md.Types) { // process only once each namespace (as we keep adding logic below) string nspace = td.Namespace; +#if !XAMCORE_5_0 + // AVCustomRoutingControllerDelegate was incorrectly placed in AVKit + if (td.Is ("AVKit", "AVCustomRoutingControllerDelegate")) + nspace = "AVRouting"; +#endif + if (processed.Contains (nspace)) continue; processed.Add (nspace); From 9f1fcb2bb0c9041accb0576d673c90ca6fc4c161 Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Tue, 25 Apr 2023 12:34:52 +0000 Subject: [PATCH 2/2] Auto-format source code --- src/avrouting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/avrouting.cs b/src/avrouting.cs index 04edb33fdf77..b31fcaee1635 100644 --- a/src/avrouting.cs +++ b/src/avrouting.cs @@ -99,7 +99,7 @@ interface AVCustomRoutingController { NSString AuthorizedRoutesDidChangeNotification { get; } } -// The AVCustomRoutingControllerDelegate type was incorrectly placed in the AVKit framework. + // The AVCustomRoutingControllerDelegate type was incorrectly placed in the AVKit framework. #if !XAMCORE_5_0 } namespace AVKit {