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

798 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 99081123a7 [tests] Update a few TestCase attributes to be compatible with official NUnitLite. 2020-08-03 11:53:17 +02:00
Rolf Bjarne Kvinge b7db211e2d [tests] Use MonoTouch.Dialog from NuGet and Touch.Client instead of MonoTouch.NUnit.
* Touch.Client references the official NUnitLite package, which means we're using
  a non-forked version of NUnit.

* This makes it easier for our .NET 5 effort, since we won't have to port an ancient
  version of NUnitLite to .NET 5 (nor will we have to keep using it in our existing
  code, we can use more modern NUnit patterns).

* Reference MonoTouch.Dialog from the NuGet package. This also eases the .NET 5 effort,
  since we won't have to port MonoTouch.Dialog to .NET 5 (we'll probably still do it
  though at some point, but it doesn't have to be done right away), nor build it
  ourselves / ship it.
2020-08-03 11:53:17 +02:00
Rolf Bjarne Kvinge 7df8652579 Update .gitignore. 2020-08-03 11:53:17 +02:00
Whitney Schmidt c999bd5f57
[HealthKit][Xcode12] Update beta 1 (no b2, b3 changes) (#9249)
* HealthKit updates for Xcode12
2020-07-30 16:41:38 -04:00
Sebastien Pouliot e8de7afd4d
[mlcompute] New Xcode 12 framework. Up-to-date with beta 3 (#9208)
Framework not shipped for iOS/tvOS simulators - even if it's available
on macOS...

Feedback FB8132074 / https://github.com/xamarin/maccore/issues/2271
2020-07-28 20:55:28 -04:00
Whitney Schmidt 8fc88096ad
Revert "[Xcode12] HealthKit b1 update (#9152)" (#9217)
This reverts commit 74e8421f2c.
2020-07-28 14:04:31 -04:00
Whitney Schmidt 74e8421f2c
[Xcode12] HealthKit b1 update (#9152)
* HealthKit updates for beta 3
2020-07-28 14:03:56 -04:00
Alex Soto ac42dad8de [xcode11.6] Initial bump to support Xcode 11.6 Beta 1 2020-07-26 18:27:06 -04:00
Sebastien Pouliot 142ff3127b
[xcode12] Bump for beta 3 (#9162)
* Disable iOS 32bits simulator based tests
2020-07-24 08:52:33 -04:00
Rolf Bjarne Kvinge 4a2236f7e0 Merge remote-tracking branch 'origin/main' into xharness-a-directory-per-project 2020-07-23 15:37:06 +02:00
Rolf Bjarne Kvinge 4e8219b42e
[tests] The HttpWebRequest constructors are not publicly available in .NET 5, so use WebRequest.CreateHttp instead. (#9157) 2020-07-23 08:37:45 +02:00
Alex Soto 10059f1add [xcode11.6] Initial bump to support Xcode 11.6 Beta 1 2020-07-22 15:44:42 -04:00
Rolf Bjarne Kvinge cff47214ec [tests] Move bindings-test[-mac].csproj to their own directory. 2020-07-21 17:24:15 +02:00
Sebastien Pouliot 38fb1018a7
[naturallanguage] Update for Xcode 12 beta 2 (#9133) 2020-07-20 16:15:00 -04:00
Alex Soto 772e6518e6 [xcode11.6] Initial bump to support Xcode 11.6 Beta 1 2020-07-18 18:19:53 -04:00
Rolf Bjarne Kvinge 026a58b6c4
[monotouch-test] Second attempt at fixing the broken UrlRequestTest.Mutability_30744 test. (#9116)
This has been tested on:

* macOS 10.9, 10.10, 10.11, 10.12, 10.13, 10.14 and 10.15.
* iOS device:
	* iOS 8.2
	* iOS 9.3.5
	* iOS 11.4.1
	* iOS 13.6
2020-07-17 15:26:38 +02:00
Rolf Bjarne Kvinge 2995cd086a
[tests] Update tests to make native type vs normal type comparison explicit (#9097)
We've modified our NUnitLite to special-case the native types, so that they
can easily be compared with the standard types, but that doesn't work anymore
when switching to the official NUnit[Lite], so change all asserts to
explicitly convert whenever needed.
2020-07-17 08:48:09 +02:00
Rolf Bjarne Kvinge 839f586344
[monotouch-test] Fix broken UrlRequestTest.Mutability_30744 test. (#9096)
* [monotouch-test] Fix broken UrlRequestTest.Mutability_30744 test.

This test is supposed to assert that setting a header on an immutable
dictionary throws an exception.

The problem is that the tested code always throws an exception: either when
setting the header, or when asserting right after because no exception was
thrown, effectively always passing.

This showed up with current versions of NUnit[Lite], which keeps track of
assertion failures, and fails a test even if those assertion
failures/exceptions are caught in exception handlers.

So remove the whole exception verification logic, and just try to set the
value. We'll see if the test start failing somewhere (I've already tested both
on device and simulator, and no problems found so far).

* Remove a simulator condition.

It works on device for me (iPhone 7 with iOS 11.4.1)... maybe Apple changed
something?
2020-07-16 08:20:09 +02:00
Rolf Bjarne Kvinge e344698612
[tests] Use Assert.Throws instead of the ExpectedException attribute. (#9092)
* [tests] Use Assert.Throws instead of the ExpectedException attribute.

The ExpectedExceptionAttribute doesn't exist in newer versions of NUnit[Lite] anymore.

* [monotouch-test] Rework some CaptiveNetwork tests.

They need permissions, and entitlements, and something else I couldn't figure
out, so just assert they're returning null instead.
2020-07-16 08:19:33 +02:00
Rolf Bjarne Kvinge 3ac93d2330
[monotouch-test] Comparing uint to int for inequality doesn't work newer versions of NUnit[Lite]. (#9094)
So make sure we pass two values of the same type to Assert.AreNotEqual.
2020-07-16 08:19:01 +02:00
Manuel de la Pena 2b35db02ae
[Accessibility] Add new Framework from Xcode 12 beta 1. (#9086)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-07-15 16:29:15 -04:00
Rolf Bjarne Kvinge a59742a8ec
[monotouch-test] Use Is.EqualTo instead of Is.EquivalentTo for equal arrays. (#9093)
The latter is much, much, *much* slower when using a recent version of NUnit[Lite].

I have no idea exactly how much slower, because it was so slow that I got
tired of waiting, and stopped the tests.

So use EqualTo instead, since the arrays should be equal in the first place.
2020-07-15 18:07:57 +02:00
Rolf Bjarne Kvinge 93b5c223d6
[tests] Provide an ignore reason for Ignore attributes. (#9091)
Newer versions of NUnit[Lite] require this.
2020-07-15 14:50:54 +02:00
Rolf Bjarne Kvinge 6c4e357d3b
[monotouch-test] Fix debug naming. (#9084) 2020-07-15 09:05:34 +02:00
Manuel de la Pena 8bb60059e5
[ClockKit] Add support for Xcode 12 beta 1. (#9010)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2020-07-14 11:12:26 -04:00
Sebastien Pouliot 3eeb15ff72
[coregraphics] Update for Xcode 12 beta 2 (#9070) 2020-07-13 16:36:40 -04:00
Rolf Bjarne Kvinge 96327dee88
[monotouch-test] Use a normal thread instead of MulticastDelegate.BeginInvoke in AVAssetImageGeneratorTest. (#9067)
MulticastDelegate.BeginInvoke isn't supported in .NET.

Ref: https://github.com/dotnet/runtime/issues/16312
2020-07-13 15:07:05 +02:00
Sebastien Pouliot 8a57e7daf6
[coretext] Update for Xcode 12 beta 2 (#9062) 2020-07-13 08:41:14 -04:00
Alex Soto 802bd4e069
[UIKit] Update bindings to Xcode 12 Beta 2 (#8992) 2020-07-10 13:21:18 -04:00
Sebastien Pouliot 66ae40a442
[tests][monotouch-test] Re-enable some tests with beta 2 (#9042)
Some issues we detected in beta 1 are not present in beta 2
https://github.com/xamarin/xamarin-macios/issues/8943
2020-07-09 08:53:56 -04:00
Sebastien Pouliot e5100b74d3
[uniformtypeidentifiers] Update for Xcode 12 beta 2 (#9039)
Includes support for `UTType`-based `[Field]` in the generator as an
hundred (or so) of them were added. Unit test shows the field-based
properties are working as expected.
2020-07-09 08:50:57 -04:00
Sebastien Pouliot de306cd96d
Bump for Xcode 12 beta 2 (#9027)
* [arkit] Remove fields (from beta2) to fix introspection
* [tests][introspection] AVMutableMediaSelection is as bad as it's non mutable parent
* [tools] Update IsFrameworkBroken (remove CoreAudioTypes and MediaPlayer)
* [tests][monotouch-test] MKPinAnnotationView seems fixed in beta 2
* [tests][xtro] Update ARKit todo (with previous fix)
2020-07-08 09:26:24 -04:00
monojenkins 110f13759c
[tests] Skip a few networking tests on macOS 10.9. Fixes #xamarin/maccore@2221. (#9021)
Fixes https://github.com/xamarin/maccore/issues/2221.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-07-07 15:56:43 +02:00
monojenkins 069f4a4628
[tests] Skip a few networking tests on macOS 10.9. Fixes #xamarin/maccore@2221. (#9022)
Fixes https://github.com/xamarin/maccore/issues/2221.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-07-07 15:56:32 +02:00
Rolf Bjarne Kvinge 31f4a2e22a
[tests] Skip a few networking tests on macOS 10.9. Fixes #xamarin/maccore@2221. (#9012)
Fixes https://github.com/xamarin/maccore/issues/2221.
2020-07-06 13:26:09 +02:00
Sebastien Pouliot ae548380c4
[xcode12][security] Update for beta 1 (#8969) 2020-06-29 15:02:16 -04:00
Sebastien Pouliot f427b5e91d
[xcode12] Bump for beta 1 (#8935)
Known issues https://github.com/xamarin/xamarin-macios/issues/8943
2020-06-26 14:02:44 -04:00
monojenkins bf4b5f4db8
[xcode12] [ImageIO] Update bindings for Xcode11 (#8942) 2020-06-25 15:28:29 -04:00
monojenkins 5e75a06b32
[runtime] Remove memcpy usage from Runtime.CloneMemory (#8925)
instead use `Buffer.MemoryCopy`.

Currently only used from `CGDataProvider`. Added unit tests for the
public/indirect, usage of the API (we had none).

Co-authored-by: Sebastien Pouliot <sebastien.pouliot@microsoft.com>
2020-06-23 08:52:32 +02:00
Rolf Bjarne Kvinge 6ad1cba473
[monotouch-test] Lower indirect command buffer availability. (#8886)
Apple's charts say indirect command buffers are available with MTLGpuFamilyCommon2.

That's not quite so, devices that support MTLGpuFamilyCommon2 may crash when
MTLDevice.CreateIndirectCommandBuffer is called.

So make the conditions for calling CreateIndirectCommandBuffer an intersection
of the previous condition for macOS (MTLFeatureSet.macOS_GPUFamily2_v1) + the
new condition (MTLGpuFamily.Common2) + Xcode 11+ (just to make things
simpler).

I've tested this on all our macOS bots, and it worked on all of them.

If it fails anywhere else (iOS devices), the next patch will remove the entire
test.
2020-06-18 17:55:20 +02:00
Sebastien Pouliot ce45a0267b
[runtime] Remove memcpy usage from Runtime.CloneMemory (#8880)
instead use `Buffer.MemoryCopy`.

Currently only used from `CGDataProvider`. Added unit tests for the
public/indirect, usage of the API (we had none).
2020-06-18 08:01:16 -04:00
Rolf Bjarne Kvinge 1d269a12d0
[monotouch-test] Check for Metal compatibility for all platforms before creating indirect command buffers. Fixes #xamarin/maccore@2235. (#8863)
This fixes an iOS assertion (crash) when running on iPhone 6 with iOS 12+:

    2020-06-15 13:52:35.138 monotouchtest[6887:5713672] failed assertion 0 at line 54 in NopIndirectCommandBuffer

    =================================================================
    	Native Crash Reporting
    =================================================================
    Got a abrt while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.
    =================================================================

    =================================================================
    	Native stacktrace:
    =================================================================
    	0x1060b23fc - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info
    	0x1060a8674 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonosgen-2.0.dylib : mono_handle_native_crash
    	0x1060b1948 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonosgen-2.0.dylib : sigabrt_signal_handler
    	0x20049e9fc - /usr/lib/system/libsystem_platform.dylib : <redacted>
    	0x2004a4094 - /usr/lib/system/libsystem_pthread.dylib : <redacted>
    	0x200383ea8 - /usr/lib/system/libsystem_c.dylib : abort
    	0x2029c5dac - /System/Library/Frameworks/Metal.framework/Metal : MTLGetWarningMode
    	0x2210cff78 - /System/Library/Extensions/AGXMetalA8.bundle/AGXMetalA8 :
    	0x20299fb80 - /System/Library/Frameworks/Metal.framework/Metal : <redacted>
    	0x103143c58 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libXamarin.iOS.dll.dylib : wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_IntPtr_nuint_UInt64_intptr_intptr_intptr_System_nuint_ulong
    	0x102f4cbdc - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libXamarin.iOS.dll.dylib : Metal_MTLDevice_Extensions_CreateIndirectCommandBuffer_Metal_IMTLDevice_Metal_MTLIndirectCommandBufferDescriptor_System_nuint_Metal_MTLResourceOptions
    	0x101a8bd58 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonotouchtest.exe.dylib : MonoTouchFixtures_Metal_MTLDeviceTests_ReturnReleaseTest
    	[...]

Fixes https://github.com/xamarin/maccore/issues/2235.
2020-06-18 08:59:35 +02:00
Rolf Bjarne Kvinge 952037b7a3
[tests] Remove Classic code from all tests. (#8707) 2020-05-29 16:43:06 +02:00
Rolf Bjarne Kvinge 2b2f1d08dc
[tests] Remove Classic code from all tests. (#8702) 2020-05-28 16:35:09 +02:00
Sebastien Pouliot e819d09658
[corefoundation] Safer NativeObject (#8667)
Do not allow calling `CFRetain` or `CFRelease` on a null handle as this
will crash the process, instead use `GetCheckedHandle` so a managed (and
catchable) `ObjectDisposedException` can be thrown.

Make `GetCheckedHandle` public so subclasses (outside the platform
assembly) can use it - it's already recommended in some `[Obsolete]`
attributes (but was not made available).

Move the `ObjectDisposedException` thrower into a new `ThrowHelper`
class. This will allow sharing it (to be re-used in future PR).

Add unit tests for `NativeObject`.
2020-05-26 12:09:26 -04:00
Alex Soto bb5a3d353a
[Tests] Use safe listed password by our Credentials Scanner tool (#8580) (#8652) 2020-05-21 20:47:43 -04:00
Rolf Bjarne Kvinge 944ec6dc2f
[introspection] Remove Classic code. (#8620) 2020-05-20 09:29:21 +02:00
Rolf Bjarne Kvinge 16ab321951
[tests] Remove some Classic code. (#8592) 2020-05-14 09:36:21 +02:00
Alex Soto 06871ab24f
[Tests] Use safe listed password by our Credentials Scanner tool (#8580) 2020-05-12 14:02:16 -04:00
monojenkins 4d7dfaafd1
[d16-7] [Foundation] Do not get in an infinite loop with empty creds. (#8548)
As described in the issue, when the credentials for the base auth are set
to be empty the request reaches a timeout.

The inner issue is that when we have empty credentials the query that
is performed to the credentials db of the system throws an exception.
This exception is not raised to our code, but simply prints out in stderr.

When this situation occurs we get in an infinite loop in which we keep
sending the same credentials, we get another challenge, but the OS does
not do the right thing, we believe that we have to provide the creds
again (which are the same) and we get another challenge.. this goes on
an on until we reach the timeout.

Fortunately we know the number of failed challenges and the failure
response. With this information we can deduce if we already sent the
credentials, and if we did, do not set them again. In this case, the OS
sees no credentials in out delegate, uses the default handler and
correctly returns a 401.

fixes: https://github.com/xamarin/xamarin-macios/issues/8342
Fixes: https://github.com/xamarin/xamarin-macios/issues/8344

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2020-05-07 22:21:36 -04:00
Manuel de la Pena 8d08ad2ce3
[Foundation] Do not get in an infinite loop with empty creds. (#8543)
* [Foundation] Do not get in an infinite loop with empty creds.

As decribed in the issue, when the credentials for the base auth are set
to be empty the request reaches a timeout.

The inner issue is that when we have empty credentials the query that
is performed to the credentials db of the system throws an exception.
This exception is not raised to our code, but simply prints out in stderr.

When this situation occurs we get in an infinite loop in which we keep
sending the same credentials, we get another challenge, but the OS does
not do the right thing, we believe that we have to provide the creds
again (which are the same) and we get another challenge.. this goes on
an on until we reach the timeout.

Fortunately we know the number of failed challenges and the failure
response. With this information we can deduce if we already sent the
credentials, and if we did, do not set them again. In this case, the OS
sees no credentials in out delegate, uses the default handler and
correctly returns a 401.

fixes: https://github.com/xamarin/xamarin-macios/issues/8342
fixes: https://github.com/xamarin/xamarin-macios/issues/8344
2020-05-07 18:25:26 -04:00
Whitney Schmidt ecf295f4db
[ImageIO] Update bindings for Xcode11 (#8376)
* initial imagio bindings + test project

* remove sample files, update xtro

* clean up

* add new line at eof

* even more cleanup...

* update based on PR feedback

* reformat according to coding standards

* fix all feedback except monotouch tests

* add monotouch-test files

* fix test feedback

* fix PR feedback

* fix timeout in tests, add asserts for status, update return value for APi to CGImageAnimationStatus enum

* fix == asserts

* respond to more pr feedback

* add StrongDictionary, remove Partial

* NSNumber -> nuint for NSUInteger

* add smaller gif

* remove hack.gif from project

* add gif to csproj
2020-04-28 17:02:36 -04:00
Rolf Bjarne Kvinge 9dd1231e50
[Foundation] Add an overload to NSString.FromHandle that takes an 'owns' parameter. (#8417)
This matches our API elsewhere.
2020-04-20 09:48:29 +02:00
Sebastien Pouliot 15938de198
[generator] Add C#8 nullability into generated code (#7570) (#8333)
Goals
* Reflect Apple nullability annotations in our bindings using C#8
* No warnings when building bindings

Non-Goals
* Update (add or fix) `[NullAllowed]` to match Apple headers (next phase)
* Make the generator or internal code fully nullable aware (`nowarn` is used)

Notes
* Apple's own annotations are not 100% accurate :(
* Where known issue exists we have _fixed_ our attributes to match reality :)
* We also do additional null-checks internally that might seems not required (better safe than sorry).
2020-04-10 12:38:14 -04:00
Sebastien Pouliot a5ac0ea102
[generator] Add C#8 nullability into generated code (#7570)
Goals
* Reflect Apple nullability annotations in our bindings using C#8
* No warnings when building bindings

Non-Goals
* Update (add or fix) `[NullAllowed]` to match Apple headers (next phase)
* Make the generator or internal code fully nullable aware (`nowarn` is used)

Notes
* Apple's own annotations are not 100% accurate :(
* Where known issue exists we have _fixed_ our attributes to match reality :)
* We also do additional null-checks internally that might seems not required (better safe than sorry).
2020-04-09 09:29:28 -04:00
Alex Soto 3ff3e07ebe Merge remote-tracking branch 'xamarin/d16-5-xcode11.4' 2020-03-26 19:59:14 -04:00
Sebastien Pouliot e9ff1f854d
It seems 'initWithRequest:cachedResponse:client:' is not called on 10.9 (#8173) 2020-03-23 20:55:51 -04:00
Sebastien Pouliot 9f1ecfa85f
[tests][monotouch-test] Update UrlProtocolTest (#8168)
The _nice_ thing about `NSURLProtocol` is that it does not force the use
of the network - but we inflicted this upon us on tests.

So this updates the test to avoid the network, which should make it
more reliable and not so much influenced by the URL used or the OS
versions where it's executed.

This does not cover as much callback as before. However this it does
test that the NSUrlProtocol is registered correctly (what we care) and
the rest is largely only related the the OS (which is not the target
of our unit tests).

Hopefully fix https://github.com/xamarin/maccore/issues/1956
2020-03-20 21:52:43 -04:00
Alex Soto f5b3a6f1c4
Merge remote-tracking branch 'xamarin/xcode11.4' into d16-5-xcode11.4 2020-03-08 13:16:04 -04:00
Sebastien Pouliot 0129618de8
[mtouch] Add `force-rejected-types-removal` optimization (#8009) (#8042)
This optimization can be enabled when it's not possible to use the
managed linker (e.g. **Don't link**) or when the managed linker cannot
remove references to deprecated types that would cause an application
to be rejected by Apple.

References to the existing types will be renamed, e.g. `UIWebView` to
`DeprecatedWebView`, in every assemblies.

The type definition is also renamed (for validity) and all custom
attributes on the types and their members will be removed.
Code inside the members will be replaced with a
`throw new NotSupportedException ();`.

The msbuild test app `MyReleaseBuild` has been updated to test that the
optimization is working as expected (device builds are slow so reusing
this test has little impact in test time).

Basically the test ensure that `UIWebView` is used and cannot be removed
by the compiler (optimization) or the managed linker (since it's
referenced). Since the optimization is enabled then we can `grep` then
final `.app` directory to ensure there's no mention of `UIWebView` inside
any of the files that would be submitted.

The application can be run, by itself, and will turn green if OK, red if
`DeprecatedWebView` can't be found (skeleton replacement for `UIWebView`)
or orange if a `NotSupportedException` is thrown.

Finally introspection tests have been updated to skip over the deprecated
(and renamed) types. It should not be an issue right now, since this
optimization is not enabled by default, but it made testing easier.
2020-03-04 21:21:41 -05:00
Alex Soto ac8fb30f5d
[xcode11.4] Initial commit for Xcode 11.4 Beta 3 support (#8034)
* [xcode11.4] Initial commit for Xcode 11.4 Beta 3 support

* [monotouch-test] Adjust `TextFieldTest.EmptySelection` to 13.4 changes
2020-03-04 11:24:02 -05:00
Sebastien Pouliot 004b50f590
[tests][monotouch-test] Tweak UIWebView tests to work in every case (#8033)
so if we optimize (to remove references) the tests will be ignored.
Doing this based on define was wrong since we have different (and more)
configurations executed on devices,
2020-03-03 17:07:10 -05:00
Sebastien Pouliot c2ca09dc69
[corefoundation] Fix TypeInitializationException in OSLog (#7962)
`Default` property was using a nil-handle which is incorrect since
* we don't allow that (this is generally a bad sign)
* it does not map to `OS_LOG_DEFAULT`

Since `Default` was assigned in the type (static) constructor then
the whole type became unusable :(

Header `log.h` shows that the right definition requires us to load a
field and use it.

```
define OS_LOG_DEFAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_default)
```

While `NULL` can actually be used for disabled (not exposed) by this
contradicting (nullability-wise) macro

```
define OS_LOG_DISABLED ((os_log_t _Nonnull)NULL)
```

Also adds unit tests. A more general tests for `.cctor` will be added
to introspection tests in a separate PR.

Fixes https://github.com/xamarin/xamarin-macios/issues/7959
2020-03-03 16:38:43 -05:00
Rolf Bjarne Kvinge eeff89f895
[monotouch-test] Improve NWBrowserTest.TestStateChangesHandler to not assert on background threads. (#8022)
Asserts will throw an exception when the assert fails, which will crash the
app if it happens on a background thread. So marshal any exceptions to the
main thread.

Solves this (by turning it into a normal NUnit assert failure):

    Unhandled Exception:
    NUnit.Framework.AssertionException:   newResult first run
      Expected: null
      But was:  <Network.NWBrowseResult>
    2020-02-28 19:47:41.214499-0500 monotouchtest[46412:20292304] Unhandled managed exception:   newResult first run
      Expected: null
      But was:  <Network.NWBrowseResult>
     (NUnit.Framework.AssertionException)

    =================================================================
    	Native Crash Reporting
    =================================================================
    Got a SIGABRT while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.
    =================================================================

    =================================================================
    	Native stacktrace:
    =================================================================
    	0x107c028c5 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_dump_native_crash_info
    	0x107bf6f85 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_handle_native_crash
    	0x107c01f1b - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : sigabrt_signal_handler
    	0x7fff40be642d - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_platform.dylib : _sigtramp
    	0x7ff295501cb0 - Unknown
    	0x7fff40ad6a1c - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_c.dylib : abort
    	0x107e3d33f - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : xamarin_unhandled_exception_handler.cold.1
    	0x107e30c09 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : xamarin_unhandled_exception_handler
    	0x107cb7525 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_invoke_unhandled_exception_hook
    	0x107bf69ea - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_handle_exception_internal
    	0x107bf4ed9 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_handle_exception
    	0x107b76019 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_amd64_throw_exception
    	0x1085c95b0 - Unknown
    	0x107e30a25 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : xamarin_process_managed_exception
    	0x107bf671e - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_handle_exception_internal
    	0x107bf4ed9 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_handle_exception
    	0x107b76019 - /Users/builder/Library/Developer/CoreSimulator/Devices/E7C088E5-575C-42B7-ADFB-8144438C78A5/data/Containers/Bundle/Application/E3172E17-F6D2-4BC0-8770-379689518F78/monotouchtest.app/monotouchtest : mono_amd64_throw_exception
    	0x1085c95b0 - Unknown
    	0x11aed4ceb - Unknown
    	0x7fff3fa7ecfe - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libnetwork.dylib : nw_parallel_array_apply_with_range
    	0x7fff3f975077 - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libnetwork.dylib : __nw_browser_notify_browse_result_changes_locked_block_invoke.100
    	0x7fff409c9848 - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_call_block_and_release
    	0x7fff409ca7b9 - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_client_callout
    	0x7fff409d9d69 - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_root_queue_drain
    	0x7fff409da39b - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_worker_thread2
    	0x7fff40bee6b6 - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
    	0x7fff40bed827 - /Applications/Xcode113.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_pthread.dylib : start_wqthread
2020-03-02 17:27:27 +01:00
Sebastien Pouliot 54f2dae935
[mtouch] Add `force-rejected-types-removal` optimization (#8009)
This optimization can be enabled when it's not possible to use the
managed linker (e.g. **Don't link**) or when the managed linker cannot
remove references to deprecated types that would cause an application
to be rejected by Apple.

References to the existing types will be renamed, e.g. `UIWebView` to
`DeprecatedWebView`, in every assemblies.

The type definition is also renamed (for validity) and all custom
attributes on the types and their members will be removed.
Code inside the members will be replaced with a
`throw new NotSupportedException ();`.

The msbuild test app `MyReleaseBuild` has been updated to test that the
optimization is working as expected (device builds are slow so reusing
this test has little impact in test time).

Basically the test ensure that `UIWebView` is used and cannot be removed
by the compiler (optimization) or the managed linker (since it's
referenced). Since the optimization is enabled then we can `grep` then
final `.app` directory to ensure there's no mention of `UIWebView` inside
any of the files that would be submitted.

The application can be run, by itself, and will turn green if OK, red if
`DeprecatedWebView` can't be found (skeleton replacement for `UIWebView`)
or orange if a `NotSupportedException` is thrown.

Finally introspection tests have been updated to skip over the deprecated
(and renamed) types. It should not be an issue right now, since this
optimization is not enabled by default, but it made testing easier.
2020-03-02 09:20:29 -05:00
Sebastien Pouliot 9a8855117b
[corefoundation] Fix TypeInitializationException in OSLog (#7962)
`Default` property was using a nil-handle which is incorrect since
* we don't allow that (this is generally a bad sign)
* it does not map to `OS_LOG_DEFAULT`

Since `Default` was assigned in the type (static) constructor then
the whole type became unusable :(

Header `log.h` shows that the right definition requires us to load a
field and use it.

```
define OS_LOG_DEFAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_default)
```

While `NULL` can actually be used for disabled (not exposed) by this
contradicting (nullability-wise) macro

```
define OS_LOG_DISABLED ((os_log_t _Nonnull)NULL)
```

Also adds unit tests. A more general tests for `.cctor` will be added
to introspection tests in a separate PR.

Fixes https://github.com/xamarin/xamarin-macios/issues/7959
2020-02-25 08:55:37 -05:00
Manuel de la Pena 9d11429de3
[Tests] Fix AudioQueueTest.Properties test. (#7930)
From the documentation of
https://developer.apple.com/documentation/audiotoolbox/audio_converter_services?language=objc
I think we can deduce that we are hitting a 'hwiu' which is Hardware in
use. Could make sense if we did not clean up properly. Switching to use
the software implementation should fix the flacky test.

fixes: https://github.com/xamarin/maccore/issues/1614
2020-02-18 09:09:47 -05:00
Marius Ungureanu f841b1eb51
Use sizeof instead of Marshal.Sizeof (#7558) 2020-02-10 14:41:31 -05:00
monojenkins 0c4af7daa1 [d16-5] [registrar] Fixes NSString trampoline code generation in static registrar (#7738)
* [registrar] Fixes NSString trampoline code generation in static registrar

Fixes xamarin/xamarin-macios#7733

This was introduced as a side effect of commit 8425129, we
used to generate `id foo` instead of the full block signature
in the trampoline code used by the static registrar, this is
the reason we never caught this condition before.

Added registrar test.

* Move tests to the appropiate test file

Co-authored-by: Alex Soto <alex@alexsoto.me>
2020-01-22 16:27:38 -05:00
Alex Soto 621fc8089a
[registrar] Fixes NSString trampoline code generation in static registrar (#7735)
* [registrar] Fixes NSString trampoline code generation in static registrar

Fixes xamarin/xamarin-macios#7733

This was introduced as a side effect of commit 8425129, we
used to generate `id foo` instead of the full block signature
in the trampoline code used by the static registrar, this is
the reason we never caught this condition before.

Added registrar test.

* Move tests to the appropiate test file
2020-01-22 15:03:18 -05:00
Manuel de la Pena 8dd672801c
[CoreFoundation] Add some helper methods to make DispatchData easier to use. (#7690)
Add the following methods:

1. FromReadOnlySpan - Allows to create DispatchData from Spans.
2. ToArray - Return a managed copy of the data.

Fixes: https://github.com/xamarin/xamarin-macios/issues/7446
2020-01-09 22:47:21 -05:00
Chris Hamons 7950155faf [mmp] Set ThrowManagedException in debug apps if unset (#7667)
- https://github.com/xamarin/xamarin-macios/issues/5738
- There are a number of managed exceptions Apple can throw at you during
debugging, such as expanding a NSColor in the wrong colorspace
- Throwing a managed exception is a nicer debugging experience, and
during debug we don't care about any performance penality.
2020-01-08 08:00:41 -05:00
Manuel de la Pena ac8e52c2e2
[Foundation] Add support to ignore the cookies in the NSUrlSessionHandler. (#7677)
This change allows to ignore the use of cookies and cookie containers in
the NSUrlSessionHandler. There are two different cookie containers to
consider:

1. The native NSHttoCookieStorage.
2. The managed CookieContainer.

If the native one is set to null, the native code will not use a cookie
storage, which is used as a flag to ignore the managed one.

There is an interesting situation, we allow different types of sessions.
From the cookie storage point of view, Default and Background sessions
are the same, but Ephemeral is not, since we only want to store in ram
the cookies and do not share them.

This supposes a problem because Apple does not provide any API that will
allow to determine the session type use in the configuration. The
workaround has been to hide the direct native call for the configuration
and add an enum value that can later be accessed in the
NSUrlSessionHandler. Of course things cannot be that easy. When a
session is created with the configuration, it creates a copy, and the
internal session configuration does not longer have the flag, therefore,
we need to store the session type in the handler.

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

Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
2020-01-07 18:37:17 -05:00
Manuel de la Pena f9e3cab385
[Foundation] Add some missing C bindings in NSFileManager. (#7664)
Add the bindings since Enviroment does not provide all/same information.

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


Co-authored-by: Pramit Mallick <prmallic@microsoft.com>
2020-01-02 14:05:56 -05:00
Manuel de la Pena fffa889f22
[Foundation] Add CookieContainer support in NSUrlSessionHandler. (#7654)
There are two important things to look at this:

1. That we do set the cookies that are present in the CookieContainer in
the request. That is, we need to set Cookie headers for all of them.
2. That if we receive a Set-Cookie from the server, the CookieContainer
gets correctly updated else we will have issues since we do not respect
the data sent from the server side.

Tests show both that we are setting the Cookie header and that we honour
the Set-Cookie header.

Fixes: https://github.com/xamarin/xamarin-macios/issues/5665
2019-12-27 15:36:47 -05:00
Alex Soto f1f867af03
Merge branch 'd16-5' into d16-5-xcode11.3 2019-12-18 12:01:21 -05:00
Vincent Dondain fd3f86d912 Bump to mono:2019-10 (#7192) (#7547)
* Fixed
`/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/builds/mono-ios-sdk-destdir/ios-sources/external/linker/src/linker/Linker.Steps/OutputStep.cs(110,15): error CS0246: The type or namespace name ‘OutputException’ could not be found (are you missing a using directive or an assembly reference?) [/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mmp/mmp.csproj]`
* Changed the name of the method that is used from linker. Because of this commit 6be26771b9
* Added `OutputException.cs` file on `mtouch.csproj`.
* Removing enter_gc_safe and exit_gc_safe because now it's already gc_safe in this part of code, after a mono change.
* Added known exceptions to LLVM exception list.
* Needs `ifdef` because of this https://github.com/mono/mono/pull/17260.
* Bump MIN_MONO_VERSION to 6.8.0.41 and point MIN_MONO_URL to the PR.
* Add ENABLE_IOS=1 and ENABLE_MAC=1.
* Added switch to disable packaged mono build
* [Tests] Ignore tests that fail on 32b.
    Ignore the test on 32b, and filled issue: https://github.com/mono/mono/issues/17752
* [Tests] Ignore a couple of tests causing OOM.
    Hopefully fixes https://github.com/xamarin/maccore/issues/1659 for good.
* Ignore `MM0135` test on Catalina+ because it needs Xcode 9.4.
* [monotouch-test] Add null checks for teardown when test didn't run because of a too early OS version.
* [CFNetwork]: Http 2.0 requires OS X 10.11 or later.
    Check whether `_HTTPVersion2_0` is available and fallback to HTTP 1.1 otherwise.

* #7346
* This bumps Mono to use https://github.com/mono/mono/pull/17645 (which is the 2019-10 backport
of https://github.com/mono/mono/pull/17628).
* The big user-visible change is in regards to certificate validation, everything below are just
some minor adjustments to tests.

CoreFX uses a completely new `HttpClientHandler` implementation called `SocketsHttpHandler`,
which you can find at https://github.com/dotnet/corefx/tree/release/3.0/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler.

Since this is not based on the web stack anymore, it does not use any of the related APIs such
as `ServicePointManager` or `WebException`.

There is a new API called `HttpClientHandler.ServerCertificateCustomValidationCallback`.
- https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclienthandler.servercertificatecustomvalidationcallback?view=netframework-4.8
- c1778515a3/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.Unix.cs (L154)
- c1778515a3/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.Windows.cs (L383)

The `ServicePointManager.ServerCertificateValidationCallback` is no longer invoked and on
certificate validation failure, `AuthenticationException` (from `System.Security.Authentication`)
is thrown instead of `WebException`.

At the moment, the `NSUrlSessionHandler` still uses it's own validation callback and also still
throws `WebException` on failure; we should probably look into making this consistent with the
other handlers.

* `HttpContent.SerializeToStreamAsync()` is now `protected` (changed from `protected internal`).
  - src/Foundation/NSUrlSessionHandler.cs: changed overload accordingly.
  - src/System.Net.Http/CFContentStream.cs: likewise.

* `HttpHeaders.GetKnownHeaderKind()` is an internal Mono API.
   There is a new internal API called `System.Net.Http.PlatformHelper.IsContentHeader(key)`
   which exists in both the old as well as the new implementation.
   The correct way of doing it with the CoreFX handler is
   `HeaderDescriptor.TryGet (key, out var descriptor) && descriptor.HeaderType == HttpHeaderType.Content`

* `HttpClientHandler.MaxRequestContentBufferSize` is now longer supported, you can set it to
  any non-negative value, the getter will always return 0.
  See c1778515a3/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.Core.cs (L18).
  - tests/linker/ios/link sdk/HttpClientHandlerTest.cs: removed assertion from test.

* `HttpMessageInvoker.handler` is a `protected private` field - in the CoreFX handler, it is
  called `_handler` and `private`.  This is accessed via reflection by some of the tests, which are
  now using the new name.
  - tests/mmptest/src/MMPTest.cs: here
  - tests/mtouch/MTouch.cs: here

* tests/monotouch-test/System.Net.Http/MessageHandlers.cs:
  Adjust `RejectSslCertificatesServicePointManager` to reflect the certificate validation
  changes described above.
  - FIXME: There was an `Assert.Ignore()` related to `NSUrlSessionHandler` and macOS 10.10;
    I removed that to reenable the test because the description linked to an old issue in
    the private repo that was referenced by several "Merged" PR's, so it looked to me that
    this might have already been fixed - and I also didn't see why it would fail there.
2019-12-18 11:40:47 -05:00
Alex Soto 9ac17bdbcf
Merge remote-tracking branch 'xamarin/xcode11.3' into master-xcode11.3 2019-12-17 19:25:11 -05:00
Alex Soto 01c1d04877
Merge remote-tracking branch 'xamarin/xcode11.3' into d16-5 2019-12-17 18:56:12 -05:00
monojenkins a6c714fa84 [xcode11.3] [monotouch-test] Simplify NetworkReachabilityTest.CtorIPAddressPair test. (#7613)
* [monotouch-test] Improve reachability test.

Tested on:

* All macOS versions we support (10.9 -> 10.15).
* tvOS device: 13.2
* iOS devices: 8.2, 9.3.5, 10.3.3, 11.4.1, 12.4.1, 13.3
* iOS simulators: 10.3, 11.0, 12.0, 13.2.
* tvOS simulators: 10.2, 13.2

* Yay Apple!

* Give up.

* Revert unneeded change.
2019-12-17 16:07:22 -05:00
Manuel de la Pena cfd8c7a20b
[Tests] Improve error when we have network issues in ImageCaptioningTest.GetCaption (#7591)
The error does give a description letting us know that the url was
invalid, that is, we could not reach it.

Fixes: https://github.com/xamarin/maccore/issues/2088
2019-12-16 22:07:22 -05:00
Sebastien Pouliot 2c8cc9bd43
[test][monotouch-test] Fix crash on old iOS8 32bits devices (#7595)
```
20:11:28.9562500 2019-12-12 20:11:48.058 monotouchtest[873:239608] Xamarin.iOS: Received unhandled ObjectiveC exception: NSInvalidArgumentException *** -[AVCaptureMetadataOutput setMetadataObjectTypes:] - unsupported type found.  Use -availableMetadataObjectTypes.
20:11:29.0542980 2019-12-12 20:11:48.154 monotouchtest[873:239608]
20:11:29.0543360 Unhandled Exception:
20:11:29.0543440 0   libmonosgen-2.0.dylib               0x04d53c45 setup_stack_trace + 188
20:11:29.0543500 1   libmonosgen-2.0.dylib               0x04d51df9 mono_handle_exception_internal + 2120
20:11:29.0543560 2   libmonosgen-2.0.dylib               0x04d515ad mono_handle_exception + 50
20:11:29.0543620 3   libmonosgen-2.0.dylib               0x04d47de9 mono_arm_throw_exception + 132
20:11:29.0543690 4   libmscorlib.dll.dylib               0x01570648 throw_exception + 72
...
```

Fixes https://github.com/xamarin/maccore/issues/2091
2019-12-16 08:57:57 -05:00
monojenkins 71d009c1c8 [d16-5] [monotouch-test] Simplify NetworkReachabilityTest.CtorIPAddressPair test. (#7579)
Don't assert anything about the flags, it's a never ending game to keep up with OS versions.

Fixes https://github.com/xamarin/maccore/issues/2047 for good.

Backport of #7546.
2019-12-12 17:56:42 +01:00
Rolf Bjarne Kvinge a6d2ebddfd
[monotouch-test] Simplify NetworkReachabilityTest.CtorIPAddressPair test. (#7546)
* [monotouch-test] Improve reachability test.

Give up.

Different versions of OSes report different flags. Trying to
figure out which OS versions have which flags set turned out to
be a never-ending game of whack-a-mole, so just don't assert
that any specific flags are set.
2019-12-12 07:57:23 +01:00
Rolf Bjarne Kvinge e19fd5ba00
[monotouch-test] Improve MessageHandlerTest.TestNSUrlSessionHandlerCookies. (#7542)
1. Instead of fetching the managed response's cookies twice, and then
   comparing them to themselves, fetch the managed response's cookies once and
   then the native response's cookies once, and compare that. This way the
   test does what it's actually supposed to do!
2. Don't pass if we fail to get the managed response's cookies.
3. Improve assertions to verify the actual cookie content as well.
4. Improve diagnostics if an exception was thrown by checking for the
   exception first instead of failing due to something else being different
   (since the underlying cause of the difference is the exception, that's what
   will have the most information about the failure).
5. Use httpbin.org instead of microsoft.com, since microsoft.com does UA
   sniffing and returns different results between the http handlers :/
2019-12-04 23:26:31 +01:00
Jo Shields 5d4ada34c7 Bump to mono:2019-10 (#7192)
## Miscellaneous fixes

* Fixed
`/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/builds/mono-ios-sdk-destdir/ios-sources/external/linker/src/linker/Linker.Steps/OutputStep.cs(110,15): error CS0246: The type or namespace name ‘OutputException’ could not be found (are you missing a using directive or an assembly reference?) [/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mmp/mmp.csproj]`
* Changed the name of the method that is used from linker. Because of this commit 6be26771b9
* Added `OutputException.cs` file on `mtouch.csproj`.
* Removing enter_gc_safe and exit_gc_safe because now it's already gc_safe in this part of code, after a mono change.
* Added known exceptions to LLVM exception list.
* Needs `ifdef` because of this https://github.com/mono/mono/pull/17260.
* Bump MIN_MONO_VERSION to 6.8.0.41 and point MIN_MONO_URL to the PR.
* Add ENABLE_IOS=1 and ENABLE_MAC=1.
* Added switch to disable packaged mono build
* [Tests] Ignore tests that fail on 32b.
    Ignore the test on 32b, and filled issue: https://github.com/mono/mono/issues/17752
* [Tests] Ignore a couple of tests causing OOM.
    Hopefully fixes https://github.com/xamarin/maccore/issues/1659 for good.
* Ignore `MM0135` test on Catalina+ because it needs Xcode 9.4.
* [monotouch-test] Add null checks for teardown when test didn't run because of a too early OS version.
* [CFNetwork]: Http 2.0 requires OS X 10.11 or later.
    Check whether `_HTTPVersion2_0` is available and fallback to HTTP 1.1 otherwise.

## Bring HttpClient from CoreFX

* #7346 
* This bumps Mono to use https://github.com/mono/mono/pull/17645 (which is the 2019-10 backport
of https://github.com/mono/mono/pull/17628).
* The big user-visible change is in regards to certificate validation, everything below are just
some minor adjustments to tests.

### SocketsHttpHandler

CoreFX uses a completely new `HttpClientHandler` implementation called `SocketsHttpHandler`,
which you can find at https://github.com/dotnet/corefx/tree/release/3.0/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler.

Since this is not based on the web stack anymore, it does not use any of the related APIs such
as `ServicePointManager` or `WebException`.

### Certificate Validation Changes

There is a new API called `HttpClientHandler.ServerCertificateCustomValidationCallback`.
- https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclienthandler.servercertificatecustomvalidationcallback?view=netframework-4.8
- c1778515a3/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.Unix.cs (L154)
- c1778515a3/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.Windows.cs (L383)

The `ServicePointManager.ServerCertificateValidationCallback` is no longer invoked and on
certificate validation failure, `AuthenticationException` (from `System.Security.Authentication`)
is thrown instead of `WebException`.

At the moment, the `NSUrlSessionHandler` still uses it's own validation callback and also still
throws `WebException` on failure; we should probably look into making this consistent with the
other handlers.

### Minor adjustments related to internal Mono APIs

* `HttpContent.SerializeToStreamAsync()` is now `protected` (changed from `protected internal`).
  - src/Foundation/NSUrlSessionHandler.cs: changed overload accordingly.
  - src/System.Net.Http/CFContentStream.cs: likewise.

* `HttpHeaders.GetKnownHeaderKind()` is an internal Mono API.
   There is a new internal API called `System.Net.Http.PlatformHelper.IsContentHeader(key)`
   which exists in both the old as well as the new implementation.
   The correct way of doing it with the CoreFX handler is
   `HeaderDescriptor.TryGet (key, out var descriptor) && descriptor.HeaderType == HttpHeaderType.Content`

### Minor adjustments to tests.

* `HttpClientHandler.MaxRequestContentBufferSize` is now longer supported, you can set it to
  any non-negative value, the getter will always return 0.
  See c1778515a3/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.Core.cs (L18).
  - tests/linker/ios/link sdk/HttpClientHandlerTest.cs: removed assertion from test.

* `HttpMessageInvoker.handler` is a `protected private` field - in the CoreFX handler, it is
  called `_handler` and `private`.  This is accessed via reflection by some of the tests, which are
  now using the new name.
  - tests/mmptest/src/MMPTest.cs: here
  - tests/mtouch/MTouch.cs: here

* tests/monotouch-test/System.Net.Http/MessageHandlers.cs:
  Adjust `RejectSslCertificatesServicePointManager` to reflect the certificate validation
  changes described above.
  - FIXME: There was an `Assert.Ignore()` related to `NSUrlSessionHandler` and macOS 10.10;
    I removed that to reenable the test because the description linked to an old issue in
    the private repo that was referenced by several "Merged" PR's, so it looked to me that
    this might have already been fixed - and I also didn't see why it would fail there.
2019-12-04 15:10:32 -05:00
Manuel de la Pena 8abcd9c60c
[Network] Add missing BindingImplAttr. (#7530)
Fixes: https://github.com/xamarin/xamarin-macios/issues/7513
2019-12-04 11:41:29 -05:00
monojenkins 74a94c35d1 [monotouch-test] Make NetworkReachabilityTest.CtorIPAddressPair a bit more permissive. Fixes xamarin/maccore#2047. (#7521)
Try to fix https://github.com/xamarin/maccore/issues/2047 by making the test
accept NetworkReachabilityFlags.Reachable for the loopback address on device.

Fixes https://github.com/xamarin/maccore/issues/2047.
2019-12-02 21:54:33 +01:00
monojenkins 7e2e738eb3 [monotouch-test] Make NetworkReachabilityTest.CtorIPAddressPair a bit more permissive. Fixes xamarin/maccore#2047. (#7520)
Try to fix https://github.com/xamarin/maccore/issues/2047 by making the test
accept NetworkReachabilityFlags.Reachable for the loopback address on device.

Fixes https://github.com/xamarin/maccore/issues/2047.
2019-12-02 18:36:43 +01:00
Rolf Bjarne Kvinge bc6735374b
[monotouch-test] Make NetworkReachabilityTest.CtorIPAddressPair a bit more permissive. Fixes xamarin/maccore#2047. (#7516)
Try to fix https://github.com/xamarin/maccore/issues/2047 by making the test
accept NetworkReachabilityFlags.Reachable for the loopback address on device.

Fixes https://github.com/xamarin/maccore/issues/2047.
2019-12-02 07:58:57 +01:00
Sebastien Pouliot 4ffbef7cac
[avfoundation] Use a smart enum for AVMetadataObjectType (#7497)
and drop the manual, error prone, conversion code.

The fact that this is also used as a `[Flag]` enum does not mean smart
enum could not be used [1]. The flag code only needed to be updated to
use the smart enum generated code.

[1] https://github.com/xamarin/xamarin-macios/issues/7317

Added unit tests.
2019-11-28 10:40:12 -05:00
Marius Ungureanu 38a3c4ed87 [CFNetwork] Fix ownership rules of CFHTTPAuthentication (#6088)
`Create` methods give ownership of the object, so in this case, owns=true. Prevents leak of CFHTTPAuthentication

Co-Authored-By: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-Authored-By: Manuel de la Pena <mandel@microsoft.com>
2019-11-26 16:28:41 -05:00
monojenkins bcf3899893 [generator] If forcing a managed type, we must do so even if there's another managed instance of an incompatible type. Fixes #7441. (#7460)
If forcing a managed type for a particular native handle, we must ensure we're
always successful.

This means creating another managed instance even if there already is an
existing instance for the native handle. This is not optimal, but the
alternative is worse: some functionality can be completely broken otherwise
(such as NSSavePanel⁄NSOpenPanel may stop working).

If creating multiple managed instances for the same native handle ends up
being too problematic, we'll probably have to add full support for this
scenario (see #7442).

Fixes https://github.com/xamarin/xamarin-macios/issues/7441.
2019-11-26 13:38:57 -05:00
Manuel de la Pena 245fdf96aa
[Tests] Reuse NetworkResources in the linker tests. (#7451)
The linking tests do use a number of endpoints.
As with PR https://github.com/xamarin/xamarin-macios/pull/7418 we want
to have all the endpoints in a single place to update them if the server
side does give us problems.
2019-11-25 04:54:56 -05:00
monojenkins f30817fd70 [generator] If forcing a managed type, we must do so even if there's another managed instance of an incompatible type. Fixes #7441. (#7453)
If forcing a managed type for a particular native handle, we must ensure we're
always successful.

This means creating another managed instance even if there already is an
existing instance for the native handle. This is not optimal, but the
alternative is worse: some functionality can be completely broken otherwise
(such as NSSavePanel⁄NSOpenPanel may stop working).

If creating multiple managed instances for the same native handle ends up
being too problematic, we'll probably have to add full support for this
scenario (see #7442).

Fixes https://github.com/xamarin/xamarin-macios/issues/7441.
2019-11-15 22:34:27 +01:00
Rolf Bjarne Kvinge 7caf1fbb04
[generator] If forcing a managed type, we must do so even if there's another managed instance of an incompatible type. Fixes #7441. (#7445)
If forcing a managed type for a particular native handle, we must ensure we're
always successful.

This means creating another managed instance even if there already is an
existing instance for the native handle. This is not optimal, but the
alternative is worse: some functionality can be completely broken otherwise
(such as NSSavePanel⁄NSOpenPanel may stop working).

If creating multiple managed instances for the same native handle ends up
being too problematic, we'll probably have to add full support for this
scenario (see #7442).

Fixes https://github.com/xamarin/xamarin-macios/issues/7441.
2019-11-15 08:16:06 +01:00
Manuel de la Pena d83e9687a6
[Tests] Centralized the endpoints for the different network tests. (#7418)
Use a single point where the different enpoints can be found so that
if they need to be updated (server issues or other) it is a simple
change that will affect all tests in monotouch-tests
2019-11-14 05:45:33 -05:00
Manuel de la Pena 8a63932245
[Tests] GetGlobalQueue_QualityOfService is only supported on Mac OS X 10.10 and later (#7419)
Ensure that the test does not fail in earlier versions of the os.

Fixes: https://github.com/xamarin/maccore/issues/2062
2019-11-13 06:03:23 -05:00
michizhou e9b18d4c2f [CoreFoundation] [tests] Add new DispatchQueue overloaded method (#7343)
* [CoreFoundation] [tests] Add new DispatchQueue overloaded method with unit tests. Fixes #6783

* [CoreFoundation] [tests] Add new variant method to DispatchQueue

* [CoreFoundation] [tests] Remove nonexistent DispatchQueue methods

* [CoreFoundation] [tests] Restore existing methods and tests
2019-11-12 14:56:45 +01:00
Vincent Dondain 44fd06324a Merge master into d16-5 2019-11-08 10:21:12 -05:00