Bug 57870 - [generator] Smart enum wrapper doesn't work on setters
Summary: [generator] Smart enum wrapper doesn't work on setters
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: XI 10.99 (xcode9)
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Alex Soto [MSFT]
Depends on:
Reported: 2017-06-29 20:19 UTC by Vincent Dondain [MSFT]
Modified: 2018-02-06 16:35 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: No
Last known good build:


Description Vincent Dondain [MSFT] 2017-06-29 20:19:46 UTC

[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.

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)")]

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

Note You need to log in before you can comment on or make changes to this bug.