Bug 8101 - Bindings need to escape generated property names
Summary: Bindings need to escape generated property names
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.2.x
Hardware: PC Windows
: Normal normal
Target Milestone: master
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2012-10-31 11:55 UTC by Jeremy Kolb
Modified: 2016-09-22 06:59 UTC (History)
3 users (show)

Tags: XATriaged
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 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:
Status:
RESOLVED FIXED

Description Jeremy Kolb 2012-10-31 11:55:43 UTC
I need to use droidtext (http://code.google.com/p/droidtext/) in my project but am hitting a lot of cases where field names are like the following: "_3D".  The bindings try to generate a property name "3D" for this which gets us into trouble.  I think that instead the bindings should keep the leading underscore if a number immediately follows it.
Comment 1 Atsushi Eno 2012-10-31 15:12:07 UTC
For Android API bindings such names that begin with a number are forced to be explicitly named manually, like android/view/KeyEvent.KEYCODE_3D_MODE field becomes enum value Keycode.ThreeDMode (not Keycode.3DMode which is invalid). I don't think our naming of fields are not very simple to introduce such special escaping. Also at least we believed that there shouldn't be such a lot of "public" fields whose name begin with _.

I think it shouldn't be very difficult to create such a java tool that iterates all the fields in all the classes and generate part of Metadata.xml so far.
Comment 2 Jeremy Kolb 2012-10-31 15:24:52 UTC
I agree that naming fields beginning with _ is stupid.  I guess it's not a big deal because as you say there shouldn't be too many of them and we can explicitly rename them.
Comment 3 Atsushi Eno 2016-09-22 06:59:47 UTC
We now output warnings. https://github.com/xamarin/java.interop/pull/69