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

1150 Коммитов

Автор SHA1 Сообщение Дата
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
Rolf Bjarne Kvinge b770d1eae8
[CoreGraphics] Improve matrix types for .NET. Fixes #14125. (#14208)
Hoping that one day we'll have a System.Numerics.Matrix3x3 type we can replace our
RMatrix3 type with:

* Add all API in OpenTK.Matrix3 that also exists in equivalent form in System.Numerics.Matrix4x4.
* Remove all API that doesn't exist in equivalent form in System.Numerics.Matrix4x4.

For NMatrix2 and NMatrix3:

* Change the fields to be M## instead of R#C# (this is how System.Numerics does
  it, and also how we do it in other matrix types).
* Add obsolete and hidden R#C# versions of the fields to ease migrating existing
  code to .NET (but let's try to remove these in xamcore 5).
* Add properties in legacy Xamarin recommending users to use the new naming.
* A few other API additions to add equivalent API to the matrix types in System.Numerics.

For CGAffineMatrix:

* Add obsolete and hidden versions of the legacy field names to .NET to ease
  migrating existing (but let's try to remove these in xamcore 5).

Fixes https://github.com/xamarin/xamarin-macios/issues/14125.
2022-02-24 18:42:19 +01:00
Rolf Bjarne Kvinge bd97933b60
[runtime] Remove ObjCRuntime.nfloat in favor of System.Runtime.InteropServices.NFloat. (#14197)
* Remove ObjCRuntime.nfloat (in favor of   System.Runtime.InteropServices.NFloat).
* Automatically add a reference to the System.Runtime.InteropServices.Internal
  package, so that developers get the new NFloat API (with operators) we've
  added post .NET 6 (but don't do this for .NET 7).
* Automatically add a global using alias for
  System.Runtime.InteropServices.NFloat -> nfloat. This is not behind the
  usual `ImplicitUsings` condition our other implicit usings are, because
  they're off by default for existing projects, and the main target for the
  global using alias for nfloat is upgraded projects.
* Automatically generate a global using alias (like above) in the generator
  for all code the generator compiles.
* Update xtro entries to reference System.Runtime.InteropServices.NFloat
  instead of ObjCRuntime.nfloat.
* Add a workaround for a hopefully temporary issue with .NET/CoreCLR where the
  wrong runtime pack is selected otherwise (without the new NFloat API, so
  nothing works at runtime).

Ref: https://github.com/xamarin/xamarin-macios/issues/13087
2022-02-24 16:51:12 +01:00
Sebastien Pouliot c918142101
[objcruntime] Fix some `IntPtr` -> `NativeHandle` inside `Class` (#14174)
* Using `NativeHandle` avoids implicit casts [1]
* Do not expose `IntPtr` as the type for the `SuperClass` handle

[1] likely not an issue with JIT/AOT optimization, less sure for the
interpreter. No harm in not having those in the product assembly.
2022-02-23 20:45:43 +01:00
Rolf Bjarne Kvinge 2140d46327
[monotouch-test] The RuntimeTest.ResurrectedObjectsDisposedTest test seems to be passing everywhere in .NET now. (#14175) 2022-02-18 16:34:58 +01:00
Rolf Bjarne Kvinge 2e62431fb1
[nfloat] Obsolete nfloat.CopyArray in legacy Xamarin and stop using it. (#14164)
There's no corresponding System.Runtime.InteropServices.NFloat.CopyArray method in .NET.

It turned out that the API where we used CopyArray don't need to use CopyArray at all, the same can be accomplished faster and simpler by using unsafe code.
2022-02-16 20:10:13 +01:00
Rolf Bjarne Kvinge 97afd484d2
[ObjCRuntime] Keep accepting IntPtr constructors in .NET as an alternative to NativeHandle constructors. Fixes #14046. (#14145)
As a part of the breaking changes in .NET, we introduced a new type,
`ObjCRuntime.NativeHandle`, to represent native handles.

This meant that constructors taking taking `IntPtr handle`:

```cs
public class MyUIViewController : UIViewController {
    protected MyUIViewController (IntPtr handle)
        : base (handle)
    {
    }
}
```

would have to be ported to take `NativeHandle handle`:

```cs
public class MyUIViewController : UIViewController {
    protected MyUIViewController (NativeHandle handle)
        : base (handle)
    {
    }
}
```

The unfortunate part is that there will be no compiler warnings or errors
flagging this, so users won't know to do it unless they either read the
documentation (🤣) or run into the problem, googles for a while, runs into
someone else who had the same problem, and applies their (probably broken)
fix.

So we change our logic to:

1. Look for and use an `(IntPtr)` (or `(IntPtr, bool)`) constructor in .NET if
   the `NativeHandle` version isn't found.
2. Show a warning.
3. Some time in the future maybe remove this hack/workaround.

Fixes https://github.com/xamarin/xamarin-macios/issues/14046.
2022-02-15 22:48:23 +01:00
Stephane Delcroix f36606e654
[C] Clear OpenTK namespace (#13767)
fixes #13160

- remove unused types
- use System.Numerics when possible
- move own created types from OpenTK namespace to CoreGraphics
- create missing types in CoreGraphics namespace

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-02-14 18:50:23 +01:00
Filip Navara 0622ae4af2
Fix GC issue on CoreCLR where finalized objects are returned by Runtime.GetNSObject (#14070)
Fixes race condition where finalized objects are resurrected by the finalizer and for a brief moment `Runtime.TryGetNSObject`/`Runtime.GetNSObject` would return them even though a new instance is supposed to be used. In multi-threaded scenarios this would result in reused objects (same native handle) to suddenly become invalid when the UI thread processes the delayed finalization.

Fixes #13921
2022-02-08 11:08:44 +01:00
Rolf Bjarne Kvinge 5eda463eaf
[Foundation] Remove a WebKit workaround for NSProxy on tvOS in .NET. (#14089)
The WebKit framework doesn't exist on tvOS.
2022-02-08 10:48:40 +01:00
Rolf Bjarne Kvinge a5855f6f88
[JavaScriptCore] Bind JSValue.ToArray as NSArray in .NET. Fixes #12549. (#14090)
Fixes https://github.com/xamarin/xamarin-macios/issues/12549.
2022-02-08 10:39:14 +01:00
Rolf Bjarne Kvinge 2d81a92270
[tests] Adopt XAMCORE_4_0 changes in monotouch-test .NET. (#14099) 2022-02-08 10:36:20 +01:00
Rolf Bjarne Kvinge 14dde5ca9a
[AppKit/Foundation] Make the "Color" suffix consistent in NSColor and UIColor properties. Fixes #7945. (#14080)
Make the "Color" suffix consistent in NSColor and UIColor properties (by removing the "Color" suffix for all such properties).

Fixes https://github.com/xamarin/xamarin-macios/issues/7945.
2022-02-08 09:15:21 +01:00
Rolf Bjarne Kvinge ef3b05478e
[tools/runtime] Enable exception marshalling by default for all platforms in .NET. (#14051)
When exception marshalling was originally implemented, for backwards
compatibility concerns it was only turned on by default for platforms that
really needed it (watchOS).

However, exception marshalling is by far the safest option, so in .NET we're
enabling it by default for all platforms (it's still possible to disable it
for those who wants to).

Ref: https://docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling
2022-02-07 14:12:32 +01:00
Marius Ungureanu dc9e080828
Implement IEquatable<T> on NSRange (#14083)
This avoids poor performance of GetHashCode and Equals that are used for the struct using reflection on the first field.
2022-02-07 07:52:45 +01:00
Rolf Bjarne Kvinge 534bf839c2
[Foundation] Fix signature for NSAttributedString.LowLevelGetAttributes to support no effectiveRange output. Fixes #13569. (#14069)
This makes it possible to override LowLevelGetAttributes to provide an
implementation, and be called with a NULL effectiveRange pointer.

Fixes https://github.com/xamarin/xamarin-macios/issues/13569.
2022-02-04 18:40:19 +01:00
Rolf Bjarne Kvinge d766fe8c8b
[AppKit] Remove a few obsolete members in .NET (#14043) 2022-02-04 08:14:10 +01:00
Rolf Bjarne Kvinge d5697a8867
[runtime] Use the full managed description (including inner exceptions) as the reason when creating an NSException from a managed exception. (#14002)
This makes diagnosing what happens much easier in some cases.

Exhibit A, pre fix:

    *** Terminating app due to uncaught exception 'ObjCRuntime.RuntimeException', reason: 'Failed to lookup the required marshalling information.
    Additional information:
    	Selector: conformsToProtocol:
    	Type: ViewController

Exhibit B, post fix:

    *** Terminating app due to uncaught exception 'ObjCRuntime.RuntimeException', reason: 'Failed to lookup the required marshalling information.
    Additional information:
    	Selector: conformsToProtocol:
    	Type: ViewController
     (ObjCRuntime.RuntimeException)
    Failed to get the 'this' instance in a method call to templ.ViewController.InvokeConformsToProtocol. (ObjCRuntime.RuntimeException)
       at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
       at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
       at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cls, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc, IntPtr& exception_gchandle)
    Failed to marshal the Objective-C object 0x7f813fd2f470 (type: ViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'templ.ViewController' does not have a constructor that takes one NativeHandle argument). (ObjCRuntime.RuntimeException)
       at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution)
       at ObjCRuntime.Runtime.ConstructNSObject[T](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution)
       at ObjCRuntime.Runtime.ConstructNSObject(IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution)
       at ObjCRuntime.Runtime.GetNSObject(IntPtr ptr, MissingCtorResolution missingCtorResolution, Boolean evenInFinalizerQueue)
       at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
2022-02-02 16:22:34 +01:00
Rolf Bjarne Kvinge 56a71684e5
[CoreImage] Adopt XAMCORE_4_0 changes in .NET. (#13983) 2022-02-02 16:07:45 +01:00
Rolf Bjarne Kvinge 101c0a7ac0
[Network] Adopt XAMCORE_4_0 changes in .NET. (#13988) 2022-02-01 21:17:18 +01:00
Rolf Bjarne Kvinge 2d48710858
[AppKit] Adopt XAMCORE_4_0 changes in .NET. (#13987)
* A lot of obsolete/deprecated removal.
* Remove the NSDraggingInfo model, which required numerous other changes.
* Remove the NSPasteboardReading/NSPasteboardWriting models, which required more
  numerous changes.
* Update the tests accordingly.
2022-02-01 20:56:32 +01:00
Rolf Bjarne Kvinge b1ce33ba51
[Foundation/ObjCRuntime] Use 'ObjCException' as the native exception type name for all platforms in .NET. Fixes #13855. (#13915)
* Use 'ObjCException' instead of 'MonoTouchException' as the managed exception
  type wrapping an NSException for all platforms in .NET (that was already the
  case for macOS, so no change there).
* Make the ObjCException class behave like the MonoTouchException class does.
* Move the ObjCException type to the ObjCRuntime namespace in .NET.

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

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-02-01 17:24:57 +01:00
Rolf Bjarne Kvinge aaee4d9f27
[ModelIO] Adopt XAMCORE_4_0 changes in .NET. (#13941)
This turned out a bit complex, because numerous ModelIO APIs were initially bound
with wrong matrix types, and had to be rebound later (our matrix type was transposed
with regards to the native matrix type). The new versions often had to use worse
names, so that's being fixed now. This means that numerous tests had to be updated,
because the original API now returns non-transposed matrices.
2022-02-01 08:08:50 +01:00
Rolf Bjarne Kvinge 1d8ef73ee1
[SystemConfiguration] Adopt XAMCORE_4_0 changes in .NET. (#13991) 2022-01-31 21:54:37 +01:00
Rolf Bjarne Kvinge 6674e83bec
[GameplayKit] Adopt XAMCORE_4_0 changes in .NET. (#13972) 2022-01-31 17:51:08 +01:00
Rolf Bjarne Kvinge 8405fcf3b8
[EventKit] Adopt XAMCORE_4_0 changes in .NET. (#13971) 2022-01-31 17:50:09 +01:00
Rolf Bjarne Kvinge d8c2e5e040
[HealthKit] Adopt XAMCORE_4_0 changes in .NET. (#13968) 2022-01-31 16:57:26 +01:00
Rolf Bjarne Kvinge 62b3eab06d
[Darwin] Adopt XAMCORE_4_0 changes in .NET. (#13965) 2022-01-31 16:51:12 +01:00
Rolf Bjarne Kvinge b0f84a44c1
[CoreMedia] Adopt XAMCORE_4_0 changes in .NET. (#13932) 2022-01-28 10:20:51 +01:00
Rolf Bjarne Kvinge 43d74fb895
[ObjCRuntime] Add explicit conversion operators between NativeHandle and void*. Fixes #13867. (#13929)
Fixes https://github.com/xamarin/xamarin-macios/issues/13867.
2022-01-28 10:03:54 +01:00
Rolf Bjarne Kvinge d2ef29739b
[CoreAnimation] Adopt XAMCORE_4_0 changes in .NET. (#13918)
* Mostly just removal of obsolete/deprecated API.
* Modified CAScrollLayer.ScrollMode to use the good name
  (CAScrollLayer.ScrollMode) for the strongly typed enum, and then have a
  WeakScrollMode property for the NSString version (like we do elsewhere).
2022-01-28 10:02:46 +01:00
Rolf Bjarne Kvinge 7e8650a931
[ARKit] Adopt XAMCORE_4_0 changes in .NET. (#13886)
For ARKit this just means removing obsolete/deprecated API.
2022-01-27 10:45:50 +01:00
Rolf Bjarne Kvinge 00647d50a5
[ModelIO] Fix the MDLVoxelIndexExtent name for .NET. (#13893) 2022-01-27 10:37:51 +01:00
Rolf Bjarne Kvinge e7024da461
[Photos] Adopt XAMCORE_4_0 changes in .NET. (#13830)
This means removing obsolete/deprecated API.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-01-25 11:58:48 +01:00
Rolf Bjarne Kvinge efb0ac2ac7
[PassKit] Adopt XAMCORE_4_0 changes in .NET. (#13833) 2022-01-25 11:52:59 +01:00
Rolf Bjarne Kvinge fbd55af78b
[NetworkExtension] Adopt XAMCORE_4_0 changes in .NET. (#13842) 2022-01-25 11:50:35 +01:00
Sebastien Pouliot eb3015b388
[mobilecoreservices] Modernize UTType (#13831)
* Use `is` instead of `==` for null checks
* Use `ThrowHelper` to throw common exceptions
* Use faster `CFString` API (over the slower `NSString` variants)

* [tests] Adjust UTTypeTest.cs to build for net profile
2022-01-24 21:57:28 -05:00
Rolf Bjarne Kvinge c738fd47b4
[AudioComponentDescription] Strong-type the ComponentSubType field in .NET. (#13827)
Strong names are always better!
2022-01-21 21:30:55 +01:00
Sebastien Pouliot 25fab0b74e
[net][coregraphics] Match native strings representation for structs (#13802)
* Use the native `NSStringFrom*` API so we can, eventually, use the
native code to parse them from `NSString` and also ensure increased
compatibility with any code that expects the native string representation

* Add unit tests for `ToString` methods

Also use [`System.HashCode`](https://docs.microsoft.com/en-us/dotnet/api/system.hashcode?view=net-6.0) to generate the hash code
2022-01-21 08:46:25 +01:00
Rolf Bjarne Kvinge e51355f657
[SceneKit] Adopt XAMCORE_4_0 changes in .NET. (#13806)
This means removing obsolete/deprecated methods.
2022-01-21 08:09:57 +01:00
Rolf Bjarne Kvinge a2f7407b76
[SafariServices] Adopt XAMCORE_4_0 changes in .NET. (#13801) 2022-01-20 10:33:42 +01:00
Rolf Bjarne Kvinge 82a3b71c60
[Foundation] Adopt a better name/signature for numerous Foundation API in .NET. (#13776) 2022-01-20 10:32:55 +01:00