Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uikit] Preserve method associated with updateSearchResultsForSearchController:. Fixes #5024 #5027

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/UIKit/UISearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#if !WATCH

using System;
using Foundation;

namespace UIKit {

Expand All @@ -17,6 +18,8 @@ public __Xamarin_UISearchResultsUpdating (Action<UISearchController> cback)
this.cback = cback;
IsDirectBinding = false;
}

[Preserve (Conditional = true)] // called back from native, no direct managed reference (except on the type itself)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't overriding an exported method be enough to make the linker preserve it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - the override should have been enough to automagically preserve it (and it would explain why it, likely, worked before). It's possible that logic got broken and, in most cases (user code) the override would not be linked (so this would hide the issue)

public override void UpdateSearchResultsForSearchController (UISearchController searchController)
{
cback (searchController);
Expand Down
14 changes: 14 additions & 0 deletions tests/linker/ios/link sdk/LinkSdkRegressionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,20 @@ public void TlsProvider_Apple ()
Assert.NotNull (provider, "provider");
Assert.That (provider.ID, Is.EqualTo (new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c")), "correct provider");
}

[Test]
public void Github5024 ()
{
TestRuntime.AssertXcodeVersion (6,0);
var sc = new UISearchController ((UIViewController) null);
sc.SetSearchResultsUpdater ((vc) => { });

var a = typeof (UISearchController).AssemblyQualifiedName;
var n = a.Replace ("UIKit.UISearchController", "UIKit.UISearchController+__Xamarin_UISearchResultsUpdating");
var t = Type.GetType (n);
Assert.NotNull (t, "private inner type");
Assert.IsNotNull (t.GetMethod ("UpdateSearchResultsForSearchController"), "preserved");
}
#endif // !__WATCHOS__

[Test]
Expand Down