Fixes this warning:
Makefile:163: warning: overriding commands for target `virtualwrap'
Makefile:40: warning: ignoring old commands for target `virtualwrap'
* [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
* [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
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
* [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