Bug 57870 - [generator] Smart enum wrapper doesn't work on setters
Summary: [generator] Smart enum wrapper doesn't work on setters
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: XI 10.99 (xcode9)
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: 15.7
Assignee: Alex Soto [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-06-29 20:19 UTC by Vincent Dondain [MSFT]
Modified: 2018-03-08 21:06 UTC (History)
3 users (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 Vincent Dondain [MSFT] 2017-06-29 20:19:46 UTC
Problem:

[Wrap ("HMPresenceTypeExtensions.GetValue (_PresenceType)")]
HMPresenceType PresenceType { get; set; }

where _PresenceType is:

[Export ("presenceType")]
NSString _PresenceType { get; set; }

The generated code for the getter is fine but wrong for the setter.

[CompilerGenerated]
public HMPresenceType PresenceType {
	get {
		return (HMPresenceType) (HMPresenceTypeExtensions.GetValue (_PresenceType));
	}
	set {
		HMPresenceTypeExtensions.GetValue (_PresenceType) = value;
	}
}

Idk if we should support `[Wrap ("_PresenceType")]` or `BindAs`.
Comment 1 Sebastien Pouliot 2017-08-03 18:59:16 UTC
Changing how `[Wrap]` works will likely cause other issues and it's also confusing.
I think we should be using something like:

	HMPresenceType PresenceType {
		[Wrap ("HMPresenceTypeExtensions.GetValue (_PresenceType)")]
		get; 
		[NotImplemented]
		set; 
	}

but it still require a small fix to avoid

> error BI1018: bgen: No [Export] attribute on property HomeKit.HMPresenceEvent.PresenceType

That check should be relaxed if the getter and setters (when presents) have [Wrap], [Export], [BindAs] or [NotImplemented].

FWIW it always bugged me to do something like

	[Export ("advertisingTrackingEnabled")]
	bool IsAdvertisingTrackingEnabled { [Bind ("isAdvertisingTrackingEnabled")] get; }

since the [Export] is ignored (when no setter is present).
Comment 2 Sebastien Pouliot 2017-08-11 15:53:19 UTC
Not required to ship `xcode9` support. We want to minimize changes (and potential regression) from stable on this branch.
Comment 3 Alex Soto [MSFT] 2018-02-06 16:35:24 UTC
Fixed in xamarin-macios/master @ https://github.com/xamarin/xamarin-macios/commit/dca6d7988137199793a3820bf3923b818fa95118