Граф коммитов

7 Коммитов

Автор SHA1 Сообщение Дата
Sebastien Pouliot ee046ee034 [generator] Copy [Obsolete] attributes on smart enums. Fixes #46292 (#1104)
Covers attributes on the type itself and on its members.

Reference:
* https://bugzilla.xamarin.com/show_bug.cgi?id=46292
2016-11-02 23:18:59 -04:00
Sebastien Pouliot e55385637f [generator] Allow identical (numeric) values in smart enums. Fixes #46285 (#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
2016-11-02 21:46:04 -04:00
Alex Soto ff326bdfdb [generator] ForcedType is now only valid on parameters, properties and return value
https://bugzilla.xamarin.com/show_bug.cgi?id=37175
https://bugzilla.xamarin.com/show_bug.cgi?id=44322

* ForcedType is now only valid on parameters, properties and return value
* Added generator test
* Fixed bindings accordingly
* Fixed docs
2016-09-26 03:57:57 -05:00
Alex Soto e397849108 [generator] Fix bug 43579 - Generator emits invalid code when using the same method name (overload) in @delegates using events and C# delegates (#817)
* [generator] Fix bug 43579 - Generator emits invalid code when using the same method name (overload) in @delegates using events and C# delegates
https://bugzilla.xamarin.com/show_bug.cgi?id=43579

Bug Description:
Generator will emit invalid code when using the same name (overload)
in a method inside a @delegate (protocol) that is decorated
either with EventArgs or DelegateName

-----------------------------------------------------------------

This commit introduces a new attribute named DelegateApiNameAttribute
which mimics the EventNameAttribute but for delegate properties in
host classes

It is used to specify the delegate property name that will be created when
the generator creates the delegate property on the host
class that holds events and delegates.

This is really useful when you have two overload methods that makes
sense to keep them named as is but you want to expose them in the host class
with a better given name.

example:
 interface SomeDelegate {
     [Export ("foo"), DelegateApiName ("Confirmation"), DelegateName ("Func<bool>"), DefaultValue (false)]
     bool Confirm (Some source);
 }

 Generates propety in the host class:
	Func<bool> Confirmation { get; set; }

This also introduces two new BIXXXX errors:
- BI1043 Repeated overload {mi.Name} and no [DelegateApiNameAttribute]
provided to generate property name on host class.
- BI1044 Repeated name '{apiName.Name}' provided in [DelegateApiNameAttribute].

Which provides an error instead of generating invalid C# code.

Generator test included :D

* [docs] Added DelegateApiNameAttribute and IgnoredInDelegateAttribute docs

Also added Protocol where Model was used in our docs so we do not
misslead customers about it
2016-09-14 08:20:08 -04:00
Manuel de la Pena 90c7eab95e [Fix] Ensure that strong dictionaries can work with templated dictionaries as property types. 2016-06-13 12:13:48 +02:00
Rolf Bjarne Kvinge 4a714f3c43 Make logic not depend on the checkout directory being named 'xamarin-macios'. (#129) 2016-06-06 12:18:52 +02:00
Rolf Bjarne Kvinge ecfdea9508 [tests] Import 2016-05-26 15:06:52 +02:00