Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generator] Backport smart enum fixes from master #1105

Merged
merged 3 commits into from
Nov 3, 2016

Conversation

spouliot
Copy link
Contributor

@spouliot spouliot commented Nov 3, 2016

No description provided.

This allows us to convert some existing manual conversion code into
generated code and never miss a new constant being added [1].

The additional control comes in two forms:

* allow [Field (null)]: a null NSString constant will return this
  enum value instead of throwing an ArgumentNullException;

* a new `[DefaultEnumValue]` attribute allow marking the constant to be
  returned if the enum value is not known;

[1] Vincent found some missing in HomeKit when adding the new ones
from iOS 10.

This commits also adds documentation for the existing (missing) and
new attributes.
…6285 (dotnet#1102)

Considering the following binding code:

    public enum HMAccessoryCategoryType {
        [Field ("HMAccessoryCategoryTypeGarageDoorOpener")]
        DoorOpener,

        GarageDoorOpener = DoorOpener,
    }

We must

1. Ensure that `HMAccessoryCategoryType.DoorOpener.GetConstant () ==
	HMAccessoryCategoryType.GarageDoorOpener.GetConstant ()`;

This is done by using the numeric value of the enum member (instead of the name)

2. Ensure that `HMAccessoryCategoryTypeExtensions.GetValue ("HMAccessoryCategoryTypeGarageDoorOpener")`
   always return the same enum value, i.e. it can **not** change between
   XI versions (e.g. due to reflection ordering) as it could break
   comparison code;

This is done by only adding a map to the member that has a [Field] and
means that:

2.1. the _favorite_ enum member should be the one with the [Field]; and

2.2. a [Field] value can only be used once per enum (or else we report
     an BI1046 error). This also solve the duplicate code generation for
	 the constant loading code;

Reference:
* https://bugzilla.xamarin.com/show_bug.cgi?id=46285
@monojenkins
Copy link
Collaborator

Build success

@spouliot spouliot merged commit 807d223 into dotnet:xcode8.2 Nov 3, 2016
@spouliot spouliot deleted the xcode82-update-generator branch November 3, 2016 12:11
spouliot added a commit to spouliot/xamarin-macios that referenced this pull request Nov 6, 2018
Commit list for xamarin/Xamarin.MacDev:

* dotnet/macios-devtools@49a17b1 VSTS 702327: Launch image sizes for iPhone XS Max and iPhone XR (dotnet#35)
* dotnet/macios-devtools@95599c5 Added new Xcode10 Watch Complication values (dotnet#34)
* dotnet/macios-devtools@59b15be Use Version.TryParse
* dotnet/macios-devtools@2dd5fa0 Merge pull request dotnet#32 from xamarin/vsts-692176
* dotnet/macios-devtools@a97390f VSTS-692176: Add missing AutoFill Credential Provider entitlement
* dotnet/macios-devtools@19b14f6 Added API to get the recommended Xcode version value

Diff: dotnet/macios-devtools@39ea45b...49a17b1

Commit list for mono/mono:

* mono/mono@4d7b7ab3751 [ci] Fix Windows .msi build
* mono/mono@21dc7470bc7 [bcl] avoid false pinning in GCTest (dotnet#11534)
* mono/mono@d9779c1df6d [interp] accept typed-by-ref as return type from a JIT call (dotnet#11538)
* mono/mono@e7e14a79297 [interp] transform delegate invoke in method body too (dotnet#11549)
* mono/mono@cadeaf43dad [ci] Switch to new syntax of Azure Storage plugin

Diff: mono/mono@709b46e...4d7b7ab

Commit list for xamarin/maccore:

* xamarin/maccore@e73094e632 Update maciostools to head (dotnet#1117)
* xamarin/maccore@4902ebbdbd Merge pull request dotnet#1105 from xamarin/swift-o-matic-optional-virtual-constructor
* xamarin/maccore@76ecea4760 Added IsOptional property.
* xamarin/maccore@77d93295bd Added a test where the init fails to ensure both paths work.
* xamarin/maccore@3d989b1ca4 Support for optional constructors in virtual classes.
* xamarin/maccore@bfdc782d0e Merge pull request dotnet#1100 from xamarin/swift-o-matic-constructor-mulligan
* xamarin/maccore@cf8025724d Added field and prop for ClassHandle
* xamarin/maccore@dc2e3f32fe Trimmed down ObjC constructors.
* xamarin/maccore@b53827c151 [SoM] Document CI a bit. (dotnet#1101)
* xamarin/maccore@46d01c8c10 [SoM] Provision XI and Mono as well. (dotnet#1099)
* xamarin/maccore@b4455eafcb bye bye old code.
* xamarin/maccore@34730dfeac Lots of changes for constructor refactoring.
* xamarin/maccore@bd09006725 Merge pull request dotnet#1096 from xamarin/swift-o-matic-required-init
* xamarin/maccore@2af91dc79a Label those asserts!
* xamarin/maccore@ea5b501a47 It looks like cmake isn't there?
* xamarin/maccore@b50285719f Support for required init methods
* xamarin/maccore@6e7187da41 [install-qa-provisioning-profiles] Create directory before trying to create files in it. (dotnet#1095)
* xamarin/maccore@8addb4a338 Merge pull request dotnet#1092 from xamarin/swift-o-matic-objc-methods
* xamarin/maccore@9dc7111497 Removed dead code, added nfloat.
* xamarin/maccore@663279065d Removed dead code.
* xamarin/maccore@3852918abc Added code to import C# methods defined in ObjC bindings.

Diff: https://github.com/xamarin/maccore/compare/b35c3a8d7682c8482c7c749d7c1670b3d4bbed5c...e73094e6322531bcefdef95b4ec8654f596c4ae9
spouliot added a commit that referenced this pull request Nov 6, 2018
Commit list for xamarin/Xamarin.MacDev:

* dotnet/macios-devtools@49a17b1 VSTS 702327: Launch image sizes for iPhone XS Max and iPhone XR (#35)
* dotnet/macios-devtools@95599c5 Added new Xcode10 Watch Complication values (#34)
* dotnet/macios-devtools@59b15be Use Version.TryParse
* dotnet/macios-devtools@2dd5fa0 Merge pull request #32 from xamarin/vsts-692176
* dotnet/macios-devtools@a97390f VSTS-692176: Add missing AutoFill Credential Provider entitlement
* dotnet/macios-devtools@19b14f6 Added API to get the recommended Xcode version value

Diff: dotnet/macios-devtools@39ea45b...49a17b1

Commit list for mono/mono:

* mono/mono@4d7b7ab3751 [ci] Fix Windows .msi build
* mono/mono@21dc7470bc7 [bcl] avoid false pinning in GCTest (#11534)
* mono/mono@d9779c1df6d [interp] accept typed-by-ref as return type from a JIT call (#11538)
* mono/mono@e7e14a79297 [interp] transform delegate invoke in method body too (#11549)
* mono/mono@cadeaf43dad [ci] Switch to new syntax of Azure Storage plugin

Diff: mono/mono@709b46e...4d7b7ab

Commit list for xamarin/maccore:

* xamarin/maccore@e73094e632 Update maciostools to head (#1117)
* xamarin/maccore@4902ebbdbd Merge pull request #1105 from xamarin/swift-o-matic-optional-virtual-constructor
* xamarin/maccore@76ecea4760 Added IsOptional property.
* xamarin/maccore@77d93295bd Added a test where the init fails to ensure both paths work.
* xamarin/maccore@3d989b1ca4 Support for optional constructors in virtual classes.
* xamarin/maccore@bfdc782d0e Merge pull request #1100 from xamarin/swift-o-matic-constructor-mulligan
* xamarin/maccore@cf8025724d Added field and prop for ClassHandle
* xamarin/maccore@dc2e3f32fe Trimmed down ObjC constructors.
* xamarin/maccore@b53827c151 [SoM] Document CI a bit. (#1101)
* xamarin/maccore@46d01c8c10 [SoM] Provision XI and Mono as well. (#1099)
* xamarin/maccore@b4455eafcb bye bye old code.
* xamarin/maccore@34730dfeac Lots of changes for constructor refactoring.
* xamarin/maccore@bd09006725 Merge pull request #1096 from xamarin/swift-o-matic-required-init
* xamarin/maccore@2af91dc79a Label those asserts!
* xamarin/maccore@ea5b501a47 It looks like cmake isn't there?
* xamarin/maccore@b50285719f Support for required init methods
* xamarin/maccore@6e7187da41 [install-qa-provisioning-profiles] Create directory before trying to create files in it. (#1095)
* xamarin/maccore@8addb4a338 Merge pull request #1092 from xamarin/swift-o-matic-objc-methods
* xamarin/maccore@9dc7111497 Removed dead code, added nfloat.
* xamarin/maccore@663279065d Removed dead code.
* xamarin/maccore@3852918abc Added code to import C# methods defined in ObjC bindings.

Diff: https://github.com/xamarin/maccore/compare/b35c3a8d7682c8482c7c749d7c1670b3d4bbed5c...e73094e6322531bcefdef95b4ec8654f596c4ae9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants