Xamarin后门调用 - 注册商发现该方法中存在签名不匹配

问题描述 投票:0回答:2

我想在Xamarin ui测试中调用后门。对于一种方法,我需要传递一些参数,但它会导致签名不匹配。我遵循官方文档(https://developer.xamarin.com/api/member/Xamarin.UITest.IApp.Invoke/p/System.String/System.Object[]/),所以不知道为什么或哪里出错。

这是我的应用程序代码(AppDelegate.cs)

    [Export("ConfigurationBackdoor:")]
    public void ConfigurationBackdoor(NSString configuration, NSString configurationName)
            {
   BackdoorHelper.ConfigurationEventBackdoor(configuration, configurationName);
            }

这是我的xamarin ui测试代码:

object[] arguments = { "arg1", "arg2" };
AppContext.App.Invoke("ConfigurationBackdoor:", arguments);

有人知道为什么这不起作用?在Android上,它工作正常顺便说一句。提前致谢!

c# xamarin xamarin.uitest
2个回答
1
投票

显然,Xamarin UI测试不允许iOS的多个参数。在Android上它不是问题,但在iOS上你只能使用一个参数。就像它在文档中描述的那样(https://docs.microsoft.com/en-us/appcenter/test-cloud/uitest/working-with-backdoors)。

The method must take a parameter of NSString. 

所以我有点创意,并把一个json字符串作为参数。


0
投票

方法签名可能不正确(只有一个参数)。尝试“configurationBackdoor:withConfigurationName:”。将此签名放在两个位置(导出和调用)。

© www.soinside.com 2019 - 2024. All rights reserved.