Bug 20327 - TextField's Changed event ActionAttribute selector name does not contain a ":"
Summary: TextField's Changed event ActionAttribute selector name does not contain a ":"
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS Designer ()
Version: 3.0
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Vinicius Jarina
URL:
Depends on:
Blocks:
 
Reported: 2014-06-04 02:07 UTC by Mikael Nensén
Modified: 2014-07-10 18:28 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mikael Nensén 2014-06-04 02:07:28 UTC
Running against an emulator works.

Trying to publish to a real device results in the following error:
MT4117:The registrar found a signature mismatch in the method 'XS_SingleView.XS_SingleViewViewController.TextFieldInput_Changed' - the selector 'TextFieldInput_Changed' indicates the method takes 0 parameters, while the managed method has 1 parameters.

If I manually add ":" to the selector name I can publish to the device but I get a NSInvalidArgumentException when the app runs and the event triggers:
[Action ("TextFieldInput_Changed")] -> [Action ("TextFieldInput_Changed:")]
Comment 1 Mikael Nensén 2014-06-04 02:08:17 UTC
This was all dune using iPad storyboard. 

This is the generated code:
[Action ("TextFieldInput_Changed")]
[GeneratedCode ("iOS Designer", "1.0")]
partial void TextFieldInput_Changed (UITextField sender);
Comment 2 Mikael Nensén 2014-06-04 09:01:23 UTC
There are probably a lot of other instances when the ":" is not added to the action attribute selector name, another example is the UIBarButtonItem's action event.

A workaround is to remove the generated code and do the following:
[Action("ContinueButton_Action")]
private void ContinueButton_Action()
{
    ContinueButton_Action(ContinueButton);
}

[Action("ContinueButton_Action:")]
private void ContinueButton_Action(UIBarButtonItem sender)
{
    // TODO
}

The only problem is that as soon as you make any changes to the storyboard the designer file gets regenerated and the original partial void method is back with the action attribute.
Comment 3 Alan McGovern 2014-06-12 14:18:17 UTC
"ContinueButton_Action" is a function with no parameters but 'ContinueButton_Action:' is a function which takes one parameter.

There are two workarounds to achieve what you want:
1) Open the storyboard file in a text editor, search for 'ContinueButton_Action' inside an <action /> declaration and append an ":" to the name. Then the function we are generating will match the selector and iOS will be happy.

2) With Xamarin Studio 5.1+ you can move the declaration from your .designer.cs file into your main cs file and remove the 'UIBarButtonItem sender' parameter. Once there is a function with '[Action("ContinueButton_Action")]' on it, the designer will stop generating one in the .designer.cs file. This way you will have a C# function with no parameters, which is what should happen when your selector does not have a ':' at the end.

From our side we will fix our code generation step to correctly generate either a parameterless function, or a function with one parameter.
Comment 5 Alan McGovern 2014-07-10 18:27:41 UTC
This has been fixed already
Comment 6 Alan McGovern 2014-07-10 18:28:33 UTC
oops, clicked 'save' too early.

The fix for this was included in 5.1, but there was a bug which makes 5.1 unusable. We've just addressed that bug and will be issuing some new builds once the changes have been QA'ed.