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

1260 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge e4c940cdb8
[Foundation] Fix NSDate's explicit conversion operators with DateTime. (#16872)
We recently tried to fix NSDate's conversion operators with DateTime
(3c65ab1756), but unfortunately a corner case
was missed.

The new approach in the above-mentioned commit would get the individual
date/time components for a given date and use the appropriate constructor for
the other type to re-construct the date/time in question.

However, one case was missed: when converting from NSDate to DateTime, we'd
get a fractional number of milliseconds. This fractional number could be
something like 999.99 milliseconds, and when converting that to the int the
DateTime constructor expected for the number of milliseconds, then DateTime
would throw an exception, because the number of milliseconds could only be
between 0 and 999.

I've solved this by not using floating-point math in the computations. We're
now getting the number of nanoseconds from the NSDate (which is a natural
number, and represents the total number of nanoseconds less than a whole
second), and then converting that to the number of milliseconds, microseconds
and ticks that can be used with DateTime using integral math. Unfortunately
DateTime doesn't have a constructor that takes the remaining number of ticks
after all the other fields have been provided, but that can be added
afterwards.

I've also made a few other improvements:

* Improve the validation for the NSDate -> DateTime conversion to detect BC
  dates by using the NSDate's Era component (to throw because DateTime only
  supports AC dates). Also don't allow a tick later than year 10.000 (DateTime
  only supports up to a tick before year 10.000) - but explicitly support
  exactly year 10.000, and convert it to DateTime.MaxValue (this is because
  due to precision errors NSDate can't actually express 'a tick before year
  10.000', it ends up being rounded up to year 10.000 exactly). This means
  there are no more magical values in the range validation checks.
* Increase precision in the DateTime -> NSDate conversion by starting with the
  sub-second amount of ticks from the DateTime instance (instead of the number
  of milliseconds). This allows us to compute the nanoseconds NSDate expects
  with much higher precision.
* More tests!

Fixes this test:

    MonoTouchFixtures.Foundation.DateTest.DateTimeToNSDate : 2 ms
        [FAIL] Precision32022 : System.ArgumentOutOfRangeException : Valid values are between 0 and 999, inclusive.
            Parameter name: millisecond
            at System.DateTime..ctor (System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second, System.Int32 millisecond, System.DateTimeKind kind) [0x0002d] in <4d40c65adfc14d7fb19bad9310f3eb2a>:0
            at Foundation.NSDate.op_Explicit (Foundation.NSDate d) [0x000b8] in <9cb1e1018c034b75ba5f4ed7b83ba2f2>:0
            at MonoTouchFixtures.Foundation.DateTest.Precision32022 () [0x0000c] in <c44b5df5f7b84b69b737e9fd61bddaed>:0
            at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
            at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <4d40c65adfc14d7fb19bad9310f3eb2a>:0

Fixes https://github.com/xamarin/maccore/issues/2632.

Date and time is difficult.

Ref: https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca
Ref: the rest of internet...
2022-11-23 07:55:22 +01:00
Rolf Bjarne Kvinge 0e778737c7
[tests] Adjust TestNSurlSessionHandlerCookieContainer* tests to not fail in CI in case of network problems. Fixes #2197. (#16817)
Fixes:

    [FAIL] TestNSurlSessionHandlerCookieContainerSetCookie :   Cookies received from server.
        Expected: 1
        But was:  0
            at MonoTests.System.Net.Http.MessageHandlerTest.TestNSurlSessionHandlerCookieContainerSetCookie() in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:line 233

    [FAIL] TestNSUrlSessionHandlerCookies :   Failed to get managed cookies
        Expected: True
        But was:  False
            at MonoTests.System.Net.Http.MessageHandlerTest.TestNSUrlSessionHandlerCookies () [0x000aa] in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/System.Net.Http/MessageHandlers.cs:144

Fixes https://github.com/xamarin/maccore/issues/2197.
2022-11-23 07:54:04 +01:00
Rolf Bjarne Kvinge d7f5544c18
[tests] Adjust ImageCaptioningTest to skip network-related failures in CI. (#16814)
Fixes:

    MonoTouchFixtures.MediaAccessibility.ImageCaptioningTest
    	[FAIL] GetCaption : Ignore this failure when network is down
    		   at MonoTouchFixtures.MediaAccessibility.ImageCaptioningTest.GetCaption() in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/MediaAccessibility/ImageCaptioningTest.cs:line 36

Ref: https://github.com/xamarin/maccore/issues/2088.
2022-11-21 20:55:49 +01:00
Rolf Bjarne Kvinge 0076cd9920
[autoformat] Add .NET tests. (#16811) 2022-11-21 09:45:49 +01:00
Rolf Bjarne Kvinge b3870ccb6d
[tests] Adjust MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback to ignore timeouts in CI. (#16816)
Fixes:

    MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback
    	[FAIL] TestCallback(True) :   timed out
      Expected: True
      But was:  False
    		   at MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback(Boolean stronglyTyped) in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/VideoToolbox/VTCompressionSessionTests.cs:line 171
    	[FAIL] TestCallback(False) :   timed out
      Expected: True
      But was:  False
    		   at MonoTouchFixtures.VideoToolbox.VTCompressionSessionTests.TestCallback(Boolean stronglyTyped) in /Users/builder/azdo/_work/3/s/xamarin-macios/tests/monotouch-test/VideoToolbox/VTCompressionSessionTests.cs:line 171
    		   at InvokeStub_VTCompressionSessionTests.TestCallback(Object, Object, IntPtr*)
2022-11-21 09:37:08 +01:00
Rolf Bjarne Kvinge 1c29665f72
[tests] Ignore SWCollaborationView in DelegateAndSourceTest. (#16777)
[SWCollaborationView setDelegate:] crashes when passed null.

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2022-11-18 08:02:42 +01:00
Rolf Bjarne Kvinge 97eee84442
[tests] Ignore PassLibraryTest.PassLibraryTest on bots if PKPassLibrary.GetPasses returns null. Fixes #xamarin/maccore@2598. (#16738)
PKPassLibrary.GetPasses randomly returns null for no apparent rhyme or reason
on our bots, so just ignore the test in that case.

Maybe if someone can reproduce locally one day we'll be able to investigate
and figure out what's happening.

Fixes https://github.com/xamarin/maccore/issues/2598.
2022-11-16 07:54:57 +01:00
Rolf Bjarne Kvinge 0140122668
[autoformat] Add the Security, SensorKit, Social, SpriteKit, StoreKit, SystemConfiguration, TVServices, VideoToolbox, Vision and WKWebKit frameworks. (#16763) 2022-11-16 07:38:18 +01:00
Manuel de la Pena 58a14e9231
[DevOps] Do not use ta vm for the pkgs upload due to its hdd size. (#16765)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2022-11-15 18:15:36 -05:00
Rolf Bjarne Kvinge 9af83cd712
[monotouch-test] Ignore certificate chain errors on bots. Fixes #xamarin/maccore@2626. (#16743)
Ignore certificate chain errors on bots in MessageHandlerTest.RejectSslCertificatesWithCustomValidationCallbackNSUrlSessionHandler.

Fixes https://github.com/xamarin/maccore/issues/2626.
2022-11-15 17:43:11 +01:00
Marius Ungureanu 4025f4e881
Fix ownership of CFSocketCreateRunLoopSource (#6089)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-11-15 15:55:21 +01:00
Rolf Bjarne Kvinge 09f84f988c
[autoformat] Autoformat after a PR race. (#16720)
There was a PR race:

1. I created a PR to autoformat monotouch-test code.
2. Another PR added incorrectly formatted code to monotouch-test.
3. The first PR was merged, everything was fine.
4. The second PR was merged (it was green) - but its code hadn't been
   autoformatted.
5. Now there's incorrectly formatted code in the repo, which will show up in
   every new PR.

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2022-11-14 08:43:39 +01:00
Marius Ungureanu 2bd6433fda
[perf] Add unmanaged constraint to some APIs to allow pinning, and not manual GCHandle code (#7561)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2022-11-11 08:58:46 +01:00
Rolf Bjarne Kvinge 6f45caa84d
[autoformat] Add monotouch-test (#16701) 2022-11-10 17:59:26 +01:00
Rolf Bjarne Kvinge ceaa0171da
Merge net7.0-xcode14.1 into main. (#16555)
This merges .NET 7 + Xcode 14.1 support into main.
2022-11-04 08:36:25 +01:00
Whitney Schmidt 3c65ab1756
Fix DateTime -> NSDate conversion (#7404)
Update conversions from `NSDate` to `DateTime` and `DateTime` to `NSDate` to use date components instead of `SecondsSinceReferenceDate`.

The number of seconds since reference date is inconsistent between `NSDate` and `DateTime`. See the associated bug - converting `DateTime` 1/1/1 to `NSDate` ends up giving you an `NSDate` a couple days off :(

Fixes https://github.com/xamarin/xamarin-macios/issues/6993.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-11-03 21:11:00 +01:00
Rolf Bjarne Kvinge cdc62aeae9 Merge remote-tracking branch 'origin/net7.0-xcode14.1' into main-net7.0-xcode14.1 2022-11-03 08:21:55 +01:00
Rolf Bjarne Kvinge 940e1d09e9 Merge xcode14.1 into net7.0-xcode14.1. 2022-11-02 19:03:30 +01:00
VS MobileTools Engineering Service 2 988bf9b4ba
[net7.0-xcode14.1] [tests] Handle managed exceptions in a networking callback. (#16535)
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


Backport of #16414

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-11-02 18:05:06 +01:00
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