Bug 52665 - [generator] Deriving from certain protocol interfaces generates uncompilable code
Summary: [generator] Deriving from certain protocol interfaces generates uncompilable ...
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: master
Hardware: PC Mac OS
: Normal normal
Target Milestone: 15.3
Assignee: Alex Soto [MSFT]
Depends on:
Reported: 2017-02-22 12:10 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-05-18 16:46 UTC (History)
2 users (show)

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:

Description Rolf Bjarne Kvinge [MSFT] 2017-02-22 12:10:46 UTC
Test case:

using Foundation;
using SpriteKit;

namespace X {
	[Protocol] interface C15 : ISKWarpable {}


/var/folders/3d/m3cj039j7yg55lj4hrmfk9nw0000gn/T/8rxw7du5.c28/X/C15.g.cs(58,10): error CS0246: The type or namespace name `SKWarpGeometry' could not be found. Are you missing `SpriteKit' using directive?
Compilation failed: 1 error(s), 0 warnings
btouch-native: API binding contains errors.

Generated code: https://gist.github.com/rolfbjarne/194849f75ce19c64afb1a9ac1ad1fa33

The compiler error occurs in this line: https://gist.github.com/rolfbjarne/194849f75ce19c64afb1a9ac1ad1fa33#file-c15-g-cs-L58

The problem is that the type formatting prints "SKWarpGeometry" because it sees that the "WarpGeometry" property is from the "SKWarpable" class, and thinks we're generating code for "SKWarpable" (in which case the printed type would be correct, since we'd be in the SpriteKit namespace). Unfortunately we're generating code in a completely different class, which leads to the generated code being invalid.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-02-22 15:55:06 UTC
This can be reverted once this bug is fixed: https://github.com/xamarin/xamarin-macios/pull/1745/commits/75f2238ef3b2016c7d6b686060628c8f08a2e41f