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

1291 Коммитов

Автор SHA1 Сообщение Дата
VS MobileTools Engineering Service 2 3536335c3a
[xcode14.1] [ObjCRuntime] Change Runtime.GetNSObject<T> to create a new instance if the existing one is of the wrong type. Fixes #13704. (#16502)
Objective-C has an optimization where creating an empty dictionary would
return the same instance every time (probably to a constant empty
dictionary).

This causes a problem with how we've bound generic dictionaries, because
all
empty dictionaries would have the same native handle, even if we'd bound
them
with different managed types.

This surfaces in unfortunate ways when we try to look up a managed
instance
given a native handle, we find that we already have a managed instance,
but
the managed instance is of the wrong type.

Example code:

    var a = new NSDictionary ();
    var b = new NSDictionary<NSString, NSString> ();
    var c = new NSDictionary<NSString, NSObject> ();
    Console.WriteLine ($"a: 0x{a.Handle:X}");
    Console.WriteLine ($"b: 0x{b.Handle:X}");
    Console.WriteLine ($"c: 0x{c.Handle:X}");

would produce something like:

    a: 0x0x7fff80821080
    b: 0x0x7fff80821080
    c: 0x0x7fff80821080

now for this code:

    Runtime.GetNSObject<NSDictionary<NSString, NSString>> (b.Handle)

it would throw an exception like this:

Unable to cast object of type
'Foundation.NSDictionary`2[[Foundation.NSString],[Foundation.NSObject]]'
to type
'Foundation.NSDictionary`2[[Foundation.NSString],[Foundation.NSString]]'

