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

37 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 430a5e7ebe
[registrar] Don't throw NRE when finding methods that almost implement optional protocol members. (#3658) (#3659)
If a class implements a protocol with optional members, and that class also exports methods whose selectors match an optional member, but the signature doesn't match, we must show a useful warning instead of erroring out due to a NullReferenceException.

Fixes this:

    System.NullReferenceException: Object reference not set to an instance of an object
      at Registrar.StaticRegistrar.GetBlockProxyAttributeMethod (Mono.Cecil.MethodDefinition method, System.Int32 parameter) [0x00001] in /Users/builder/data/lanes/1381/9de35b83/source/xamarin-macios/tools/common/StaticRegistrar.cs:4113
      at Registrar.StaticRegistrar.GetBlockWrapperCreator (Registrar.Registrar+ObjCMethod obj_method, System.Int32 parameter) [0x001e1] in /Users/builder/data/lanes/1381/9de35b83/source/xamarin-macios/tools/common/StaticRegistrar.cs:4101
      at Registrar.StaticRegistrar.Specialize (Registrar.AutoIndentStringBuilder sb, Registrar.Registrar+ObjCMethod method, System.Collections.Generic.List`1[T] exceptions) [0x0216b] in /Users/builder/data/lanes/1381/9de35b83/source/xamarin-macios/tools/common/StaticRegistrar.cs:3683

when building the msbuild/tests/MyWatchKit2IntentsExtension project.
2018-03-06 14:40:45 +01:00
Rolf Bjarne Kvinge 835f65897f
[static registrar] Optimize creation of delegates for blocks. (#3623) (#3644)
* [static registrar] Optimize creation of delegates for blocks.

Optimize creation of delegates for blocks so that it doesn't require the
dynamic registrar.

This is done by getting the metadata token for the Create method that creates
the delegate, and embed that metadata token in the generated code from the
static registrar.

Also add tests, since this scenario was not covered by tests already.

* [mmptest] Fix test after recent changes.

* [test-libraries] Avoid duplicate symbols.

* [tests] Update according to changes.
2018-03-05 07:41:28 +01:00
Rolf Bjarne Kvinge ed886f6181 [tests] Refactor several tests to use new-style syntax.
Failure are reported much better, and the testing is more accurate and extensive.
2018-02-14 01:13:17 +01:00
Rolf Bjarne Kvinge f905427739
[tests] Share supporting code between the mtouch and mmp tests. (#3374)
* [tests] Share supporting code between the mtouch and mmp tests.

Create a new class 'BundlerTool', which now contains most of the code in
MTouchTool that's also applicable to mmp (and the new MmpTool class).

This will make it easier to share tests between the mtouch and mmp tests.

Some tweaks are still probably required, but this should get us most of the
way.

* [tests] Fix generator tests after changes in shared test code.

* [tests] Add new file to the MSBuild/XM tests.
2018-02-02 07:09:04 +01:00
Rolf Bjarne Kvinge 407a19b59b
[tests][mtouch] Add test case for bug #59617. (#2926)
* [tests][mtouch] Convert MT4162 to new syntax.

This also means adding support for custom usings in test code, and adding
support for asserting filename/linenumber with error patterns, and custom
pattern syntax.

* [tests][mtouch] Add test case for bug #59617.

This amounts to running the MT4162 test with the linker enabled.

https://bugzilla.xamarin.com/show_bug.cgi?id=59617
2017-10-27 19:14:58 +02:00
Rolf Bjarne Kvinge 05484c915f [registrar] Don't verify the SDK for protocol members, and fix the SDK check for other cases. Fixes #59617. (#2790)
* [registrar] Remove useless interface.

* [registrar] Don't store LinkContext in the static registrar when in can be fetched from the Target. Partially fixes #59617.

This avoids a problem where our code would store null because LinkContext
wasn't created yet when the static registrar instance was created.

This fixes the missing error from bug #59617.

https://bugzilla.xamarin.com/show_bug.cgi?id=59617

* [registrar] Don't verify the SDK for protocol members. Partially fixes #59617.

It's not needed, because protocol members don't end up in the registrar output
anyway (and would thus not prevent the registrar code from compiling).

Classes that implement any protocol members would still run into the SDK
check, so this should not prevent real problematic code from being reported
either.

https://bugzilla.xamarin.com/show_bug.cgi?id=59617

* [tests][mtouch] Fix tests after registrar changes.
2017-09-28 17:35:21 +02:00
Rolf Bjarne Kvinge d0bb1c5d0c [tests] Recover BindAs test that got lost in merges. (#2786) 2017-09-27 14:05:54 +02:00
Rolf Bjarne Kvinge a979a10412 Merge remote-tracking branch 'origin/master' into bindas-registrar-support 2017-09-22 10:50:07 +02:00
Sebastien Pouliot 05eb96d0a7 Merge branch 'xcode9' into xcode9-master-merge 2017-09-15 11:05:30 -04:00
Rolf Bjarne Kvinge d34918dda2 [mtouch] Report better error (MT4169) when we can't generate a P/Invoke wrapper for a P/Invoke. (#2349) 2017-07-20 15:34:42 +02:00
Rolf Bjarne Kvinge 88a377e5f3 [tests] Update tests since BindAs supports conversions between enums and NSNumber. 2017-07-07 12:28:53 +02:00
Rolf Bjarne Kvinge a41c6ebc3f [registrar] Verify if the BindAs type matches the type in the method signature. 2017-07-07 12:28:10 +02:00
Rolf Bjarne Kvinge 098c6876fa [mtouch] Minor adjustments to get error messages right. 2017-07-05 08:54:42 +02:00
Rolf Bjarne Kvinge f53e9da0d7 [mtouch] Minor adjustments to get error messages right. 2017-07-04 20:07:20 +02:00
Rolf Bjarne Kvinge d3a505fa24 [tests] Add mtouch tests for the BindAs attribute. 2017-07-04 07:35:29 +02:00
Rolf Bjarne Kvinge c1348da5f6 [tests][mtouch] Adjust tests to cope with Xcode 9. Fixes #57601. (#2231)
Fixes:

1. Failed : Xamarin.MTouch.MT0091(tvOS,"tvOS")
    The error 'MT0091: This version of Xamarin.iOS requires the tvOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).' was not found in the output:
    Message #1 did not match:
        actual:   'This version of Xamarin.iOS requires the tvOS 11.0 SDK (shipped with Xcode 9). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'
        expected: 'This version of Xamarin.iOS requires the tvOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'

2. Failed : Xamarin.MTouch.MT0091(iOS,"iOS")
    The error 'MT0091: This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).' was not found in the output:
    Message #1 did not match:
        actual:   'This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'
        expected: 'This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'

3. Failed : Xamarin.Registrar.NoWarnings
    no warnings
    Expected: not String matching "warning:"
    But was:  "/Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.MTouchTool.CreateTemporaryDirectory298/mtouch-test-cache/registrar.m:32468:17: warning: method 'paymentAuthorizationViewController:didAuthorizePayment:handler:' in protocol 'PKPaymentAuthorizationViewControllerDelegate' not implemented [-Wprotocol]"

https://bugzilla.xamarin.com/show_bug.cgi?id=57601
2017-06-21 12:07:13 +02:00
Timothy Risi 25468bf617 Merge Quote methods into a single class instead of multiple versions (#2153) 2017-06-06 12:32:25 -08:00
Rolf Bjarne Kvinge 1fb67779f8 [registrar] Detect more invalid characters in selectors so that we can report better errors. Fixes #55568. (#2154)
* [registrar] Detect more invalid characters in selectors so that we can report better errors. Fixes #55568.

https://bugzilla.xamarin.com/show_bug.cgi?id=55568

* [mtouch] Add a few comments about duplicated data between mtouch and tests.
2017-06-02 16:37:26 +02:00
Rolf Bjarne Kvinge 25e6a93976 [tests] Simplify the MT4164 test a bit. (#2151)
* [tests] Add support to mtouch tests for comparing file name & line number of error/warning messages.

* [tests] Simplify the MT4164 test a bit.
2017-06-01 01:10:36 +02:00
Rolf Bjarne Kvinge c199c9f2c2 [mtouch] Show a nice error (MT4168) if the user registers a managed class with an Objective-C keyword. Fixes #51776. (#2150)
Previously:

    obj/iPhone/Ad-Hoc/mtouch-cache/64/registrar.m:4402:12: error: expected identifier
    @interface register : UITableViewController {
    ^
    obj/iPhone/Ad-Hoc/mtouch-cache/64/registrar.m:4402:21: error: expected unqualified-id
    @interface register : UITableViewController {

    error : Failed to compile the generated registrar code. Please file a bug report at http://bugzilla.xamarin.com

Now:

    error MT4168: Cannot register the type 'register' because its Objective-C name 'register' is an Objective-C keyword. Please use a different name.

https://bugzilla.xamarin.com/show_bug.cgi?id=51776
2017-05-31 19:07:02 +02:00
Rolf Bjarne Kvinge 05895c41f5 [registrar] Add support for specifying that a protocol changed informal status in a certain SDK. Fixes #43780 and #48311. (#2130)
* [registrar] Add support for specifying that a protocol changed informal status in a certain SDK. Fixes #43780

Add support for specifying that an informal protocol became a formal protocol
(or the reverse) in a certain SDK version, so that the static registrar can
generate the correct code based on the SDK being built with.

This also fixes a series of compiler warnings when using the static registrar:

    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:374:11: warning: duplicate protocol definition of 'CALayerDelegate' is ignored
    @protocol CALayerDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h:798:11: note: previous definition is here
    @protocol CALayerDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:824:11: warning: duplicate protocol definition of 'WebDownloadDelegate' is ignored
    @protocol WebDownloadDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebDownload.h:60:11: note: previous definition is here
    @protocol WebDownloadDelegate <NSURLDownloadDelegate>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:851:11: warning: duplicate protocol definition of 'WebFrameLoadDelegate' is ignored
    @protocol WebFrameLoadDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebFrameLoadDelegate.h:51:11: note: previous definition is here
    @protocol WebFrameLoadDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:866:11: warning: duplicate protocol definition of 'WebPolicyDelegate' is ignored
    @protocol WebPolicyDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebPolicyDelegate.h:138:11: note: previous definition is here
    @protocol WebPolicyDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:869:11: warning: duplicate protocol definition of 'WebResourceLoadDelegate' is ignored
    @protocol WebResourceLoadDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebResourceLoadDelegate.h:46:11: note: previous definition is here
    @protocol WebResourceLoadDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:872:11: warning: duplicate protocol definition of 'WebUIDelegate' is ignored
    @protocol WebUIDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebUIDelegate.h:153:11: note: previous definition is here
    @protocol WebUIDelegate <NSObject>
              ^

https://bugzilla.xamarin.com/show_bug.cgi?id=43780

* [registrar] Use a string to specify when a protocol went from informal to formal.

Use a string to specify when a protocol went from informal to formal, and
don't support the reverse condition (going from formal to informal), since
it's currently not needed and makes the code more complicated and harder to
understand.

Also add an mtouch test, and update an existing mmp test to be more restrictive.

* [registrar] Rename from 'InformalUntil' to 'FormalSince'.

It just sounds better.
2017-05-29 16:15:54 +02:00
Alex Soto 2a85ec1674 [mtouch] Remove workaround for bug 43462, this fixes slow builds (bug 52545) (#1976)
https://bugzilla.xamarin.com/show_bug.cgi?id=52545

Some projects took a lot of time to build with the workaround for
bug 43462 but now that it is fixed we can remove it and stop the slowness
2017-04-10 08:20:13 +02:00
Rolf Bjarne Kvinge d196a78cda [registrar] Fix generic argument check to allow INativeObject. Fixes #52868. (#1788)
https://bugzilla.xamarin.com/show_bug.cgi?id=52868
2017-02-28 20:22:05 +01:00
Rolf Bjarne Kvinge e8fbb7f0a6 [tests][mtouch] There's no need to delete a temporary directory we create ourselves. (#1711)
Deleting the directory when the test completes just makes it harder to copy-
paste the failing command.

Any directories created by Cache.CreateTemporaryDirectory will automatically
be deleted at the next test run, so this won't use up disk space.
2017-02-17 16:01:05 +01:00
Rolf Bjarne Kvinge cf14456cd5 [mtouch] Add docs and improve MT4146 to be an error if we can detect the generated code won't compile. Fixes #52530. (#1712)
https://bugzilla.xamarin.com/show_bug.cgi?id=52530
2017-02-17 16:00:53 +01:00
Rolf Bjarne Kvinge 4a0ffa3110 [mtouch tests] Refactor registrar tests a little bit to not cause trouble in Xamarin Studio. (#1679)
Change how the registrar calls mtouch a bit, so that we don't use API that
throws an exception with the entire output in the exception message.

The problem is that if the process has a lot of output, XS slows down to a
crawl when showing the exception message in the test result pad.

Instead print the output to the terminal.
2017-02-10 18:24:37 +01:00
Rolf Bjarne Kvinge 47a7568f9b [tests] Refactor many of the mtouch tests to use new testing infrastructure. (#1569)
This makes a couple of future optimizations easier:

* Cache the compilation of test assemblies.
* Load mtouch.exe directly in the test process.
2017-01-27 07:35:32 +01:00
Rolf Bjarne Kvinge f24c8f7331 [docs] Update text about MT4134 to not mention the legacy registrar anymore. (#1558)
Since the legacy registrar is not available anymore.
2017-01-26 15:31:26 +01:00
Rolf Bjarne Kvinge 2d3a990acf [mtouch tests] Minor refactoring to make a few nested classes non-nested. (#1433) 2017-01-04 19:33:57 +01:00
Rolf Bjarne Kvinge d3e974e2bc [mtouch tests] Build the registrar tests for the simulator. (#1431)
It's *much* faster.
2017-01-03 19:40:33 +01:00
Rolf Bjarne Kvinge 2e3185d687 [mtouch tests] Rename Profile.Unified to Profile.iOS. (#1281)
Rename Profile.Unified to Profile.iOS to better match the other values in the enum (tvOS/watchOS).
2016-12-01 12:32:48 +01:00
Rolf Bjarne Kvinge 43c06e0cbb [tests] Ignore mtouch tests that require device support if device support was not included in the build. (#1109) 2016-11-03 13:20:31 +01:00
Rolf Bjarne Kvinge bdbbea962a [tests] Unifiy namespaces in mtouch tests. (#1057) 2016-10-28 10:15:00 -04:00
Rolf Bjarne Kvinge 39ec76e28a [tests] Add workaround for file descriptor leak in System.Diagnostics.Process. (#961) 2016-10-07 13:50:08 +02:00
Rolf Bjarne Kvinge 0863e412b4 Remove XI/Classic support (#926)
* [tests] Remove Classic SDK tests.

* Remove XI/Classic support.

This also means we can remove support for the legacy registrars.

* [monotouch-test] Remove legacy registrar tests.

* [tests/mtouch] Remove Classic tests (and legacy registrar logic).

* [tests/scripted] Fix tests to reference Xamarin.iOS.dll.
2016-09-30 15:02:17 -04:00
Rolf Bjarne Kvinge e9983ef148 [mtouch tests] Fix typo in RegistrarTest. (#147) 2016-06-08 16:57:40 +02:00
Rolf Bjarne Kvinge ecfdea9508 [tests] Import 2016-05-26 15:06:52 +02:00