Bug 17788 - Generated code references members which don't exist.
Summary: Generated code references members which don't exist.
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.13.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2014-02-14 16:43 UTC by Jonathan Pryor
Modified: 2014-07-08 06:27 UTC (History)
2 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 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:
VERIFIED FIXED

Description Jonathan Pryor 2014-02-14 16:43:00 UTC
In some circumstances generator.exe doesn't properly validate names, resulting in invalidly generated code, e.g.

	// Note: has non-default constructor, has no Handler member:
	internal sealed class ISignatureListenerImplementor : global::Java.Lang.Object, ISignatureListener {

		object sender;

		public ISignatureListenerImplementor (object sender)
			: base (...)
		{
			global::Android.Runtime.JNIEnv.FinishCreateInstance (Handle, "()V");
			this.sender = sender;
		}

		public SignatureOnSignatureRequestedHandler OnSignatureRequestedHandler;

		public RetType OnSignatureRequested (Request p0)
		{
			var __h = OnSignatureRequestedHandler;
			return __h != null ? __h (p0) : default (RetType)
		}
		public EventHandler OnSignatureTimedOutHandler;

		public void OnSignatureTimedOut ()
		{
			var __h = OnSignatureTimedOutHandler;
			if (__h != null)
				__h (sender, new EventArgs ());
		}

		internal static bool __IsEmpty (ISignatureListenerImplementor value)
		{
			return value.OnSignatureRequestedHandler == null && value.OnSignatureTimedOutHandler == null;
		}
	}

Aside: the above type should be `partial`.

The above type is fine, as it goes, but the generated event which uses the type is FUBAR:

	public SignatureOnSignatureRequestedHandler SignatureRequested {
		get {
			ISignatureListenerImplementor impl = ImplSignatureRequested;
			return impl == null ? null : impl.Handler;
		}
		set {
			ISignatureListenerImplementor impl = ImplSignatureRequested;
			if (impl == null) {
				impl = new global::Com.Adyen.Library.Callbacks.ISignatureListenerImplementor ();
				ImplSignatureRequested = impl;
			} else
				impl.OnSignatureRequestedHandler = value;
		}
	}

Why is it trying to reference a Handler member which doesn't exist? Why is it trying to use a non-default constructor? The other (void-returning) event is correct.

This results in the errors:

	error CS1061: Type ... does not contain a definition for `Handler' and no extension method `Handler' ...
	error CS1729: The type ... does not contain a constructor that takes `0' arguments
Comment 2 Atsushi Eno 2014-02-19 10:27:29 UTC
Handler should be actually SignatureRequestedHandler. That kind of code is generated only when there are more than one listener methods involved and come without adjusted eventName, which did not actually occur in any standard libraries (android.jar, support-*.jar, play services etc.).

This part of the issue is fixed. [master 86353d3]
Comment 3 Atsushi Eno 2014-02-19 11:07:17 UTC
Fixed the "missing sender argument in the constructor" issue too.

[master 27e3d68]
Comment 4 Udham Singh 2014-07-08 06:27:01 UTC
We have checked this issue with sample application attached in comment 1, now this is working fine and we are able to build the sample application attached in comment 1 successfully. Hence closing this issue.

Screencast : http://www.screencast.com/t/PnPSGLhV08GG

Environment Info : 

=== Xamarin Studio ===

Version 5.2 (build 180)
Installation UUID: 3dbf10c4-ed30-4e55-8a8b-1704777c7b5f
Runtime:
	Mono 3.6.0 ((no/a653694)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000000

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===

Version: 7.2.6.17 (Business Edition)
Hash: 762ebac
Branch: 
Build date: 2014-07-03 15:53:37-0400

=== Xamarin.Android ===

Version: 4.14.0 (Business Edition)
Android SDK: /Users/apprpject/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.Mac ===

Version: 1.8.1.0

=== Build Information ===

Release ID: 502000180
Git revision: c27cfff0160e6f3d8ad82b57be030d6adf866743
Build date: 2014-07-04 18:06:04-04
Xamarin addins: 68026ad1ccee9923e927d9cfcca408d673d5ab61

=== Operating System ===

Mac OS X 10.8.5
Darwin localhost 12.5.0 Darwin Kernel Version 12.5.0
    Sun Sep 29 13:33:47 PDT 2013
    root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64