Skip to content

Commit

Permalink
[generator] Don't trim 8 name chars on non-set-listeners. (#181)
Browse files Browse the repository at this point in the history
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58403

An event names is generated from the method name which was supposed to be
`setOnXxxListener()`. Though we had been generating events for methods that
do not end with "Listener", resulting in weird event names (e.g. it was
"VisibleWidt" for `setOnVisibleWidthChanged` method).

Trim trailing 8 characters only on `setOnXxx**Listener**()` methods.
  • Loading branch information
atsushieno authored and jonpryor committed Sep 6, 2017
1 parent 7d9d72a commit 2986b24
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/generator/Method.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ internal string CalculateEventName (Func<string, bool> checkNameDuplicate)
{
string event_name = EventName;
if (event_name == null) {
event_name = Name.Substring (0, Name.Length - 8).Substring (3);
var trimSize = Name.EndsWith ("Listener", StringComparison.Ordinal) ? 8 : 0;
event_name = Name.Substring (0, Name.Length - trimSize).Substring (3);
if (event_name.StartsWith ("On"))
event_name = event_name.Substring (2);
if (checkNameDuplicate (event_name))
Expand Down

0 comments on commit 2986b24

Please sign in to comment.