because we'll have the 'c' object (with type `NSDictionary<NSString,
Object>`)
in our dictionary of native handles -> managed instances, and that's not
compatible with the desired return type from GetNSObject
(`NSDictionary<NSString, NSString>`)

This likely happens with all the non-mutable collection types we have a
generic version of (NSArray, NSDictionary, NSOrderedSet, NSSet).

Fixes https://github.com/xamarin/xamarin-macios/issues/16378.
Fixes https://github.com/xamarin/xamarin-macios/issues/13704.

This PR is somewhat simpler to review by ignoring whitespace:
https://github.com/xamarin/xamarin-macios/pull/16491/files?w=1


Backport of #16491

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-10-28 16:53:15 -04:00
Rolf Bjarne Kvinge adf3dacabf
[tests] Don't block forever in CoreFoundation.ProxyTest if something goes wrong. (#16495) 2022-10-28 11:07:11 +02:00
Rolf Bjarne Kvinge 543d73be3c
[ObjCRuntime] Change Runtime.GetNSObject<T> to create a new instance if the existing one is of the wrong type. Fixes #13704. (#16491)
Objective-C has an optimization where creating an empty dictionary would
return the same instance every time (probably to a constant empty dictionary).

This causes a problem with how we've bound generic dictionaries, because all
empty dictionaries would have the same native handle, even if we'd bound them
with different managed types.

This surfaces in unfortunate ways when we try to look up a managed instance
given a native handle, we find that we already have a managed instance, but
the managed instance is of the wrong type.

Example code:

    var a = new NSDictionary ();
    var b = new NSDictionary<NSString, NSString> ();
    var c = new NSDictionary<NSString, NSObject> ();
    Console.WriteLine ($"a: 0x{a.Handle:X}");
    Console.WriteLine ($"b: 0x{b.Handle:X}");
    Console.WriteLine ($"c: 0x{c.Handle:X}");

would produce something like:

    a: 0x0x7fff80821080
    b: 0x0x7fff80821080
    c: 0x0x7fff80821080

now for this code:

    Runtime.GetNSObject<NSDictionary<NSString, NSString>> (b.Handle)

it would throw an exception like this:

    Unable to cast object of type 'Foundation.NSDictionary`2[[Foundation.NSString],[Foundation.NSObject]]' to type 'Foundation.NSDictionary`2[[Foundation.NSString],[Foundation.NSString]]'

because we'll have the 'c' object (with type `NSDictionary<NSString, Object>`)
in our dictionary of native handles -> managed instances, and that's not
compatible with the desired return type from GetNSObject
(`NSDictionary<NSString, NSString>`)

This likely happens with all the non-mutable collection types we have a
generic version of (NSArray, NSDictionary, NSOrderedSet, NSSet).

Fixes https://github.com/xamarin/xamarin-macios/issues/16378.
Fixes https://github.com/xamarin/xamarin-macios/issues/13704.
2022-10-28 11:05:52 +02:00
Rolf Bjarne Kvinge f4bfa0d0bb
[monotouch-test] Update QuantityTypeIdentifier.EnumValues_22351 after recent API additions. Fixes #16443. (#16498)
Fixes https://github.com/xamarin/xamarin-macios/issues/16443.

Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-10-28 09:49:34 +02:00
Rolf Bjarne Kvinge a2761a7308
[tests] Handle managed exceptions in a networking callback. (#16414)
Fixes a problem where any exception would crash the process, because the
callback was executed on a background thread, and there was no other managed
frame catching the managed exception:

    MonoTests.System.Net.Http.MessageHandlerTest.RejectSslCertificatesWithCustomValidationCallbackNSUrlSessionHandler
    2022-10-21 07:02:23.557 monotouchtest[91107:28076542] *** Terminating app due to uncaught exception 'NUnit.Framework.AssertionException', reason: '  Expected: None
      But was:  RemoteCertificateChainErrors
     (NUnit.Framework.AssertionException)
       at NUnit.Framework.Assert.ReportFailure(String message)
       at NUnit.Framework.Assert.ReportFailure(ConstraintResult result, String message, Object[] args)
       at NUnit.Framework.Assert.AreEqual(Object expected, Object actual)
       at MonoTests.System.Net.Http.MessageHandlerTest.<>c__DisplayClass14_0.<RejectSslCertificatesWithCustomValidationCallbackNSUrlSessionHandler>b__2(HttpRequestMessage sender, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors errors) in /Users/builder/azdo/_work/2/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:line 613
       at Foundation.NSUrlSessionHandler.ServerCertificateCustomValidationCallbackHelper.Invoke(HttpRequestMessage request, SecTrust secTrust)
       at Foundation.NSUrlSessionHandler.TryInvokeServerCertificateCustomValidationCallback(HttpRequestMessage request, SecTrust secTrust, Boolean& trusted)
       at Foundation.NSUrlSessionHandler.NSUrlSessionHandlerDelegate.DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action`2 completionHandler)
    --- End of stack trace from previous location ---
       at ObjCRuntime.Runtime.InvokeMethod(MethodBase method, Object instance, IntPtr native_parameters)
       at ObjCRuntime.Runtime.InvokeMethod(MonoObject* methodobj, MonoObject* instanceobj, IntPtr native_parameters)
       at ObjCRuntime.Runtime.bridge_runtime_invoke_method(MonoObject* method, MonoObject* instance, IntPtr parameters, IntPtr& exception_gchandle)
    '
    *** First throw call stack:
    (
    	0   CoreFoundation                      0x00007ff81dba97c3 __exceptionPreprocess + 242
    	1   libobjc.A.dylib                     0x00007ff81d909bc3 objc_exception_throw + 48
    	2   monotouchtest                       0x000000010426e524 xamarin_process_managed_exception + 820
    	3   monotouchtest                       0x00000001042fec76 _ZL32native_to_managed_trampoline_183P11objc_objectP13objc_selectorPP11_MonoObjectS0_S0_S0_S0_j + 1302
    	4   monotouchtest                       0x00000001042fe750 -[Foundation_NSUrlSessionHandler_NSUrlSessionHandlerDelegate URLSession:task:didReceiveChallenge:completionHandler:] + 80
    	5   CFNetwork                           0x00007ff8225d3635 _CFHostIsDomainTopLevelForCertificatePolicy + 13206
    	6   libdispatch.dylib                   0x00007ff81d8af0cc _dispatch_call_block_and_release + 12
    	7   libdispatch.dylib                   0x00007ff81d8b0317 _dispatch_client_callout + 8
    	8   libdispatch.dylib                   0x00007ff81d8b6317 _dispatch_lane_serial_drain + 672
    	9   libdispatch.dylib                   0x00007ff81d8b6e30 _dispatch_lane_invoke + 417
    	10  libdispatch.dylib                   0x00007ff81d8c0eee _dispatch_workloop_worker_thread + 753
    	11  libsystem_pthread.dylib             0x00007ff81da63fd0 _pthread_wqthread + 326
    	12  libsystem_pthread.dylib             0x00007ff81da62f57 start_wqthread + 15
2022-10-24 22:34:16 +02:00
Rolf Bjarne Kvinge e4164d508a
[tests] Ignore ExceptionsTest.ManagedExceptionPassthrough on ARM64 desktop. (#16384)
Ignore ExceptionsTest.ManagedExceptionPassthrough on ARM64 desktop until we
fix the underlying bug.

Ref: https://github.com/xamarin/xamarin-macios/issues/16264
2022-10-19 14:40:57 +02:00
Haritha Mohan f160ec03c9
[Foundation] Implement IEquatable and IComparable for NSOperatingSystemVersion (#16308)
Implemented the interfaces for NSOperatingSystemVersion, can now compare
instances and check for equality using operators.

Fixes #15721

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-10-18 10:25:28 -07:00
Rolf Bjarne Kvinge cb6f555665 Merge main into xcode14.1. 2022-10-17 11:35:33 +02:00
Simon Rozsival 7171baaeca
[Foundation] Implement the server certificate custom validation callback usage in NSUrlSessionHandler (#15117)
We recently implemented the `ServerCertificateCustomValidationCallback` in Xamarin.Android (https://github.com/xamarin/xamarin-android/pull/6665). It would be great to have feature parity and support the same callback in Xamarin.iOS and Xamarin.Mac.

Related to https://github.com/dotnet/runtime/issues/68898.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/14632.

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-10-17 10:14:39 +02:00
Israel Soto bac36c5040
[VideoToolbox] Added support for Xcode 14 b1-3 (#15845)
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-10-13 11:27:15 -04:00
Israel Soto 17f0ffd332
[SharedWithYouCore] Added support for Xcode 14.1 b3 (#16198)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-10-12 12:09:00 -04:00
Rolf Bjarne Kvinge 1913c3efed
[tests] Re-enable tests that were disabled in Xcode 12 beta 1. Fixes #9531. (#16307)
Looks like some of these tests are working in the simulator now.

I also confirmed that ARReferenceObjectTest.MarshallingTest test should be
ignored in the simulator by verifying that Xcode gets the same behavior we do
(i.e. it doesn't work).

Fixes https://github.com/xamarin/xamarin-macios/issues/9531.
2022-10-11 23:25:14 +02:00
Rolf Bjarne Kvinge 45b97d838e Merge main into xcode14.1. 2022-10-06 13:59:29 +02:00
Rolf Bjarne Kvinge 273c2fa51a
[Foundation] Add NSArray.ToArray and implement IEnumerable<NSObject>. (#16252)
For NSArray, implement:

* A ToArray () method that returns an NSArray[].
* A ToArray<T> () method that returns a T[].
* The IEnumerable<NSObject> interface.

For NSArray<T>, implement:

* A ToArray () method that returns a T[].

This should make NSArray much better to work with from managed code.
2022-10-06 08:37:02 +02:00
Rolf Bjarne Kvinge c7badeacf1 Merge main into xcode14.1. 2022-10-04 16:21:54 +02:00
Rolf Bjarne Kvinge 5078c8b065
[AVFoundation] Fix the AVAudioFormat.StreamDescription binding. Fixes #8892. (#16206)
The property returns a pointer to a struct, not the struct itself.

Fixes https://github.com/xamarin/xamarin-macios/issues/8892.
2022-10-03 22:18:07 +02:00
Rolf Bjarne Kvinge 7e6edcbc36
[Network] Fix a few issues with the callbacks in NWPath. Fixes #13772. (#16138)
* Change EnumerateGateways to use the 'static_EnumerateGatewaysHandler'
  callback. It looks like this was a c&p error, since the
  'static_EnumerateGatewaysHandler' callback was implemented, just never
  referenced anywhere.
* Add an overload to EnumerateGateways and EnumerateInterfaces that takes a
  callback that returns a bool indicating whether the enumeration should
  continue. This mirrors the native API.
* Obsolete the EnumerateGateways and EnumerateInterfaces overloads that take a
  void callback (and remove in XAMCORE_5_0).
* Add a test for EnumerateGateways that works (the previous failed, but never
  asserted the failure, so it would just silently time out).

Fixes https://github.com/xamarin/xamarin-macios/issues/13772.
2022-10-03 12:11:52 +02:00
Rolf Bjarne Kvinge 9c3458dc33 Merge main into xcode14.1. 2022-09-26 22:46:59 +02:00
Rolf Bjarne Kvinge b82b1685a7
Use Environment.SpecialFolder.UserProfile, not SpecialFolder.Personal. (#16017)
Context: dotnet/runtime#68610
Context: https://github.com/xamarin/xamarin-android-tools/commit/0be567a9

In Mono and .NET prior to .NET 8, the
[`System.Environment.SpecialFolder`][0]`.Personal` enum value would refer to
`$HOME` on Unix platforms.

This will be changing in .NET 8, such that
`Environment.SpecialFolder.Personal` will instead refer to
`$XDG_DOCUMENTS_DIR` (if set) or `$HOME/Documents`.  This is for "semantic
compatibility" with .NET on Windows.

Replace usage of `Environment.SpecialFolder.Personal` with
`Environment.SpecialFolder.UserProfile`, so that our code continues to work as
expected under .NET 8.

[0]: https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=net-6.0
2022-09-23 16:29:19 +02:00
Rolf Bjarne Kvinge f4d5e6eeab Merge main into xcode14.1. 2022-09-22 07:50:58 +02:00
Haritha Mohan a9c8efa893
[UIKit] Add Constructor for UIHoverGestureRecognizer (#15837)
Fixes #15335

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-09-21 12:54:10 -07:00
Rolf Bjarne Kvinge 5fda07d3f3 Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14.1-2022-09-15 2022-09-15 09:29:28 +02:00
Rolf Bjarne Kvinge 594e88bfca
[tests] Adjust test for tvOS and watchOS. (#15939)
Probably regressed after 61e8ce443f.

Fixes https://github.com/xamarin/maccore/issues/2618.
2022-09-13 16:06:10 +02:00
Rolf Bjarne Kvinge 9a839d6c4a
Merge main into xcode14. (#15928) 2022-09-13 10:58:30 +02:00
Manuel de la Pena f2560aafe8
[AudioToolbox] Add support for xcode 14 beta6. (#15877) 2022-09-12 10:34:44 -04:00
Rolf Bjarne Kvinge 68eb7d401f Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-09-12 2022-09-12 11:27:02 +02:00
Rolf Bjarne Kvinge 61e8ce443f
[tests] Skip SecRecord tests on macOS 11 (#15825)
It may hang on the bots.
2022-09-09 20:29:37 +02:00
Rolf Bjarne Kvinge 9bca30dce6 Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-09-09 2022-09-09 16:54:19 +02:00
TJ Lambert de7dccd8b0
[AVKit and AVRouting] Updates for Xcode14 Beta3 (#15811)
This PR has the AVKit updates and introduces the AVRouting bindings that
are interconnected with AVKit

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-09-08 15:13:15 -05:00
Manuel de la Pena 0eef1b6deb
[Network] Add support for Xcode 14 beta 6. (#15841)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-09-08 10:55:52 -04:00
Rolf Bjarne Kvinge c5615ae77c
[CoreCLR] Handle ref/out enum values as parameters. Fixes #15744. (#15870)
CoreCLR complains that enum values aren't blittable when passed to
Marshal.StructureToPtr, so unwrap enum values first.

Fixes https://github.com/xamarin/xamarin-macios/issues/15744.
2022-09-07 12:57:06 +02:00
Rolf Bjarne Kvinge 433c48a35e Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-09-07 2022-09-07 10:56:00 +02:00
TJ Lambert fe9c46cc91
[NearbyInteraction] Updates for Xcode14 Beta 1 (#15840)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-09-06 16:11:52 -04:00
Chris Hamons e43e05c298
[CoreGraphics] Xcode 14 Beta 1-5 (#15831)
**Note:** This PR is almost entirely of manual (but simple) bindings, and the documentation of these CG methods is non-existent. I had to add add MarshalAs and change pointers to IntPtr by hand, so please review carefully. 

I wrote "did not crash/return null" manual tests, which I could improve upon if desired, but I'd have to re-learn some matrix math and figure out what each method does under the hood (Alex thought this would likely be fine).

A few important notes:

- CGAffineTransformComponents is in CoreFoundation as it was defined (but not used) in those API diffs. There is a define `CF_DEFINES_CGAFFINETRANSFORMCOMPONENTS` which allows CoreGraphics to declare it in the headers, but I'm assuming that is a hack for Apple.
- The headers/docs for kCGColorSpaceITUR_709_HLG lie and claim it's in older OS than it seems to be, so I assumed latest instead.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-09-02 09:24:35 -05:00
TJ Lambert 7bd98383e1
[HealthKit] Update bindings for Xcode 14 beta 1-4 (#15612)
This one has been a toughy 😮‍💨
@mandel-macaque I am creating the draft PR and here is a gist with the MacModern failures that you mentioned you would take a closer look at: https://gist.github.com/tj-devel709/24f5c63d4b698a0e2387524a0d2666c6

There were also monotouch-test failures that seem to be related to enabling mac that I could use some help with as well.

Lastly, @chamons there was a failing Cecil test regarding ios in DidGenerateEvent method found here: https://gist.github.com/tj-devel709/2c8aee7325c0c2751e29269d3eb77fef. I did not touch this method so I am not sure why this would be a problem.
Here is the Cecil failure: https://gist.github.com/tj-devel709/cfb2576c75de2ee100a8f2b7ee6e3923

Thanks for the help!

Edit *: Issues mentioned in the code comments
https://github.com/xamarin/maccore/issues/2609
https://github.com/xamarin/maccore/issues/2610

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-09-01 10:24:35 -05:00
Haritha Mohan a2b23186cc
[UIKit] Add Preferred Content Size Wrapper (#15800)
Fixes xamarin/xamarin-macios#15687
Added type safe wrapper for ContentSizeCategory

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-08-31 13:05:51 -07:00
Rolf Bjarne Kvinge ff3aeb5073 Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-08-30 2022-08-30 11:14:47 +02:00
Rolf Bjarne Kvinge 5e8d70f95e
[tests] Improve detection of bad CI networks. (#15516) 2022-08-29 15:42:40 +02:00
Manuel de la Pena 8cecb962a4
[UIKit] Add support for Xcode 14 up to beta 5. (#15694)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-08-26 20:14:11 -04:00
Rolf Bjarne Kvinge 4289148b28 Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-08-26 2022-08-26 13:24:27 +02:00
TJ Lambert 14d73a3048
[NaturalLanguage] Updates for Xcode14 Beta 2 (#15718)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-08-25 12:42:34 -05:00
Rolf Bjarne Kvinge e372914ce0
[tests] Adjust MonoTouchFixtures.SceneKit.Invert to cope with tiny expected differences. (#15750)
This seems to happen on macOS 10.15 only for some reason.
2022-08-25 16:24:30 +02:00
Rolf Bjarne Kvinge d66c4da1af Merge remote-tracking branch 'origin/main' into xcode14-merge-main-2022-08-22 2022-08-22 18:38:32 +02:00
Rolf Bjarne Kvinge e54019a336
[dotnet] Make it possible to specify the registrar using a 'Registrar' property in MSBuild. (#15483)
Co-authored-by: Marius Ungureanu <therzok@gmail.com>
2022-08-18 17:21:48 +02:00
Alex Soto 1d40aa42dd
[xcode14] Bump to latest Xcode 14 Beta 5 (#15663)
* [xcode14] Bump to latest Xcode 14 Beta 5

* [CloudKit] Fix cloudkit intro on tvOS

* Revert "[Tests] Fix an monotouch-test test that landed broken. (#15503)"

This reverts commit 161de84bcf.

* Update tools/common/StaticRegistrar.cs

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>

* Fix typo

* [CHIP] Tell our drivers to not link CHIP at all

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-08-10 11:11:40 -04:00
Manuel de la Pena 57adecc437 Merge branch 'main' into xcode14-merge-main 2022-08-03 10:34:56 -04:00
Chris Hamons 3c359f5838
[foundation] Xcode 13 & Xcode 14 beta 1-3 bindings (#15579)
- Xcode 13 section Based upon https://github.com/xamarin/xamarin-macios/pull/13328- 
- Some disabled due to https://github.com/xamarin/maccore/issues/2608
2022-08-01 10:22:39 -05:00
TJ Lambert 481e3ec53a
[Fix] Reorder the enum to the correct order (#15540)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-07-26 11:40:12 -04:00
Manuel de la Pena 161de84bcf
[Tests] Fix an monotouch-test test that landed broken. (#15503) 2022-07-15 11:18:01 -04:00
Rolf Bjarne Kvinge 12925a7952
[xcode14] Merge main into xcode14. (#15502)
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
2022-07-15 10:22:11 +02:00
Manuel de la Pena 5f462a16e8
[xcode14] Merge main into xcode14. 2022-07-13 10:25:02 -04:00
Rolf Bjarne Kvinge bc23ece1fc
[monotouch-test] Improve MonoTouchFixtures.ObjCRuntime.ToggleRefRetainDeadlockTest to get a native stack trace upon failure. (#15476) 2022-07-13 10:40:33 +02:00
Rolf Bjarne Kvinge 5c7f866e37
Revert workarounds for broken dlopen in Xcode 14 beta 1. Fixes #15231. (#15383)
Fixes https://github.com/xamarin/xamarin-macios/issues/15231.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-07-12 17:44:28 +02:00
Rolf Bjarne Kvinge f8ff530796 Merge remote-tracking branch 'origin/main' into xcode14-merge-main-2022-07-12 2022-07-12 14:52:32 +02:00
Rolf Bjarne Kvinge d251b69ae7
[generator] Don't use culture-aware API. (#15392)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-07-11 19:59:36 +02:00
Rolf Bjarne Kvinge 50db0e315e [monotouch-test] Adjust a few tests according to new behavior. 2022-06-28 22:20:45 +02:00
Rolf Bjarne Kvinge 24db3eca11 [monotouch-test] Adjust a ShouldAutorotate test to cope with Apple dropping support for 'shouldAutorotate'. 2022-06-28 22:20:22 +02:00
Rolf Bjarne Kvinge ff20062685 [monotouch-test] Ignore the MnistTest in the simulator, Apple broke things on their side. 2022-06-28 22:19:45 +02:00
Rolf Bjarne Kvinge 99672cd028 [tests] Fix a few GLKit tests to not be unnecessarily culture sensitive. 2022-06-28 22:19:17 +02:00
Rolf Bjarne Kvinge a358b493fd Merge remote-tracking branch 'origin/xcode14' into HEAD 2022-06-21 16:12:26 +02:00
Rolf Bjarne Kvinge 42c1c66a14
[SceneKit] Fix SCNMatrix4 in .NET. Fixes #15094. (#15160)
When we changed SCNMatrix4 to be column-major instead of row-major in .NET, there
were several other related changes we should have done but didn't do. In particular
we should have made transformation operations based on column-vectors instead of
row-vectors.

In legacy Xamarin, a vector would be transformed by a transformation matrix by doing
matrix multiplication like this:

    [ x y z w] * [ 11 21 31 41 ]
                 | 12 22 32 42 |
                 | 13 23 33 43 |
                 [ 14 24 34 41 ]

In this case the vector is a row-vector, and it's the left operand in the multiplication.
When using column-major matrices, we want to use column-vectors, where the vector
is the right operand, like this:

    [ 11 21 31 41 ] * [ x ]
    | 12 22 32 42 |   | y |
    | 13 23 33 43 |   | z |
    [ 14 24 34 41 ]   [ w ]

This affects numerous APIs in SCNMatrix4, SCNVector3 and SCNVector4:

* The M## fields have been changed to make the first number the column and the
  second number the row, to reflect that it's a column-major matrix (this is
  also how it's defined in the native SCNMatrix4 type).
* Functions that return a transformation matrix have been modified to return column-vector
  transformers. Technically this means that these matrices are transposed compared
  to legacy Xamarin. The functions involved are:
    * CreateFromAxisAngle
    * CreateRotation[X|Y|Z]
    * CreateTranslation
    * CreatePerspectiveFieldOfView
    * CreatePerspectiveOffCenter
    * Rotate
    * LookAt
* Combining two column-vector transforming transformation matrices is done by multiplying
  them in the reverse order, so the Mult function (and the multiplication operator)
  have been modified to multiply the given matrices in the opposite order (this matches
  how the SCNMatrix4Mult function does it). To make things clearer I've changed the
  parameter names for XAMCORE_5_0.
* Functions that transform a vector using a transformation matrix have been modified
  to do a column-vector transformation instead of a row-vector transformation. This
  involves the following functions:
    * SCNVector3.TransformVector
    * SCNVector3.TransformNormal
    * SCNVector3.TransformNormalInverse
    * SCNVector3.TransformPosition
    * SCNVector4.Transform
* Numerous new tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/15094.
2022-06-17 20:17:05 +02:00
TJ Lambert db9412b542
[passkit] Add nullability to (generated and manual) bindings (#15262)
* Validating Null ignores and adding tests

* add nullability

* use is null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-06-15 11:33:06 -05:00
Rolf Bjarne Kvinge 8adbefdac8
[runtime] Fix 'skip_nested_brace' to not read past the string. Fixes #15253. (#15257)
Fix 'skip_nested_brace' to not double skip characters.

Also add a test.

Fixes https://github.com/xamarin/xamarin-macios/issues/15253.
2022-06-14 14:26:07 +02:00
Rolf Bjarne Kvinge 913ef62e64 Merge remote-tracking branch 'origin/xcode14' into xcode14-initial-pr 2022-06-10 11:06:36 +02:00
Manuel de la Pena c1b5c4029c
[Tests] Ensure we do check the catalyst version on catalyst. (#15240) 2022-06-09 17:28:00 -04:00
Manuel de la Pena dfe1063e0f
Merge branch 'xcode14' into xcode14-initial-pr 2022-06-09 12:33:01 -04:00
Manuel de la Pena c68372d6f4
[CI] Make sure that we check the versions catalina in the tests. Fixes test failures. (#15224) 2022-06-08 17:35:31 -04:00
Rolf Bjarne Kvinge 662fbe9d74 [runtime] Work around broken dlopen in new OSes in Xcode 14.
dlopen is broken in the latest OS versions: if you pass the path to a symlink, dlopen
will (re)open the target file even if the target file is already loaded (presumably
using the real path and not the symlink).

I've worked around it by redirecting DllImports to libobjc.dylib and libSystem.dylib
to the corresponding real path, and also updating some of our constants to point
to the real path and not a symlink.

The workarounds only work for .NET, legacy Xamarin would need a fix in Mono to
not dlopen "libc.dylib" here (and instead load "libSystem.B.dylib"):
f354099a6b/mono/metadata/w32file-unix.c (L4953)

Ref: https://github.com/xamarin/maccore/issues/2585.
2022-06-08 20:56:35 +02:00
Rolf Bjarne Kvinge a1d0b6eba9
Make our local .NET the default .NET for the build. (#15086)
Make our local .NET the default .NET (in the root's global.json), and then if
a directory wants to use the system .NET, then that directory would have to
opt-in (using its own global.json).

This way we don't have to copy global.json/NuGet.config files around to run
tests with the correct .NET setup.
2022-06-07 10:11:02 +02:00
TJ Lambert 7731894b71
[mediaplayer] Add nullability to (generated and manual) bindings (#15147)
* Confirm nullability in the ignore files

* use is null and is not null

* Remove unnecessary using statements for test

* undo the changes to the csproj

* remove monotouch-test.sln

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-06-06 10:11:11 -05:00
TJ Lambert 9bf39cd985
[homekit] Add nullability to (generated and manual) bindings (#15111)
* go through the nullable ignores and add test

* Enable Nullability

* use is null

* save a few lines

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-06-06 10:05:38 -05:00
Rolf Bjarne Kvinge 46b393ac5e
[tests] Adjust a few linker tests to cope with unreliable networks. (#15018)
* Handle 502 and 503 errors in the TrustUsingOldPolicy and TrustUsingNewCallback tests. Fixes:

    [FAIL] TrustUsingOldPolicy : System.Net.WebException : The remote server returned an error: (503) Service Unavailable.
    [FAIL] TrustUsingNewCallback : System.Net.WebException : The remote server returned an error: (503) Service Unavailable.

* Add more http and https urls to try (and don't use microsoft.com). Hopefully fixes:

    [FAIL] WebClient_SSL_Leak : At least one url should work

This is a follow-up to #14943.
2022-05-16 11:41:13 +02:00
Rolf Bjarne Kvinge 706663845d
[tests] Adjust a few tests to try network requests multiple times. (#14943)
* A few tests seem to be failing rather consistently with network errors.
  Rewrite these tests to try multiple urls before failing (we'll be assuming
  that if one of the urls succeed, the other failures were network related).

* Rename the LinkAnyTest.WebClientTest to LinkAnyTest.WebClientTest_Http to
  follow it's original intent, and make it test http instead of https.

* Remove unnecessary assertion from SSL_IP_5706. This is tested in plenty of other places.
2022-05-13 08:50:28 +02:00
Rolf Bjarne Kvinge a6c92d9a25
[tests] Ignore the new MnistTester test on the bots. (#15002)
Bots seems to break more often after this change, so let's see if this improves matters.

This is what happens with the bots:

    We stopped hearing from agent [...]. Verify the agent machine is running and has a healthy network connection. Anything that terminates an agent process, starves it for CPU, or blocks its network access can cause this error. For more information, see: https://go.microsoft.com/fwlink/?linkid=846610
2022-05-12 16:07:04 +02:00
Frank A. Krueger bd4fee0cdc
Add MetalPerformanceShadersGraph Bindings (#14303)
I'm very pleased to present full bindings to the MetalPerformanceShadersGraph framework!

I'm happy with how everything turned out with the exception of a few notes and questions below.

I re-implemented Apple's MNIST sample (from https://developer.apple.com/documentation/metalperformanceshadersgraph/training_a_neural_network_using_mps_graph) here:

https://gist.github.com/praeclarum/b8077771fb341a1f9c28240113e00425

It's also added as a unit test.

Fixes #14286

### Notes

* Although the API says it works on macOS 11, it has bugs and crashes with errors even with Apple’s Swift examples. It’s better on macOS 12. iOS 14 and on is fine.

* `MPSGraphSparseStorageType` has terrible names. They match Apple's but I wish they were better.

* I added convenience methods to `MPSNDArray` and `MPSGrapTensorData` and the `Variable` and `Constant` operations to decrease the amount of unsafe code users have to write. I currently do this for 32-bit floats, the most common data type.

Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-05-10 10:52:22 +02:00
Rolf Bjarne Kvinge f8314a435e
Add a [NativeName] attribute we can use to declare the native name for a type (enum/struct). (#14918)
We already have a few attributes that can specify the native name for a type, whenever the native name doesn't match the managed name:

* [Register ("DifferentClassName"): specifies the Objective-C class name
* [Native ("DifferentEnumName")]: specifies the Objective-C enum name (and also that it's a native-sized enum)
* [Protocol ("DifferentProtocolName")]: specifies the Objective-C protocol name
* [Category ("DifferentCategoryName")]: specifies the Objective-C category name

Unfortunately this leaves (at least) two cracks:

* Objective-C structs.
* Objective-C enums which aren't native-sized.

So I'm adding a [NativeName] attribute for this purpose, and updating numerous
types to specify the native name (either using an existing [Native] attribute
for enums that already have one, or by adding a new [NativeName] attribute).

The static registrar needs to know the native name for such types, in case
they appear as parameter types in function signatures.

This also allows us to simplify xtro a bit, to not have a separate map of
managed name given a native name, because we can now build that map
dynamically.
2022-05-09 22:16:17 +02:00
Chris Hamons 6a1622624a
Fix crash with NSUrl implicit conversion and null (#14860)
- Fixes: https://github.com/xamarin/xamarin-macios/issues/14786
2022-05-06 08:52:37 -05:00
TJ Lambert 6dc0eed0a8
[healthkit] Add nullability to (generated and manual) bindings (#14730)
* remove null ignores and add nullability

* throw better exception

* use is null

* remove extra ignores

* Add the tests

* use a progma ignore instead

* revert monotouch-test.csproj

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-28 11:54:23 -05:00
TJ Lambert 717b141f16
[gameplaykit] Add nullability to (generated and manual) bindings (#14615)
* adding Nullability

* throw better null exceptions

* use is null

* Added test

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-04-28 11:26:18 -05:00
TJ Lambert bd4501ac88
[naturallanguage] Add nullability to (generated and manual) bindings (#14741)
* adding nullability changes

* throwing better exceptions

* using is null

* address Rolf and Manuel nullability changes

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-26 09:50:51 -05:00
Rolf Bjarne Kvinge 042c97735c
[tests] Fix registrar tests to not return unretained INativeObjects to Objective-C. Fixes #xamarin/maccore@2572. (#14807)
We can't return unretained INativeObjects to Objective-C, because they might
be freed at any point when the GC collects the managed object. Instead return
retained objects, that way they're not freed even if the GC collects the
managed object.

This fixes a random crash in the TestRegistrar.TestINativeObject when the GC
would run just after we've returned an INativeObject to native code, and later
used that native handle thinking it would still be valid.

Fixes https://github.com/xamarin/maccore/issues/2572.
2022-04-26 07:28:50 +02:00
Rolf Bjarne Kvinge 254a47c440
[tests] Improve NWProtocolStackTest to not crash the process if the state change handler throws an exception. (#14697) 2022-04-11 16:38:20 -04:00
Rolf Bjarne Kvinge 2125c8febe
[tests] Make MonoTests.System.Net.Http.MessageHandlerTest handle some 504's. (#14688) 2022-04-07 18:01:25 +02:00
Rolf Bjarne Kvinge a46afd0147
[tests] Use 'BundledNETCoreAppTargetFrameworkVersion' to specify the .NET version in the project files. (#14666)
This way we don't have to update all these files when moving to .NET 7.
2022-04-06 20:58:20 +02:00
Manuel de la Pena 46af411d1c
[Foundation] Allow null parameters when creating a NSUrl from a string. (#14603)
The headers do not say that a null parameter is allowed, but the
documentation and tests state otherwise:

https://developer.apple.com/documentation/foundation/nsurl/1572047-urlwithstring

The URL string with which to initialize the NSURL object. Must be a URL that conforms to RFC 2396. This method parses URLString according to RFCs 1738 and 1808.
2022-04-02 15:13:52 -04:00
Rolf Bjarne Kvinge 08978fa4b1
[dotnet] Rename hardcoded 'net6.0' to use a 'DOTNET_TFM' variable instead. (#14524)
This makes things easier for .NET 7.
2022-04-01 13:48:09 +02:00
Rolf Bjarne Kvinge 2af5fc3c56
[monotouch-test] Attempt to fix monotouch-tests on macOS 10.15. (#14520) 2022-03-29 07:51:40 +02:00
Rolf Bjarne Kvinge e369f466f7
[dotnet] Rename the DOTNET6 make variable to DOTNET. (#14441)
This is the follow-up to where the DOTNET variable was renamed SYSTEM_DOTNET.
2022-03-21 15:56:57 +01:00
Manuel de la Pena e07b7bef79
[CI] Move tests outside of the build machine. (#14105)
Move the execution of tests to a diff bot to be compliant with the latests EO.
2022-03-10 23:36:37 -05:00
Aaron Bockover 23c8620af0
FSEventStream: bind FSEventStreamCreateRelativeToDevice, FSEventStreamGetDeviceBeingWatched (#14357)
Introduce `FSEventStreamCreateOptions` to avoid a slew of .ctor overrides, and make it easier to specify `DeviceToWatch` and `SinceWhenId`. `SinceWhenId` was previously only exposed on the "low level" .ctor, and it's a rather important parameter for supporting events that may have happened while the application was not running.

Make the existing constructors wrap `FSEventStreamCreateOptions` to avoid API break.

This is a followup to #14318. When using device-relative watches, files can be tracked via a tuple of their device ID and inode instead of paths. #14318 exposes inode data on `FSEvent`.
2022-03-10 21:30:57 +01:00
Aaron Bockover 9fe2a5c28c
FSEventStream: fix crash when asking for extended data; support dispatch queues (#12007) (#14318)
Implements support for `FSEventStreamCreateFlags.UseExtendedData`, fixing #12007.

When `.UseExtendedData` is specified, the event data type changes from `CFString` to `CFDictionary`; the dictionary contains the path (`path` key) and inode (`fileID` key) information for the file and may be extended in the future with other fields. Previously this was crashing because we assumed `CFString` always.

Further add a convenience constructor for monitoring a single path, add the missing `UnscheduleFromRunLoop` APIs, and add `SetDispatchQueue` to allow using dispatch queues directly instead of run loops.

Finally, this PR adds a fairly exhaustive file system test which covers the existing (non-extended) and fixed (extended) creation modes, along with using a dispatch queue instead of run loop.

Fixes https://github.com/xamarin/xamarin-macios/issues/12007
2022-03-09 19:05:10 +01:00
Rolf Bjarne Kvinge c98a6d01cc
[HealthKit] Add this framework to Mac Catalyst. (#14312) 2022-03-09 18:18:48 +01:00
Manuel de la Pena 488a647b49
[Tests] Ignore certain tests that do not longer work on bots. (#14326)
The new tests do not have a display and that makes certain mac tests
fail. Added a new TestRuntime function to let us know if we are on vsts
and ignore accordingly.

fixes https://github.com/xamarin/maccore/issues/2546


Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-03-09 11:24:53 -05:00
Rolf Bjarne Kvinge 3a124d3f10
[tests] Don't use reflection to create HttpClient handlers. (#14333)
Fixes two test failures on tvOS with all optimizations enabled:

    MonoTests.System.Net.Http.MessageHandlerTest.DnsFailure
        [FAIL] DnsFailure(System.Net.Http.SocketsHttpHandler) :   Exception
            Expected: instance of <System.Net.Http.HttpRequestException>
            But was:  <System.MissingMethodException: No parameterless constructor defined for type 'System.Net.Http.SocketsHttpHandler'.
                at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
                at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
                at System.Activator.CreateInstance(Type , Boolean , Boolean )
                at System.Activator.CreateInstance(Type , Boolean )
                at System.Activator.CreateInstance(Type )
                at MonoTests.System.Net.Http.MessageHandlerTest.GetHandler(Type ) in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:line 50
                at MonoTests.System.Net.Http.MessageHandlerTest.<>c__DisplayClass3_0.<<DnsFailure>b__0>d.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:line 76>

    MonoTests.System.Net.Http.MessageHandlerTest.RejectSslCertificatesServicePointManager
        [FAIL] RejectSslCertificatesServicePointManager(System.Net.Http.SocketsHttpHandler) : System.MissingMethodException : No parameterless constructor defined for type 'System.Net.Http.SocketsHttpHandler'.
            at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
            at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
            at System.Activator.CreateInstance(Type , Boolean , Boolean )
            at System.Activator.CreateInstance(Type , Boolean )
            at System.Activator.CreateInstance(Type )
            at MonoTests.System.Net.Http.MessageHandlerTest.GetHandler(Type ) in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:line 50
            at MonoTests.System.Net.Http.MessageHandlerTest.RejectSslCertificatesServicePointManager(Type ) in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:line 405
            at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
2022-03-09 08:11:06 +01:00
Rolf Bjarne Kvinge 074a90496f
[tests] Don't try to create an instance of PKPaymentAuthorizationViewController. (#14334)
The default constructor doesn't work (it's already obsolete).

Fixes:

    Xamarin.Mac.Tests.DelegateAndDataSourceTest
        [FAIL] DelegateAndDataSourceAllowsNull : 1 failing types
            1 failing types:
            PassKit.PKPaymentAuthorizationViewController: Could not initialize an instance of the type 'PassKit.PKPaymentAuthorizationViewController': the native 'init' method returned nil.
            It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
                at Xamarin.Mac.Tests.DelegateAndDataSourceTest.DelegateAndDataSourceAllowsNull () [0x0026c] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/ObjCRuntime/DelegateAndDataSourceTest.cs:90
2022-03-09 08:10:21 +01:00
Rolf Bjarne Kvinge 83c1ee189a
[monotouch-test] Adjust ImageCaptioningTest to work on older versions of macOS for Mac Catalyst. (#14265)
Also improve assert messages a bit to not have multiple asserts with the same message.
2022-03-01 08:36:26 +01:00
Rolf Bjarne Kvinge ddb16120f9
[monotouch-test] Fix UbiquitousKeyValueStoreTest to work on newer versions of macOS. (#14267)
Fixes:

    MonoTouchFixtures.Foundation.NSUbiquitousKeyValueStoreTest
        [FAIL] Indexer :   key 1
            Expected: <value>
            But was:  null
2022-02-28 22:36:05 +01:00
Rolf Bjarne Kvinge 681b45bd41
[monotouch-test] Fix the BaseEffectTest and EffectPropertyMaterialTest tests. (#14243)
The [Culture ("en")] attribute means: only run this test if the culture is
"en". This usually meant not running this test (apparently we don't run often
with culture = "en"), leading to outdated tests that happened to fail when
actually run under culture = "en" (such as on older macOS bots).

So change these tests to actually change the culture to "en" (by using the
SetCulture attribute), and also fix them.
2022-02-25 09:19:08 +01:00
Rolf Bjarne Kvinge 3fb288ff5c
[Foundation] Remove NSUrlSessionHandler.TrustOverride in .NET. (#14214)
It's better to use the TrustOverrideForUrl property instead, which already exists.
2022-02-24 23:08:21 +01:00
Rolf Bjarne Kvinge 2f494665bc
[Network] Remove obsolete API from .NET. (#14211)
All the obsolete API has replacement API that works just fine.
2022-02-24 23:07:53 +01:00