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

16 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 19c2765156 [tests][monotouch-test] Adjust code to cope with NativeHandle. 2021-11-26 14:25:21 +01:00
Manuel de la Pena 86ac68fc31
[Tests] Remove not needed usings in the CoreData and CoreFoundation tests. (#13254) 2021-11-03 16:48:48 -04:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
Rolf Bjarne Kvinge 165941ec14
[Runtime] Complete the CoreCLR implementation of setting the pending managed exeption. (#11709)
This made it possible to unignore some tests.

Co-authored-by: Alex Soto <alex@alexsoto.me>
2021-05-28 13:20:49 +02:00
Rolf Bjarne Kvinge ee5e2f0b09
[monotouch-test] Ignore tests that require exception marshalling on CoreCLR for now, they fail. (#11615)
This makes monotouch-test green when using CoreCLR, both when using the
dynamic and the static registrar.

Ref: https://github.com/xamarin/xamarin-macios/issues/10940
2021-05-20 07:34:30 +02:00
Rolf Bjarne Kvinge 7ac3c658e0
[tests] Preserve all test fixtures. (#10870)
* [tests] Preserve all test fixtures.

This fixes the wildly diffetent number of tests when running xammac tests with and without linking.

Without linking:

> Tests run: 2446 Passed: 2321 Inconclusive: 9 Failed: 0 Ignored: 125

vs with linking:

> Tests run: 1885 Passed: 1802 Inconclusive: 4 Failed: 0 Ignored: 83

Now we run the same tests either with or without linking.

One test was updated to not fail when linking is enabled.

Also add a test to ensure all future test fixtures are preserved.

* Remove whitespace noise.
2021-03-16 15:15:30 +01:00
Rolf Bjarne Kvinge f516fcfb07 [tests] Use the Does.[BeginWith|Contain|EndWith] constraints instead of the Is.[StringStarting|StringContaining|StringEnding] constraints.
The latter don't exist in the official NUnitLite anymore.
2020-08-03 11:53:17 +02:00
Rolf Bjarne Kvinge 2b2f1d08dc
[tests] Remove Classic code from all tests. (#8702) 2020-05-28 16:35:09 +02:00
Rolf Bjarne Kvinge c8ed014af7
[runtime] Improve exception creation. (#5944)
* [runtime] Add an inner exception parameter to Runtime.CreateProductException.

This allows us to simplify code by using inner (and outer) exceptions as
a means to provide information instead of passing extra information
around in order to create decent exceptions.

One example is how we pass the selector and method name to the method
that converts from a native id to a managed NSObject instance: passing
this information is not necessary anymore if we can use two exceptions,
one for the failure to convert from an id to a NSObject instance,
wrapped in a second that tells which method/selector call ran into this
conversion problem.

* [runtime] Throw better exceptions when the dynamic registrar can't marshal something.

* [runtime] Throw a better exception when something goes wrong when trying to marshal a return value.

* [runtime] Use inner exceptions to convey failure information instead of trying to create a single exception with all we know.

* Fix merge problem.
2019-04-26 11:16:23 +02:00
Rolf Bjarne Kvinge e110612118
[registrar] Improve error message when failing to create a managed wrapper for a native handle. (#4360)
* Convert it into a MM8027/MT8027 error (with documentation).
* Add information about the selector and managed method that triggered the error.

Now the problem reported in issue #4254 shows up as:

> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x7f8080412810 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).
> Additional information:
> 	Selector: popoverController:willRepositionPopoverToRect:inView:
> 	Method: UIKit.UIPopoverController+_UIPopoverControllerDelegate.WillReposition(UIKit.UIPopoverController, CoreGraphics.CGRect ByRef, UIKit.UIView ByRef)

instead of just:

> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x7f8080412810 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).

which makes it much easier to understand, track down, and fix/work around,
both for customers and ourselves.
2018-06-29 14:38:28 +02:00
Rolf Bjarne Kvinge 1a260e542b
[tests] Build the native test library for macOS and create a binding project for it. (#3373)
* [tests] Build the native test library for macOS and create a binding project for it.

Also add the new binding project to the xammac and link all XM test projects,
which allows us to stop excluding tests that require the native library and
the corresponding bindings.

* [tests] Include more tests in xammac_tests.

* [tests] Correctly ignore the ObjC exception tests in release mode.
2018-02-02 11:14:44 +01:00
Rolf Bjarne Kvinge 7728c4cd19 [registrar] Use metadata tokens instead of strings to find types and methods. (#1085)
Use metadata tokens instead of strings to find types and methods.

This makes the code to find methods more compact (a lot less strings in the
executable, and additionally in most cases a compact representation (32-bit
integer) of the corresponding metadata token and additional information can be
used, which results in less executable code (fewer parameters to methods,
etc)), resulting in smaller executables.

Size savings are around 200kb for dont link apps, and 20-60kb for linked apps
(this obviously varies a lot depending on how much has to registered by the
registrar).

|                |    Before     |     After     |       Diff        |
|----------------|--------------:|--------------:|------------------:|
| dontlink/32bit |  102.810.144  |  102.609.456  | -200.688 = -0,20% |
| dontlink/64bit |  107.420.576  |  107.221.792  | -198.784 = -0,19% |
| linksdk/32bit  |   40.957.296  |   40.936.864  |  -20.432 = -0,05% |
| linksdk/64bit  |   43.113.136  |   43.093.936  |  -19.200 = -0,04% |
| linkall/32bit  |   38.410.032  |   38.348.288  |  -61.744 = -0,16% |
| linkall/64bit  |   40.315.200  |   40.267.344  |  -47.856 = -0,12% |

Additionally I've removed the `lazy_map` dictionary, which we populated at
startup and was used to map between Class instances and the corresponding
managed type's FullName, and instead iterate over a native array of Class ->
metadata token mappings whenever we need to look up the managed type for a
certain Class instance.

This is slightly slower for each type we need to look up (for a non-linked app
there might be a 2000-3000 entries in the native array, which would be
iterated instead of using a hashtable lookup), but it's only done once per
type and there's a significant startup memory improvement.

For a non-linked test app I get the following using the Xamarin profiler:

|                   |  Before |  After  |       Diff      |
|-------------------|--------:|--------:|----------------:|
| Memory allocated  |  2,8 MB |  2,4 MB | -0,4 MB = -14 % |
| Objects allocated |   43678 |   38463 |   -5215 = -12 % |
| Private bytes     | 26,6 MB | 24,4 MB | -2,2 MB = -8,3% |
| Working set       | 26,6 MB | 24,4 MB | -2,2 MB = -8,3% |
2016-11-01 14:34:56 -04: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
Alex Soto 1d828e9e5e [CoreFoundation] Fix bug 44399 - ArgumentNullException in AddObserver (#921)
https://bugzilla.xamarin.com/show_bug.cgi?id=44399

We did not fully support passing null to name and objectToObserve in
CFNotificationCenter::AddObserver an  ArgumentNullException was thrown

The use case of sending null to both name and objectToObserve is to
observe all notifications posted to the notification center, this
won't work using darwing notification center, it is restricted
by apple.
2016-09-29 13:35:29 -04:00
Rolf Bjarne Kvinge ecfdea9508 [tests] Import 2016-05-26 15:06:52 +02:00
Rolf Bjarne Kvinge 73ddab291c [tests] Add bindings-test. 2016-04-26 17:27:37 -04:00