* [generator] Properly set the IsDirectBinding value.
Properly set the IsDirectBinding value to false for models and synthetic types.
This also means we can now stop excluding models when testing if the
IsDirectBinding value is correct.
Also set IsDirectBinding value to true for sealed wrapper types, since those
will always be direct bindings since they can't be subclassed.
https://gist.github.com/rolfbjarne/24028bf944db848fed4083c460d0ec71
* [tests] Add introspection exclusion for XM.
* [introspection] Add back exclusions for Classic, since we can't modify/fix Classic assemblies anymore.
* [generator] Print the correct protocol name with the protocol attribute.
Fixes this test failure:
[FAIL] Foundation.NSUrlDownloadDelegate : ConformsToProtocol(null) failed
because our binding code claimed that our `NSUrlDownloadDelegate` class
implemented the `NSUrlDownloadDelegate` protocol, but since the
`NSUrlDownloadDelegate` protocol doesn't exist (it's `NSURLDownloadDelegate` -
different case), we'd verify against a null protocol (and return true from
`ConformsToProtocol(null)`, which would fail the test).
* [xtro] Only treat interfaces as protocols.
Unfortunately we add [Protocol] to [Model]s as well as on interfaces, but we
must not process those in xtro, since they don't correspond with the actual protocol.
* [tests][generator] Port bindas1048error to NUnit.
* [tests][generator] Port bindas1049error to NUnit.
* [tests][generator] Port bindas1050modelerror to NUnit.
* [tests][generator] Port bindas1050protocolerror to NUnit.
* [tests][generator] Port bug42855 to NUnit.
* [tests][generator] Port bug57070 to NUnit.
* [tests][generator] Port bug52570classinternal to NUnit.
* [tests][generator] Port bug52570methodinternal to NUnit.
* [tests][generator] Port bug52570allowstaticmembers to NUnit.
* [tests][generator] Port protocol-duplicate-abstract-error to NUnit.
* [tests][generator] Port protocol-duplicate-method-diff-length to NUnit.
* [tests][generator] Port protocol-duplicate-method-diff-out to NUnit.
* [tests][generator] Port protocol-duplicate-method-diff-type to NUnit.
* [tests][generator] Port protocol-duplicate-method-diff-return to NUnit.
* [tests][generator] Port warnaserror to NUnit.
* [tests][generator] Port nowarn to NUnit.
* [tests][generator] Add support for inspecting/asserting the generated content.
* [tests][generator] Port some Xamarin.Mac tests to NUnit.
Ported:
* bmac_smoke
* bmac-with-hyphen-in-name
* property-redefination-mac
* NSApplicationPublicEnsureMethods
* protocol-duplicate-abstract
* [tests][generator] Point bgen to our local installation.
* [tests][generator] Port the bug31788 test to a unit test.
* [generator] Make the 'bgen' helper target more complete.
* [tests][generator] Port non-custom iOS tests to unit tests.
* [tests][generator] Add new test.
* [tests][generator] Port the forum54078 test to a unit test.
* [tests][generator] Port the desk63279 test to a unit test.
* [tests][generator] Port the desk79124 test to a unit test.
* [tests][generator] Port the multiple-api-definitions tests to unit tests.
* [generator] Use mono code style.
* [tests][generator] Port the bug29493 test to a unit test.
* [tests][generator] Port the classNameCollision test to a unit test.
* [tests][generator] Port the bi1036 test to a unit test.
* [tests][generator] Port the bug37527 test to a unit test.
Also fix BI1112 and BI1113 to show up as errors in the console output (since
they're exceptions they're already treated as errors and would cause bgen to
fail).
* [tests][generator] Port the bug27986 test to a unit test.
* [tests][generator] Port the bug35176 test to a unit test.
* [tests][generator] Port the bi1046 test to a unit test.
* [tests][generator] Port the virtualwrap test to a unit test.
* [tests][generator] Port the bug42742 test to a unit test.
* [tests][generator] Port the noasyncinternalwrapper test to a unit test.
* [tests][generator] Port the noasyncwarningcs0219 test to a unit test.
* [tests][generator] Port the bug53076 test to a unit test.
* [tests][generator] Port the bug53076withmodel test to a unit test.
* [tests][generator] Port the fieldenumtests test to a unit test.
* [tests][generator] Port the smartenumwithframework test to a unit test.
* [tests][generator] Port the forcedtype test to a unit test.
* [tests][generator] Port the bug46292 test to a unit test.
* [tests][generator] Build tests with MSBuild.
There's no need to use xbuild for these tests.
* [tests][generator] Remove dead code.
* [xharness] Don't run the makefile-based generator tests anymore.
Since there aren't any makefile-based generator tests anymore, they've all
been ported to NUnit tests.
* [tests][generator] Make the bug39614 test do what it was supposed to do: make sure a namespace isn't required (but recommended).
* [mtouch/mmp/bgen] Add support for response files.
This is the first part of the fix for #56501.
https://bugzilla.xamarin.com/show_bug.cgi?id=56501
* [tests] Make sure no single argument starting with a '@' is passed to mtouch unless it's a response file.
--assembly-build-target takes arguments starting with '@', for instance:
--assembly-build-target @all=framework
which does not work anymore, because that's interpreted as a response file
(mtouch tries to read the file '@all=framework', which obviously doesn't
exist).
The fix is simple, don't put a space between the two arguments:
--assembly-build-target=@all=framework
* Add --root-assembly to mtouch/mmp and make the MSBuild tasks use this new option.
This makes it possible to pass root assemblies starting with `@` to mtouch/mmp
without getting mistaken for response files.
* [msbuild] Always use the command-line option that takes an equals or colon.
Always use the command-line option that takes an equals or colon instead of a
space.
Do either of these:
--foo=something
--foo:something
instead of this:
--foo something
so that `something` can start with an at (`@`) sign without being mistaken for
a response file.
* [msbuild] Fix tests according to recent task changes.
* Update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now.
* [builds] Pass --with-cross-offsets= to crosstv's configure.
* Bump mono to 2017-08.
* Bump mono to 2017-08.
* Force disable 'futimens' and 'utimensat' so that we build with Xcode 9.
This is also needed to build with Xcode 8.3 on High Sierra.
* Remove old AppleTls implementation.
* Bump mono.
* Bump mono to 2017-08.
* Bump mono to 2017-08
* Reenable link-keep-resources-2 test
- This reverts commit 76b759ef22.
- 2017-08 has linker fix
* Bump mono to 2017-10
* Revert "Bump mono to 2017-10"
This reverts commit bb7832724e.
* Bump system mono to 2017-10
* Bump embedded mono to 2017-10
* [runtime] reflect eglib move
9be68f8952
* bump mono
* [btouch] remove Security.Tls usage from test
* [mtouch tests] update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now.
see
ea4e4a9ef6
fixes:
```
1) Failed : Xamarin.MTouch.Profiling(tvOS)
_mono_profiler_startup_log
Expected: collection containing "_mono_profiler_startup_log"
But was: < "_mono_profiler_init_log" >
at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0
2) Failed : Xamarin.MTouch.Profiling(watchOS)
_mono_profiler_startup_log
Expected: collection containing "_mono_profiler_startup_log"
But was: < "_xamarin_get_block_descriptor", "_mono_profiler_init_log" >
at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0
```
* [mmptest] update log profiler options.
826558a4af
deprecated the dash prefix for the mlpd path.
`noallocs` or `nocalls` are not needed, neither of them are default anymore.
* [mmptest] fix link-keep-resources-2 test to cope with more corlib resources.
another corlib resource (mscorlib.xml) was added:
https://github.com/mono/mono/commit/11e95169e787#diff-2d1c64decd91d9a6e8842ab0f0e9438d
* Revert "[mmptest] fix link-keep-resources-2 test to cope with more corlib resources."
This reverts commit 350eb3c174.
* [XHarness] Add the Mono.Data.Tds tests.
* Address comments from rolf in the review.
* [mmp regresssion tests] bump mono linker, so mscorlib.xml gets stripped
the test was failing in that way:
> Executing link-keep-resources-2...
> [FAIL] i18n 4/2 data files present: charinfo.nlp, collation.core.bin, collation.tailoring.bin, mscorlib.xml
also update the output, because it's actually expected at least three
elements.
fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59277
* bump mono
fixes crash in tvOS: https://github.com/mono/mono/pull/5812
* bump mono for updated BCL tests
see https://github.com/mono/mono/pull/5820
* [mono] set 2017-10 branch in .gitmodules
* [macos] Fix guiunit error on clean builds by depending on correct copy (#2912)
* [macos] Fix guiunit error on clean builds by depending on correct copy
- From a clean build making a BCL test would error due to the non-mobile guiunit not being built
- This was because the Makefile-mac.inc target was incorrect
- This was because xharness assumed that non variation based targets were always Modern
- However, BCL tests are Full, not Modern
* Code review change
* Swap to var to reduce diff
* Revert changes in the paths for GuiUnit.
* [XHarness] Add the System.IO.Compression bcl tests. (#2918)
* [XHarness] Add the System.IO.Compression bcl tests.
* [XHarness] Add bcl tests for System.IO.Compression.FileSystem. (#2924)
* [XHarness] Add the System.IO.Compression bcl tests.
* Ensure that resources are correctly copied in the bundles.
* [XHarness] Add bcl tests for System.IO.Compression.FileSystem.
* As per review, make the Mac test app name match the tests that are ran.
* [XHarness] Add Mono.CSharp tests on ios. (#2927)
* [XHarness] Add Mono.CSharp tests on ios.
* Bump mono to bring changes in the mono.csharp tests.
* [xtro-sharpie] fix TypeDefinition access due to Cecil change
* Bump mono
* bump mono
fixes
- https://bugzilla.xamarin.com/show_bug.cgi?id=60480
- https://bugzilla.xamarin.com/show_bug.cgi?id=60482
* bump mono
more fixes around conflicting paths when tests are run in parallel.
* Bump for mono/mono@2017-10
* [generator] Improve BI1014 - include name of unsupported field and update valid types on docs, fixes bug 57094.
https://bugzilla.xamarin.com/show_bug.cgi?id=57094
* Implement feedback
* fix error message
* More feedback
* [Generator] BindAs attribute for smart enums of an array of nullable values generates code that doesn't compile, Fixes bug 57797
https://bugzilla.xamarin.com/show_bug.cgi?id=57797
We now correctly compiles the array nullabe types
* Disable Nullable array types in BindAs until we add registrar support
This fix is needed by PDFKit because it is a remapped framework[0],
the current code generates incorrect FieldAttribute on smart enums
because it uses `fa.LibraryName` as first option and this causes
remmaped frameworks have incorrect LibraryName generated for example
if a Field uses `+CoreImage` as `LibraryName` the following incorrect
code is generated:
```
[Field ("First", "+CoreImage")]
internal unsafe static IntPtr First {
get {
fixed (IntPtr *storage = &values [0])
return Dlfcn.CachePointer (Libraries.+CoreImage.Handle, "First", storage);
}
}
```
[0]: f5956d6cc1/src/generator.cs (L5985)
* [ObjCRuntime] Add GetUInt32/SetUInt32/SetNInt/SetNUInt/SetNFloat to Dlfcn
https://bugzilla.xamarin.com/show_bug.cgi?id=57535https://bugzilla.xamarin.com/show_bug.cgi?id=57537
This commit is part of the fix for the above bugs, we lacked
GetUInt32/SetUInt32/SetNInt/SetNUInt/SetNFloat in Dlfcn and we
have code inside generator that relies on the methods to be
available 0a316951a3/src/generator.cs (L6090-L6095)
* [generator] Add enum and uint support to FieldAttribute
Fixes:
* https://bugzilla.xamarin.com/show_bug.cgi?id=57535
* https://bugzilla.xamarin.com/show_bug.cgi?id=57537
New Features:
* Added Smart Enum support to [Field]
* Added [Native] enum support to [Field]
* Added enum support to [Field]
* Added uint support to [Field]
Also fixed a bug in Smart Enums support when computing the library name
taking into account third party bindings and some special cases, this is
needed because we ended up generating invalid code when Smart Enum support
was used in third party bindings.
Also added Field Enum generation test.
* Implement PR feedback and added [Get/Set]UInt64 to Dlfcn and [Field] support for it too.
* [generator] Keep [NotImplemented] info so it is usable in 3rd party bindings. Fixes bug 52664
https://bugzilla.xamarin.com/show_bug.cgi?id=52664
Currently we do not keep the [NotImplemented](0) information and the
generator gets a little confused because it will not find an Export
inside the getters/setters of properties and there is no way to tell
if this was intentional or not. We now keep the [NotImplemented]
and also add some null checks in the generator where needed.
Reenabled tests disabled in 9f036b218a
[0]: https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-c-libraries/#Objective-C_Mutable_Pattern_and_Properties
* [generator] Implement feedback
* Added quote method
* Teach linker about NotImplementedAttribute
* [generator] Improve Quote method
* [generator] Fix quote now for realsssss
* [generator] Create CVPixelBuffer using GetINativeObject so its usable from 3rd party bindings
Complements https://bugzilla.xamarin.com/show_bug.cgi?id=52665
and PR #2102
CVPixelBuffer was created using the internal handle ctor, this
did not allow 3rd party bindings to bind it correctly since it
generated not compilable code.
We now use Runtime.GetINativeObject<CVPixelBuffer> (ptr, false); just
like the base ctor https://git.io/vHvLj.
* [tests] Add IntPtr.Zero check and fix link in code
* [generator] Make comment easier to find
Some namespaces are missing on generated files, causing error CS0246
The type or namespace name `Foo` could not be found.
While fixing this another error arose, by enabling the following test
[Protocol] interface C140 : ICIImageProcessorInput {}
some codepaths leads to CVPixelBuffer creation which our code
tries to invoke the handle ctor and fails to find it because it
is internal. This will be fixed in a different commit.
https://bugzilla.xamarin.com/show_bug.cgi?id=53076
When [Async] was used on a member of a [Model][Protocol][Basetype]
interface the ModelClass ended up with additional FooAsync methods that
are not really part of the Model.
This commit removed any instances of FooAsync members from model classes
and also fixes any breaking changes in the currently bound classes.
Added test case using Model.
build diff:
https://gist.github.com/dalexsoto/75cb8424f2462bd6b513049f00bba6a8
Currently we get a CS2019 warning whenever we use AsyncAttribute
because we ignore the `result` variable on methods whose return
type is != `void` which is the expected behaviour.
This is specially more annoying on third party bindings,
the generated code did not disable this warning so you get
an "unfixable" warning on the generated code and the user
has no way to fix this on their own.
We now disable and restore CS2019 in the generated code as needed.
Nobody likes warnings that are not their fault.
Added unit test.
Build diff:
https://gist.github.com/dalexsoto/6f57d3f84b039b9fda863e2f8cfcf365
Simplify mac tests by using different variables for the various flavors of mac
generators, and use these new flavors so that all tests pass when using the
IKVM-based bgen.
* [generator] Fix bug 42742 The advice attribute doesn't make it to the generated code
https://bugzilla.xamarin.com/show_bug.cgi?id=42742
The Advice attribute used in our bindings was not making
into the generated code. This fixes it.
Also added unit test for it
* [generator] Merged PrintFooAttributes into one
Merged PrintPlatformAttributes, PrintPreserveAttribute and
PrintAdviceAttribute into a single method PrintAttributes.
This is due to sometimes we call three times in a row the same method:
```csharp
PrintPlatformAttributes (pi.GetGetMethod ());
PrintPreserveAttribute (pi.GetGetMethod ());
PrintAdviceAttribute (pi.GetGetMethod ());
```
We now do
```csharp
PrintAttributes (pi, platform:true, preserve:true, advice:true);
```
Also removed a not used instance (internal field) of AdviceAttribute
https://bugzilla.xamarin.com/show_bug.cgi?id=52570
In some cases you will find **static** members inside categories like in the following example:
```objc
@interface FooObject (MyFooObjectExtension)
+ (BOOL)boolMethod:(NSRange *)range;
@end
```
This will lead to an **incorrect** Category C# interface definition:
```csharp
[Category]
[BaseType (typeof (FooObject))]
interface FooObject_Extensions {
// Incorrect Interface definition
[Static]
[Export ("boolMethod:")]
bool BoolMethod (NSRange range);
}
```
This is incorrect because in order to use the `BoolMethod` extension you need an instance of `FooObject` but you are binding an ObjC **static** extension, this is a side effect due to the fact of how C# extension methods are implemented.
The only way to use the above definitions is by the following ugly code:
```csharp
(null as FooObject).BoolMethod (range);
```
The recommendation to avoid this is to inline the `BoolMethod` definition inside the `FooObject` interface definition itself, this will allow you to call this extension like it is intended `FooObject.BoolMethod (range)`.
```csharp
[BaseType (typeof (NSObject))]
interface FooObject {
[Static]
[Export ("boolMethod:")]
bool BoolMethod (NSRange range);
}
```
We will issue a warning (BI1117) whenever we find a `[Static]` member inside a `[Category]` definition. If you really want to have `[Static]` members inside your `[Category]` definitions you can silence the warning by using `[Category (allowStaticMembers: true)]` or by decorating either your member or `[Category]` interface definition with `[Internal]`.
* [tests][generator] Port XI/Classic tests to XI/Unified.
* [tests][generator] Comment out code triggering previously unknown bugs.
These tests makes the generator fail:
error BI0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.NullReferenceException: Object reference not set to an instance of an object
at Generator.GetSetterExportAttribute (System.Reflection.PropertyInfo pinfo) [0x0002e] in /work/maccore/master/xamarin-macios/src/generator.cs:1981
at Generator.Go () [0x007e3] in /work/maccore/master/xamarin-macios/src/generator.cs:2162
at BindingTouch.Main2 (System.String[] args) [0x010b2] in /work/maccore/master/xamarin-macios/src/btouch.cs:435
at BindingTouch.Main (System.String[] args) [0x0001d] in /work/maccore/master/xamarin-macios/src/btouch.cs:77
at System.Environment.get_StackTrace () [0x00000] in /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System/Environment.cs:321
at ErrorHelper.ShowInternal (System.Exception e) [0x000dc] in /work/maccore/master/xamarin-macios/src/error.cs:200
at ErrorHelper.Show (System.Exception e) [0x00027] in /work/maccore/master/xamarin-macios/src/error.cs:151
at BindingTouch.Main (System.String[] args) [0x0002b] in /work/maccore/master/xamarin-macios/src/btouch.cs:79
This has been filed as https://bugzilla.xamarin.com/show_bug.cgi?id=52664.
* [tests][generator] Comment out code triggering previously unknown bugs.
This has been filed as https://bugzilla.xamarin.com/show_bug.cgi?id=52665.
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