Bug 58403 - Mismatching listener types/members generated broken event name
Summary: Mismatching listener types/members generated broken event name
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 7.4 (15.3)
Hardware: PC Mac OS
: --- normal
Target Milestone: 15.5
Assignee: Atsushi Eno
Depends on:
Reported: 2017-07-25 22:16 UTC by Matthew Leibowitz
Modified: 2017-09-11 16:49 UTC (History)
3 users (show)

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

Binding project (125.75 KB, application/zip)
2017-07-25 22:16 UTC, Matthew Leibowitz

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 or GitHub 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:

Description Matthew Leibowitz 2017-07-25 22:16:47 UTC
Created attachment 23801 [details]
Binding project

I have a method on my Java class:

  public class MenuView extends LinearLayout {
    public void setOnVisibleWidthChanged(OnVisibleWidthChangedListener listener) {
      this.mOnVisibleWidthChangedListener = listener;
    public interface OnVisibleWidthChangedListener {
        void onItemsMenuVisibleWidthChanged(int newVisibleWidth);

When the generator runs, it creates an event named:


I believe the correct event name should have been:


As you can see, the event name hass basically the length of "Listener" cropped off.

A workaround is to add this:


Java source: https://github.com/arimorty/floatingsearchview
Comment 1 Jon Douglas [MSFT] 2017-07-26 02:17:43 UTC
I can CONFIRM this behavior:


I am also in agreement that the correct name should be "VisibleWidthChanged". The fact that it removes 8 characters the same amount in "Listener" seems to be coincidence perhaps? Perhaps this is a class-parse bug?
Comment 2 Atsushi Eno 2017-09-05 18:03:09 UTC
Jon is right on "Listener" part: it is a bug that this should not result in any event listener generation because it does not match the expected pattern. Anything that does not follow the pattern should not be handled. It is a generator issue (not class-parse; the resulting `api.xml` should contain the expected description).

The expected behavior is for example, `setOnClickListener` should become `Click` (removing `setOn` and `Listener`).
Comment 3 Atsushi Eno 2017-09-05 18:55:53 UTC
Removing those non-set-Listener methods actually results in Mono.Android ABI breakage (which can be manually fixed). It is expected and should be acceptable.

Though another solution to just treat set-"non-listener" methods as potential events turned out to not be that bad because the constraint on the arguments (only one parameter of Listener type is acceptable) is strong enough to not explode chances to add events, so I'd rather go for that approach.

PR is created based on this option: https://github.com/xamarin/java.interop/pull/181

(There was no ABI changes, even no additions.)

jonp will ask for tests which is quite annoying to create at this state, so the PR won't be applied anytime soon.
Comment 4 Jonathan Pryor 2017-09-11 16:49:12 UTC
Fixed in:


Should be fixed in Xamarin.Android or later, which includes all 8.1.x releases.