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

10 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 00874dc1e7 [tests][generator] 'virtualwrap' is a custom test, so put it in the corresponding variable. (#1743)
Fixes this warning:

    Makefile:163: warning: overriding commands for target `virtualwrap'
    Makefile:40: warning: ignoring old commands for target `virtualwrap'
2017-02-22 14:23:45 +01:00
Alex Soto a021c0cd3c [generator] Have WrapAttribute generate virtual members (#1707)
* [generator] Have WrapAttribute generate virtual members

WrapAttribute now has a boolean optional parameter named isVirtual,
this instructs the generator to add the virtual keyword to generated
members.

This is useful when fixing breaking changes so we can keep the wrong
signature generated instead of having manual code files.

* [docs] Add docs about virtual to WrapAttribute
2017-02-16 17:24:40 -06:00
Alex Soto 1799c2f489 [generator] Add BindAs support (#1476)
* [generator] Add BindAs support for NSValue and NSNumber
https://trello.com/c/RYCPEnkh

The intent of BindAs attribute is to have a binding definition as

	[return: BindAs (typeof (bool?))]
	[Export ("boolMethod:")]
	NSNumber BoolMethod (int arg1);

and our generator outputs

	[Export ("boolMethod:")]
	public virtual global::System.Nullable<bool> BoolMethod (int arg1) { ...  }

So we internally do the NSNumber <-> bool conversion, this also
applies to properties, parameters and methods.

* [generator] Fix a small formating issue

* [tests] Add BindAsAttribute generator tests

* [generator] Implement @spouliot's feedback

* [tests] Add BI1048 and BI1049 error tests for [BindAs]

* [generator] Implement Rolf's suggestion to avoid almost all string comparisons in [BindAs] for types

* [generator] Add BindAs support for smart enums and arrays with tests

* [generator] Some code clean up and implementation of PR feedback

* [generator] Add Protocol|Model checks and tests also a NRE check in NSArray creator

BindAs attribute cannot be used in Protocol|Model interfaces

* [generator] Add NSNumber <-> Enum support

* [docs] add BindAs documentation

* [docs] Implement documentation feedback for BindAs
2017-01-25 07:14:55 +01:00
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