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

10765 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 94196bf767
[dotnet] Don't use an Output property to retrieve the list of native object files to link. (#11592)
If the task that creates the native object files doesn't execute (because the
native object files already exists and are up-to-date), the resulting list of
native object files to link will be empty.

This typically happens for a rebuild: if a native linker error occurs when
linking the main executable, building again will result in a successful build,
because we wouldn't try to link the main executable again.
2021-05-18 15:13:40 +02:00
Rolf Bjarne Kvinge fc52f2c7ff
[Runtime/CoreCLR] Only read/write a single byte for booleans when marshalling parameters in dynamic method calls for CoreCLR. (#11594)
Fixes this unit test:

    TestINativeObject: #b1
        Expected: 0
        But was: 140187942967200
2021-05-18 15:13:32 +02:00
Rolf Bjarne Kvinge 0e957d347f
[registrar] Define CORECLR_RUNTIME when in the generated registrar code for CoreCLR (#11584)
This makes sure that we build the right thing, our shipped headers behave
differently whether CORECLR_RUNTIME is defined or not.
2021-05-18 07:36:29 +02:00
Rolf Bjarne Kvinge b00b354f04
[xharness] Add a variation that uses the static registrar for monotouch-test/.NET/CoreCLR. (#11583) 2021-05-18 07:30:28 +02:00
Sebastien Pouliot cb7ece6e6b
[msbuild] Fix error message MSBStrings.W0073 -> W0074 (#11585)
Due to incorrect update while adapting code for translations.

```
    <data name="W0073" xml:space="preserve">
        <value>The App Extension '{0}' has a CFBundleVersion ({1}) that does not match the main app bundle's CFBundleVersion ({2})
        </value>
    </data>

    <data name="W0074" xml:space="preserve">
        <value>The App Extension '{0}' has an unrecognized NSExtensionPointIdentifier value ('{1}').
        </value>
    </data>
```

Fixes https://github.com/xamarin/xamarin-macios/issues/11581
2021-05-17 23:09:07 -04:00
Rolf Bjarne Kvinge db8b688704
[ObjCRuntime] Fix pointer logic with regards to MonoObject*s. (#11582)
Instead of passing a pointer to pointer to a pointer of a MonoObject to
xamarin_mono_object_retain, we pass a pointer to a MonoObject (like
xamarin_mono_object_retain expects).
2021-05-17 23:19:54 +02:00
Sebastien Pouliot 63ad08ed44
[src] Fix some breaking changes detected when bumping APIDIFF (#11567)
They were not visible (or handled differently in `main`) but
become _small_ breaking changes once we released xcode12.5 support.
2021-05-17 15:56:18 -04:00
Manuel de la Pena c49c241f43
[CI] Do run 32b tests. (#11571) 2021-05-17 11:17:37 -04:00
Rolf Bjarne Kvinge e8f26723ef
[CoreGraphics] Adjust CGPDFOperatorTable to not use a generic Action delegate. (#11560)
* CoreCLR doesn't support generic Action delegates in reverse (P/Invokes), so
  we need to find a different solution.
* The native CGPDFOperatorTable callback API is not very friendly to us,
  because we can't pass it callback-specific data, which means that the
  managed caller must conform to the FullAOT requirement of the managed
  callback (must be a static function; must have a MonoPInvokeCallback
  attribute).
* We can leverage the new function pointer syntax in C# 9 to make these
  requirements enforced by the C# compiler (unmanaged function pointer +
  UnmanagedCallersOnly attribute). The resulting API is still clunky to use,
  but I don't see any way around that.

Fixes this monotouch-test failure with CoreCLR:

    [FAIL] Tamarin : System.Runtime.InteropServices.MarshalDirectiveException : Cannot marshal 'parameter #3': Non-blittable generic types cannot be marshaled.
               at CoreGraphics.CGPDFOperatorTable.CGPDFOperatorTableSetCallback(IntPtr table, String name, Action`2 callback)
               at CoreGraphics.CGPDFOperatorTable.SetCallback(String name, Action`2 callback)
               at MonoTouchFixtures.CoreGraphics.PDFScannerTest.Tamarin() in xamarin-macios/tests/monotouch-test/CoreGraphics/PDFScannerTest.cs:line 102

Ref: https://github.com/dotnet/runtime/issues/32963
2021-05-17 07:45:04 +02:00
Rolf Bjarne Kvinge ab14e07146
[runtime] Implement mono_class_value_size for CoreCLR. (#11554) 2021-05-14 15:19:34 +02:00
Rolf Bjarne Kvinge eab3accf26
[runtime] Implement mono_class_is_enum and mono_class_enum_basetype for CoreCLR. (#11553)
* [runtime] Implement mono_class_is_enum for CoreCLR.

* [runtime] Implement mono_class_enum_basetype for CoreCLR.
2021-05-14 15:19:23 +02:00
Sebastien Pouliot 34c55f4ed4
[dotnet][tests][intro] Update ApiPInvokeTest (#11557)
* `QCall` seems to be gone
* `libSystem.Globalization.Native` symbols are part of the executable
  since they come from a static library
2021-05-14 09:00:18 -04:00
Sebastien Pouliot d8e1c600a4
[apidiff] Bump definitions now that `xcode12.5` support is on stable (#11558) 2021-05-14 08:41:56 -04:00
Manuel de la Pena c1981b0b7e
[Tests] Undo change that broke intro in BS. (#11556) 2021-05-14 07:49:47 +02:00
Rolf Bjarne Kvinge 9a013fd4a7
[runtime] Implement xamarin_get_[nsnumber|nsvalue]_type for CoreCLR. (#11552)
* Remove a few unused xamarin_get_*_class functions.
* Make the remaining two (xamarin_get_[nsnumber|nsvalue]_type) return a
  MonoType* instead of MonoClass* - that makes things slightly simpler for
  CoreCLR (the MonoClass* return values from the previous functions were
  always converted to MonoType*s anyway).
* Implement the xamarin_get_[nsnumber|nsvalue]_type functions.
* Make the existing mono_get_string_class use the new (and more generic)
  xamarin_bridge_lookup_class method instead of the specific
  xamarin_bridge_get_string_class (which can now be removed).
2021-05-14 07:29:48 +02:00
Rolf Bjarne Kvinge 42740a5c95
[runtime] Make xamarin_bridge_free_mono_signature accept NULL signatures. (#11550) 2021-05-14 07:28:53 +02:00
Rolf Bjarne Kvinge adb355b757
[runtime] Add support for creating managed exceptions from native code for CoreCLR. (#11538) 2021-05-14 07:27:42 +02:00
Rolf Bjarne Kvinge cf932d8f61
[msbuild] Add support for smelting metal for Mac Catalyst. (#11537)
This makes monotouch-test's Metal test file compile for Mac Catalyst.
2021-05-14 07:26:44 +02:00
Sebastien Pouliot 9591a47ac3
[dotnet][tests][link all] Ignore failures on devices (#11551)
Already known issues (already filled for similar tests in Link SDK)
2021-05-13 20:42:52 -04:00
Sebastien Pouliot 30c877ce45
[dotnet][tests][link sdk] Remove [Ignore] for https://github.com/dotnet/runtime/issues/49201 (#11549) 2021-05-13 20:39:50 -04:00
Manuel de la Pena bdfa8ca344
[CI] If the api & generator is not built do not fail the build. (#11525)
If can happen that when we bump xcode we do not get an api & generator
diff. This results in a set of cascading events that make the build
fail.

We know track when the result is not 0, store it in a var and pass that
variable to all the tempaltes that need it. The pwsh script already has
an if to check if the file if present and if not, it shows a warning.
2021-05-13 17:18:32 -04:00
Sebastien Pouliot b46cea29c7
[dotnet][tests] Fix monotouch-test RegistrarRemoval (#11527)
The registrar removal was fixed recently but the test was still failing.
Turns out xharness modify the linker setting for this test (as the
linker is required for this optimization) but the newer dotnet csproj
did not have an entry (to modify).

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

[xharness] Fix monotouch-test build when LinkSdk is used for dotnet projects

Skip failing assertion, issue filled
2021-05-13 17:01:20 -04:00
Sebastien Pouliot aaefe7bcf2
[tests][intro] Add back `[Test]` on some methods (#11542)
Those were likely removed when we excluded the tests from Catalyst
2021-05-13 16:58:10 -04:00
Rolf Bjarne Kvinge 5795a62f77
[runtime] Implement mono_method_full_name for CoreCLR. (#11536) 2021-05-13 22:04:09 +02:00
Rolf Bjarne Kvinge 0a0a849b02
[runtime] Implement mono_class_is_nullable for CoreCLR. (#11528) 2021-05-13 22:03:22 +02:00
Rolf Bjarne Kvinge 427c5447db
[tools] Make exception marshalling the default for CoreCLR (and make it an error to choose otherwise). (#11535)
* Make 'throw Objective-C exception' the default for managed exception marshalling.
* Make 'throw managed exception' the default for Objective-C exception marshalling.
* Disallow the 'unwind through native frames' option: CoreCLR won't do it.
* Disallow the 'unwind through managed frames' option: it's the safeset
  option by far, and also matches the reverse case.
* Disallow the 'disable' option: this is also not safe, let's try to go the
  safe route with CoreCLR.
* Change the default in native code too.

Partial fix for #10940.
2021-05-13 20:59:18 +02:00
Rolf Bjarne Kvinge 23fedf8389
[MediaToolbox] Don't use Action<T> in reverse P/Invokes. (#11541)
CoreCLR doesn't support it.

Ref: https://github.com/dotnet/runtime/issues/32963
2021-05-13 20:58:38 +02:00
Rolf Bjarne Kvinge 83dbeda8c6
[runtime] Refactor xamarin_get_nsnumber_converter to use string comparisons instead of mono_type_get_type. (#11530)
This makes it easier for CoreCLR. Also, at least for CoreCLR, it's unlikely to
be slower, since we'd have to compute the MONO_TYPE_* value in any
compatibility function.
2021-05-13 20:56:02 +02:00
Rolf Bjarne Kvinge 64e19d2d34
[runtime] Implement mono_class_get_nullable_param for CoreCLR. (#11531) 2021-05-13 20:39:07 +02:00
Rolf Bjarne Kvinge 95dfc4fa39
[runtime] Implement mono_value_box for CoreCLR. (#11533) 2021-05-13 20:38:21 +02:00
Rolf Bjarne Kvinge 8f1f367424
[runtime] Fix call to xamarin_print_all_exceptions. (#11532)
Passing a 'MonoObject*' to a function that expects a GCHandle doesn't quite
work, so make sure to get a GCHandle for the exception we want to print
information about.
2021-05-13 20:38:12 +02:00
Rolf Bjarne Kvinge df4ce9b6a8
Update the README with download links for d16-8 and d16-9 packages. (#11529) 2021-05-13 18:37:12 +02:00
TJ Lambert 4fb1707e11
initial changes to Change languageSet and Dependencies (#11512)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2021-05-13 08:35:08 -05:00
Manuel de la Pena d1904eccf1
[CI] Remove noise added when debugging at the start of the CI move. (#11526) 2021-05-13 08:43:06 -04:00
Manuel de la Pena 01d11263b9
[Tests] Ignore tests that fail on VMs (#11524)
There are a number of tests that do not work on VMs yet our older
machines are using virtualization. Ignore those tests since we cannot
assert if they work or not.

fixes: https://github.com/xamarin/maccore/issues/2438
2021-05-13 08:41:07 -04:00
Rolf Bjarne Kvinge 751976a769
[CoreCLR] Stub out mono_runtime_set_pending_exception for CoreCLR. (#11521)
We need additional API in CoreCLR to support pending exception properly, and
this is in progress [1]. In the meantime, stub out parts of it, so that the
process doesn't abort. This way we'll have failing tests instead (and work in
other areas can progress, since the process doesn't abort).

[1]: https://github.com/dotnet/runtime/pull/52146
2021-05-13 07:12:17 +02:00
Rolf Bjarne Kvinge 6bc3d97908
[runtime] Implement functions for getting and setting array elements for CoreCLR. (#11519)
This is not the fastest implementation, but it's the simplest I could come up
with, with the target of sharing as much code as possible with MonoVM. It can
be improved later if we find out it's a slow path (these functions are not in
a common code path, very few API bindings end up here).
2021-05-13 07:11:49 +02:00
Sebastien Pouliot 6b94c43de6
[dotnet][linker] Fix the elimitation of calls for `UIApplication::EnsureUIThread` (#11523)
Lack of `MONOTOUCH` define in the dotnet csproj [1] made this look for
the AppKit (XM) version.

[1] defining `MONOTOUCH` would have required several more changes.
Simplicity won!

|    Size    | MySingleView.app |
| ----------:|------------------|
|  4,579,985 | legacy           |
| 10,787,541 | dotnet [before](https://gist.github.com/02e072567595088522f376e522e22899) |
| 10,786,829 | dotnet [after](https://gist.github.com/afa5b7d4f9bb281646f050257034be11) |

There are other ways to achieve this with ILLink [2] but again:
Simplicity (by re-using) won!

[2] https://github.com/xamarin/xamarin-macios/issues/11477

--- a.cs	2021-05-12 14:17:13.000000000 -0400
+++ b.cs	2021-05-12 14:17:17.000000000 -0400
@@ -3764,13 +3764,6 @@
 }
 namespace UIKit
 {
-	public class UIKitThreadAccessException : Exception
-	{
-		public UIKitThreadAccessException()
-			: base("UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.")
-		{
-		}
-	}
 	[Register("UIApplication", true)]
 	public class UIApplication : UIResponder
 	{
@@ -3824,14 +3817,6 @@
 			UIApplicationMain(args.Length, args, principal, @delegate);
 		}

-		public static void EnsureUIThread()
-		{
-			if (CheckForIllegalCrossThreadCalls && mainThread != null && mainThread != Thread.CurrentThread)
-			{
-				throw new UIKitThreadAccessException();
-			}
-		}
-
 		protected internal UIApplication(IntPtr handle)
 			: base(handle)
 		{
@@ -3862,7 +3847,6 @@
 		public UIButton(CGRect frame)
 			: base(NSObjectFlag.Empty)
 		{
-			UIApplication.EnsureUIThread();
 			if (base.IsDirectBinding)
 			{
 				InitializeHandle(Messaging.IntPtr_objc_msgSend_CGRect(base.Handle, Selector.GetHandle("initWithFrame:"), frame), "initWithFrame:");
@@ -3876,7 +3860,6 @@
 		[Export("setTitle:forState:")]
 		public virtual void SetTitle(string title, UIControlState forState)
 		{
-			UIApplication.EnsureUIThread();
 			IntPtr arg = NSString.CreateNative(title);
 			if (base.IsDirectBinding)
 			{
@@ -3948,8 +3931,7 @@
 			[Export("bounds")]
 			get
 			{
-				//Discarded unreachable code: IL_002f
-				UIApplication.EnsureUIThread();
+				//Discarded unreachable code: IL_002b
 				if (base.IsDirectBinding)
 				{
 					_ = 8;
@@ -3965,7 +3947,6 @@
 			[Export("mainScreen")]
 			get
 			{
-				UIApplication.EnsureUIThread();
 				return Runtime.GetNSObject<UIScreen>(Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("mainScreen")));
 			}
 		}
@@ -4025,7 +4006,6 @@
 		[Export("addSubview:")]
 		public virtual void AddSubview(UIView view)
 		{
-			UIApplication.EnsureUIThread();
 			IntPtr nonNullHandle = NativeObjectExtensions.GetNonNullHandle(view, "view");
 			if (base.IsDirectBinding)
 			{
@@ -4065,7 +4045,6 @@
 			[Export("view", ArgumentSemantic.Retain)]
 			get
 			{
-				UIApplication.EnsureUIThread();
 				if (base.IsDirectBinding)
 				{
 					return Runtime.GetNSObject<UIView>(Messaging.IntPtr_objc_msgSend(base.Handle, Selector.GetHandle("view")));
@@ -4083,7 +4062,6 @@
 		public UIViewController()
 			: base(NSObjectFlag.Empty)
 		{
-			UIApplication.EnsureUIThread();
 			if (base.IsDirectBinding)
 			{
 				InitializeHandle(Messaging.IntPtr_objc_msgSend(base.Handle, Selector.GetHandle("init")), "init");
@@ -4124,7 +4102,6 @@
 			[Export("setRootViewController:", ArgumentSemantic.Retain)]
 			set
 			{
-				UIApplication.EnsureUIThread();
 				IntPtr arg = NativeObjectExtensions.GetHandle(value);
 				if (base.IsDirectBinding)
 				{
@@ -4146,7 +4123,6 @@
 		public UIWindow(CGRect frame)
 			: base(NSObjectFlag.Empty)
 		{
-			UIApplication.EnsureUIThread();
 			if (base.IsDirectBinding)
 			{
 				InitializeHandle(Messaging.IntPtr_objc_msgSend_CGRect(base.Handle, Selector.GetHandle("initWithFrame:"), frame), "initWithFrame:");
@@ -4160,7 +4136,6 @@
 		[Export("makeKeyAndVisible")]
 		public virtual void MakeKeyAndVisible()
 		{
-			UIApplication.EnsureUIThread();
 			if (base.IsDirectBinding)
 			{
 				Messaging.void_objc_msgSend(base.Handle, Selector.GetHandle("makeKeyAndVisible"));
@@ -4188,7 +4163,6 @@
 		public UIApplicationDelegate()
 			: base(NSObjectFlag.Empty)
 		{
-			UIApplication.EnsureUIThread();
 			base.IsDirectBinding = false;
 			InitializeHandle(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, Selector.GetHandle("init")), "init");
 		}
```

Co-authored-by: Sebastien Pouliot <sebastien.pouliot@microsoft.com>
2021-05-12 20:18:49 -04:00
Sebastien Pouliot 1026b3f65c
[dotnet][generator] Fix creating 3rd party bindings (#11522)
Internally the generator uses `AvailabilityBaseAttribute` to make its
decisions. For `dotnet` we generated the newer `[SupportedOSPlatform]`
and `[UnsupportedOSPlatform]`.

A 3rd-party (dotnet) binding might refer to members decorated with the
newer attributes and fail the build with an error [1]. Avoiding the error
is easy (first block of the diff) but it does not make the _right_
decisions (e.g. if a member is unavailable for the platform) when
generating the code.

To fix this we need to be able to convert the new attributes into the
well know `AvailabilityBaseAttribute` subclasses. We have not spotted
such cases yet because

* the bindings pass our tests (good but extra code would not fail)
* API diff across legacy and dotnet is not yet done [2]

[1] https://github.com/xamarin/xamarin-macios/issues/11497
[2] https://github.com/xamarin/xamarin-macios/issues/10210
2021-05-12 18:47:28 -04:00
Manuel de la Pena 05e2a460c7
[CI] Use stage names and clean the triggers. (#11461)
Add stage names to the templates to use them in triggers in the future.
Remove a yaml file that turned out not to be needed (via a hack around
vsts limitations).
2021-05-12 18:26:00 -04:00
TJ Lambert 6eb60b9f74
Adding changes to make sure tests are not run in scheduled builds (#11518)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2021-05-12 17:16:32 -05:00
Rolf Bjarne Kvinge 98ba6d35e4
[CoreCLR] Stub out RegisterToggleRef for CoreCLR. (#11520)
We need additional API in CoreCLR to support toggle refs properly, and this is
in progress [1]. In the meantime, stub out parts of it, so that the process
doesn't abort. This way we'll have failing tests instead (and work in other
areas can progress, since the process doesn't abort).

[1]: https://github.com/dotnet/runtime/pull/52146
2021-05-12 23:38:04 +02:00
Rolf Bjarne Kvinge 39b0ca4934
[runtime] Implement mono_reflection_type_get_type for CoreCLR. (#11513)
This also meant reviewing calling code to make sure that the return value is
released when it should be.
2021-05-12 23:37:40 +02:00
Sven Boemer dc320a3606
Update to new linker custom steps API (#11374)
* Update to new linker custom steps API

* PR feedback

- Fix indentation
- Add Initialize(LinkContext) to ExceptionalMarkHandler
- Remove unnecessary ifdef
- Use IsSetter/IsGetter
- Use [0] instead of Single()
- Avoid allocating empty collections

* Note override issue

* Clean up comments

* Move `DynamicRegistrationSupported` change earlier, along with the
detection code.

This solve the issue that `ILLink` does a similar job _before_ we have
the chance to disable the dynamic registrar.

* ILLink does not support considering other attributes as `[Preserve]`

when it is itself preserved at the assembly-level.

This ignored test is checking that feature so it cannot be enabled
for `NET`

Added to known breaking changes https://github.com/xamarin/xamarin-macios/issues/8900

* Fix removal of the dynamic registrar on legacy

* Fix IntPtr size inlining

Co-authored-by: Sebastien Pouliot <sebastien.pouliot@microsoft.com>
2021-05-12 12:26:54 -04:00
Manuel de la Pena 289b095313
[Tests] Allow to assert on device and not vm on macOS. (#11508) 2021-05-12 11:09:35 -04:00
Rolf Bjarne Kvinge b4fd5f1e63
[runtime] Implement mono_get_string_class for CoreCLR. (#11514) 2021-05-12 15:22:11 +02:00
Rolf Bjarne Kvinge 6e9d9b483d
[runtime] Implement mono_array_new and mono_array_length for CoreCLR. (#11515)
* [runtime] Implement mono_array_new for CoreCLR.

* [runtime] Implement mono_array_length for CoreCLR.
2021-05-12 15:21:56 +02:00
Rolf Bjarne Kvinge 913cbb67d7
[xharness] Add ARM64 variations for macOS/.NET using both MonoVM and CoreCLR. (#11516) 2021-05-12 15:04:14 +02:00
Rolf Bjarne Kvinge 82f8ca80a1
[tests] Make ImageCaptioningTest.SetCaption restore the original value at the end. (#11499)
This makes it so that ImageCaptioningTest.GetCaption doesn't fail because it
gets values it doesn't expect.
2021-05-12 07:56:11 +02:00
Rolf Bjarne Kvinge a3932e8765
Improve support for ARM64 on macOS. (#11501)
* Implement our xamarin_dyn_objc_msgSend[Super] overrides for ARM64.
* Modify mmp to use those overrides.
* Fix an issue with the existing xamarin_arm64_common_trampoline that caused
  exceptions to not unwind correctly.
* Add an ARM64 variation of xammac tests in xharness.
* Various test fixes.
2021-05-12 07:35:10 +02:00