Bug 55536 - [btouch] Enabling --process-enums on a project with StructsAndEnums.cs set as ObjcBindingCoreSource give build error
Summary: [btouch] Enabling --process-enums on a project with StructsAndEnums.cs set as...
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: XI 10.10 (d15-2)
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Vincent Dondain [MSFT]
Depends on:
Reported: 2017-04-24 20:16 UTC by Vincent Dondain [MSFT]
Modified: 2017-04-25 15:11 UTC (History)
3 users (show)

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

Test case (465.24 KB, application/zip)
2017-04-25 15:11 UTC, Alex Soto [MSFT]

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 for Bug 55536 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Vincent Dondain [MSFT] 2017-04-24 20:16:04 UTC
This is the project I could reproduce this bug with: https://developer.xamarin.com/samples/monotouch/InfColorPicker/

Repro steps:

- Open InfColorPickerBinding.sln
- Go the the binding project project's options > Objective C Binding Build > Select "Process enums as bindings instead of external types".
- Re-build.

You should get the following build error:

`obj/Debug/ios/InfColorPicker/InfComponentIndex.g.cs(38,14,38,31): error CS0101: The namespace 'InfColorPicker' already contains a definition for 'InfComponentIndex'`


Change `StructsAndEnums.cs` build action to: "ObjcBindingApiDefinition".

Environment used: https://gist.github.com/VincentDondain/2aac9232a19b989303317bf432449613
Comment 1 Alex Soto [MSFT] 2017-04-24 22:52:13 UTC
I can confirm this happens with latest xamarin-macios/master @ dce730ddb7bdf8d7c2d3d460b0f141ede125a84e
Comment 2 Sebastien Pouliot 2017-04-25 13:26:01 UTC
@Vincent please attach build logs whenever you're quoting from them.

This looks like a sample issue. By default the same enum can be put inside both "API definition" (because it won't be generated) and in the manual `StructsAndEnums.cs` file. Once compiled together you end up with a single (non generated) enum type.

Now if you enable enum processing then the enum from "API definition" will be generated and will collide with the same one from the manual file.

The proposed workaround might compile (in this case) but is likely not producing the same final API (missing all structs). In fact "one does not simply" enable --process-enums and expect identical output ;-) You need to update/move enums inside the bindings project.

The fix is to either:

1. Correct the sample (if there's some value to enabling enum processing on it) to work when processing enums;

2. Leave the sample as is, since it works with older versions of XI;
Comment 3 Vincent Dondain [MSFT] 2017-04-25 15:06:00 UTC
Oops indeed, forgot the build output: https://gist.github.com/VincentDondain/3734cd926fb17bb84a9d91387fb3229f

"Now if you enable enum processing then the enum from "API definition" will be generated and will collide with the same one from the manual file."

^ that would have been my assumption too however the enum isn't defined twice it's only defined once in `StructsAndEnums.cs`

I believe this was Alex's question too when I asked him but that's why he confirmed the bug.
Comment 4 Alex Soto [MSFT] 2017-04-25 15:11:45 UTC
Created attachment 21764 [details]
Test case

Project to repro

> InfColorPicker/InfColorPickerBinding/InfColorPickerBinding.sln