Bug 57797 - BindAs attribute for smart enums of an array of nullable values generates code that doesn't compile
Summary: BindAs attribute for smart enums of an array of nullable values generates cod...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: master
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Alex Soto [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-06-27 14:56 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-11-13 17:02 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: No
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 Rolf Bjarne Kvinge [MSFT] 2017-06-27 14:56:51 UTC
Code:

	[BindAs (typeof (AVMediaTypes?[]))]
	[Export ("strongNullableAVMediaTypesProperties:")]
	NSString[] StrongNullableAVMediaTypesProperties { get; set; }

results in:

	error CS1026: ) expected
	error CS1056: Unexpected character '`'
	error CS1003: Syntax error, ',' expected
	error CS1003: Syntax error, ']' expected
	error CS1003: Syntax error, ',' expected
	error CS1003: Syntax error, ',' expected
	error CS1003: Syntax error, ',' expected
	error CS1026: ) expected
	error CS1001: Identifier expected
	error CS1031: Type expected
	error CS1022: Type or namespace definition, or end-of-file expected
	error CS0116: A namespace cannot directly contain members such as fields or methods
	error CS1022: Type or namespace definition, or end-of-file expected
	error CS8124: Tuple must contain at least two elements.
	error CS1022: Type or namespace definition, or end-of-file expected
	error CS1022: Type or namespace definition, or end-of-file expected

I think the easiest here would be to disallow this in the generator, at least until we know there's a need for it.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-06-27 18:51:42 UTC
Another test case, with NSValue instead of smart enum:

	[Export ("PCATransform3DNullableArray")]
	[BindAs (typeof (CATransform3D?[]))]
	NSValue[] PCATransform3DNullableArrayValue { get; set; }
Comment 2 Alex Soto [MSFT] 2017-11-03 04:39:18 UTC
PR: https://github.com/xamarin/xamarin-macios/pull/2954
Comment 3 Alex Soto [MSFT] 2017-11-09 01:14:00 UTC
The PR was updated to show an error because registrar wasn't happy and kept the generator changes so whenever we implement this we still generate valid code.

PR: https://github.com/xamarin/xamarin-macios/pull/2954

Awaiting Rolf's review.
Comment 4 Alex Soto [MSFT] 2017-11-13 17:02:57 UTC
Fixed in xamarin-macios/master @ https://github.com/xamarin/xamarin-macios/commit/ee19c79febbe2a56bc67ad106248aa96abce0353