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

10586 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge a82575189b [CoreCLR] Add support for mono_assembly_open.
This includes going through all uses of mono_assembly_open, and make sure the release
the returned assembly.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge 18ac48c5c8 [runtime] Make it possible to implement Mono Embedding API in the CoreCLR bridge
By making it possible to skip the automatically generated Mono Embedding API that
just asserts.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge 2527679e34 [runtime] Add a MonoObject implementation for CoreCLR.
We need a way to represent a managed object in native code, and since most our existing
runtime code uses MonoObjects, we use the same for the CoreCLR bridge, just our own
version of it. In Mono, the MonoObjects are tracked by the GC (which scans the stack),
but we can't make CoreCLR scan the stack, so we use a reference counted version of
MonoObject instead - we just put the GCHandle into a reference counted MonoObject,
and when the MonoObject is freed, then we free the GCHandle as well.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge 9a643594fb [runtime] Add support for generating managed delegates only for CoreCLR.
However, since our managed code is shared between CoreCLR and MonoVM, the best we
can do is to make these CoreCLR-only delegates .NET-only.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge c8b6bc6c85
[dotnet] Build macOS/.NET for ARM64 as well. (#10959)
Partial fix for #10959.
2021-03-25 07:26:48 +01:00
Rolf Bjarne Kvinge 253061bf74
[runtime] Implement calling the managed Runtime.Initialize method from the CoreCLR bridge. (#10951)
* Move the existing logic to call Runtime.Initialize into the MonoVM code.
* Implement calling the managed Runtime.Initialize method from the CoreCLR bridge.

The call to Runtime.Initialize succeeds, which means we're now executing
managed code with CoreCLR for the first time.
2021-03-25 07:25:20 +01:00
Rolf Bjarne Kvinge 5fd95007fd
[tests] Adjust BuildingSameSolutionTwice_ShouldNotRunACToolTwice to work on an M1 machine. (#10954)
This test verifies that the build log prints:

    "execution started with arguments: actool --errors --warnings --notices --output-format xml1 --output-partial-info-plist "

However, for M1 machines, we don't call actool directly, we go through 'arch'
instead, and this line is printed:

    Tool arch execution started with arguments: -arch arm64e /usr/bin/xcrun actool --errors --warnings --notices --output-format xml1 --output-partial-info-plist ...

So adjust the test to cope with both of these behaviors.
2021-03-25 07:25:05 +01:00
Sebastien Pouliot 07fb20a6de
[generate-type-forwarders] Fix default parameters (#10958)
Example

```diff
-public AvailabilityAttribute (Platform introduced, Platform deprecated = 0, Platform obsoleted = 0, Platform unavailable = 0)
+public AvailabilityAttribute (Platform introduced, Platform deprecated, Platform obsoleted, Platform unavailable)
```
2021-03-24 19:58:18 -04:00
Sebastien Pouliot c3981d257e
[generate-type-forwarders] Fix missing `protected internal` methods stubs (#10956)
Example:

```diff
-protected virtual void OnNewPersonComplete (ABNewPersonCompleteEventArgs e);
```
2021-03-24 17:42:43 -04:00
Sebastien Pouliot 9224246d25
[generate-type-forwarders] Fix `new virtual` properties (#10957)
```diff
-public virtual FPUIActionExtensionContext ExtensionContext { get; }
+public FPUIActionExtensionContext ExtensionContext { get; }
```
2021-03-24 17:38:41 -04:00
Alex Soto 9c791dcd07
[mono] Bump mono to bring iOS binaries built with xcode12.4 (#10943)
* [mono] Bump mono to bring iOS binaries built with xcode12.4

Also bumping system mono pkg to the one that contains arm64 support

New commits in mono/mono:

* mono/mono@eb4c3116eb Build iOS SDK archives on Xcode 12.4
* mono/mono@acb8d8ed6f [2020-02][marshal] Fix VARIANT and BSTR marshaling in structs (#20918)

Diff: be9218f4d1..eb4c3116eb

* [mtouch] fix version logic check

Fixes Unexpected minOS version (expected 8.0.0, found 7.0.0) in MonoTouch.iphonesimulator.sdk/lib/libmono-native-compat.dylib ()

we really only care if it is over the version we expect not below.

* Fix version test
2021-03-24 17:34:30 -04:00
Rolf Bjarne Kvinge 1b658149ff
[runtime] Fix argument name confusion in the xamarin_gchandle_new[_weakref] methods. (#10952)
This way the argument names match the argument names in the corresponding Mono Embedding API.

This is just an argument rename, no functional changes.
2021-03-24 17:38:01 +01:00
Rolf Bjarne Kvinge b30777f420
Bump to .NET 6.0.100-preview.3.21161.23 (#10772)
* Bump to .NET 6.0.100-preview.3.21152.10

* Bump to 6.0.100-preview.3.21152.10.

* Bump to 6.0.100-preview.3.21161.7.

* Bump to .NET 6.0.100-preview.3.21161.23.

* [dotnet-linker] Bump ILink and use the supported method of getting an assembly's location.

* Bump to MSBuild.StructuredLogger 2.1.364 to get support for newer binlog versions.

* Fix build failure

Fixes:

    TestHelpers/BuildEngine.cs(161,24): error CS0433: The type 'ProjectEvaluationFinishedEventArgs' exists in both 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'StructuredLogger, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d4c7181801cb6448' [/Users/builder/azdo/_work/1/s/xamarin-macios/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj]

* Update parsing binlog properties.

* Be more defensive.

* [tests] Make sure the InternalsVisibleToAttribute constructor isn't linked away.

* [tests] Implement better printing of binlogs.

The latest MSBuild.StructuredLogger made some internal changes to the Message
property which confuses some of our test logic. So implement manual printing
of the log entries that we care about to make sure they conform to the
expected format by the tests (the output is mimicing what 'msbuild /v:diag
foo.binlog' would show).
2021-03-24 16:59:33 +01:00
Rolf Bjarne Kvinge a93bcdec34
[ObjCRuntime] Simplify Runtime.NSLog to always call xamarin_log. (#10937)
* [ObjCRuntime] Simplify Runtime.NSLog to always call xamarin_log.

This also fixes a couple of bugs:

* We wouldn't use the arm64 version of NSLog on Xamarin.Mac.
* We would use a wrong xamarin_log declaration on Xamarin.Mac on older macOS
  (the string argument would be UTF8 as opposed to Unicode, which is what the
  native function expects).

* [Dlfcn] Ignore any failures to show a warning about dlopen with full path.

We can run into this problem:

    System.EntryPointNotFoundException: xamarin_log assembly:<unknown assembly> type:<unknown type> member:(null)
        at (wrapper managed-to-native) ObjCRuntime.Runtime.xamarin_log(string)
        at ObjCRuntime.Runtime.NSLog (System.String value) [0x00001] in <7b41a16d434f401091abbf1beafe6453>:0
        at ObjCRuntime.Dlfcn.dlopen (System.String path, System.Int32 mode) [0x0003b] in <7b41a16d434f401091abbf1beafe6453>:0
        at ObjCRuntime.Runtime.LookupInternalFunction[T] (System.String name) [0x00040] in <7b41a16d434f401091abbf1beafe6453>:0
        at ObjCRuntime.Runtime.EnsureInitialized () [0x00036] in <7b41a16d434f401091abbf1beafe6453>:0
        at AppKit.NSApplication.Init () [0x00016] in <7b41a16d434f401091abbf1beafe6453>:0
        at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
        at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395

which happens because we're trying to find libxammac.dylib, which we first try
to load without a full path, which runs into a code path that wants to show a
warning, which wants to use xamarin_log, which is in libxammac.dylib, which
we're trying to load. Ops.

So just ignore any failures to print this warning.

* Find a solution that doesn't involve catching exceptions.
2021-03-24 16:58:31 +01:00
Rolf Bjarne Kvinge 3b2fa0d0b1
[runtime] Move the declaration of the MonoObject struct to MonoVM-specific code. (#10938)
The fields of the MonoObject struct is specific to MonoVM, so this makes sure
we don't accidentally poke into random memory on CoreCLR.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2021-03-24 14:55:03 +01:00
Sebastien Pouliot 007964cb9f
[generate-type-forwarders] Fix const/readonly fields (#10944)
Examples:

```diff
-public double MinimumDuration = 5---null---;
+public const double MinimumDuration = null;
```

```diff
 public ---readonly--- Foundation.NSString RGB565;
```

Also handle `string` constants (quotes).
2021-03-24 09:25:14 -04:00
Rachel Kang deacce3293
Merge pull request #10886 from rachelkang/xcode12.5-avfoundation-b123
[AVFoundation] Update bindings for Xcode 12.5 beta 1,2,3
2021-03-24 09:21:56 -04:00
Sebastien Pouliot fa12b8d5e2
[devicecheck] Update for xcode 12.5 beta 3 (#10946) 2021-03-24 09:06:41 -04:00
Sebastien Pouliot 78ac083dcd
[generate-type-forwarders] Fix extension methods (#10948)
Examples:

```
-public void DidDeactivate (this IARCoachingOverlayViewDelegate This, ARCoachingOverlayView coachingOverlayView)
+public void DidDeactivate (IARCoachingOverlayViewDelegate This, ARCoachingOverlayView coachingOverlayView)
-public void DidRequestSessionReset (this IARCoachingOverlayViewDelegate This, ARCoachingOverlayView coachingOverlayView)
+public void DidRequestSessionReset (IARCoachingOverlayViewDelegate This, ARCoachingOverlayView coachingOverlayView)
-public void WillActivate (this IARCoachingOverlayViewDelegate This, ARCoachingOverlayView coachingOverlayView)
+public void WillActivate (IARCoachingOverlayViewDelegate This, ARCoachingOverlayView coachingOverlayView)
```
2021-03-24 09:04:49 -04:00
Sebastien Pouliot 3298f3b0b9
[apidiff] Skip _removed_ types when comparing Xamarin.iOS.dll between Catalyst and iOS assemblies (#10949)
We already have the _removed_ namespaces and listing all their types is
quite noisy which does not help reviewing changes/diff between the
assemblies.
2021-03-24 09:03:48 -04:00
Filip Navara 85dd54db29
Link FrameworkList.xml to a place where MSBuild SDK actually expects it (#10928)
The [SDK conflict resolution code](3c1307d227/src/Tasks/Common/src/ConflictResolution/ResolvePackageFileConflicts.cs (L54-L57)) expects the FrameworkList.xml file to be located in `$(TargetFrameworkDirectory)/RedistList/FrameworkList.xml`.

Fixes https://github.com/dotnet/runtime/issues/49211
Fixes https://github.com/dotnet/runtime/issues/49940
Fixes https://github.com/dotnet/runtime/issues/49477
Fixes https://github.com/xamarin/xamarin-macios/issues/10912
Fixes https://github.com/xamarin/xamarin-macios/issues/10839
Fixes https://github.com/xamarin/xamarin-macios/issues/10548
Fixes https://github.com/xamarin/xamarin-macios/issues/10592
Fixes https://github.com/mono/mono/issues/20805
Fixes https://github.com/mono/mono/issues/20894
2021-03-24 09:31:15 +01:00
Rolf Bjarne Kvinge 43d3f8b0f5
[runtime] Make the exception_gchandle argument optional for callbacks to managed code in CoreCLR. (#10939)
If no exception handling is provided when calling a managed delegate from native
code, and the managed code throws, then we'll abort.

It's not entirely clear how we'll handle managed exceptions that go through native
code yet, so this makes the initial implementation easier. By making the exception
handling optional, it'll be easy to find all cases where we need to fix it later,
by making it non-optional. The alternative is to add exception handling code all
over the place that would potentially have to be updated when we figure out exactly
what needs to be done.
2021-03-24 09:26:31 +01:00
Rolf Bjarne Kvinge 9153edebda
[runtime] Redirect to our objc_msgSend wrapper functions when needed for .NET code. (#10932)
This makes the mono_dllmap_insert function unnecessary for .NET, so remove it.

Ref: https://github.com/dotnet/runtime/issues/48110
Ref: https://github.com/dotnet/runtime/issues/43204
Ref: #10504
2021-03-24 09:17:35 +01:00
Sebastien Pouliot 2b7dc07d20
[generate-type-forwarders] Fix issues with properties stubs (#10941)
Examples

* Fix visibility, e.g. `protected`

```diff
-		public virtual System.IntPtr RawJointLandmarks {
+		protected virtual System.IntPtr RawJointLandmarks {
```

* Remove non-visible properties, e.g. `internal`

```diff
-		public virtual System.IntPtr _AddressBook {
-			get { throw new global::System.PlatformNotSupportedException (global::Constants.UnavailableOnMacCatalyst); }
-			set { throw new global::System.PlatformNotSupportedException (global::Constants.UnavailableOnMacCatalyst); }
-		}
```

* Fix `abstract` members

```diff
-public abstract ARSession Session { get; }
+public virtual ARSession Session { get; }
```
2021-03-23 20:05:49 -04:00
Rachel Kang ea3b15a95e
Fix spacing 2021-03-23 11:17:33 -04:00
Rachel Kang 3d5b3a89ef
More feedback fixes - update manual binding and test failures 2021-03-23 10:59:49 -04:00
Alex Soto fb5203bf55
[FileProvider] Update Bindings to Xcode 12.5 Beta 1 to Beta 5 (#10935) 2021-03-23 10:30:03 -04:00
Sebastien Pouliot 8056ae17e6
[generate-type-forwarders] Fix enum values (#10933)
Example:

```diff
-CameraUnauthorized = 103
+CameraUnauthorized = 3
-CollaborationDataUnavailable = 304
+CollaborationDataUnavailable = 13
...
```

ref: https://gist.github.com/vs-mobiletools-engineering-service2/3ebe78b99d66d2f2addcbc1d5831e6cd
2021-03-23 09:16:39 -04:00
Sebastien Pouliot e7aee69855
[metal] Update for xcode 12.5 beta 3 (#10934) 2021-03-23 09:12:19 -04:00
Rolf Bjarne Kvinge b2248993de
[runtime] Don't register for GC callbacks with CoreCLR, this will be done in a completely different manner (through managed code). (#10931) 2021-03-23 07:35:38 +01:00
Manuel de la Pena f969e83aeb
[Foundation] Break out of the delegate when we have canceled a task. Fixes #9132 (#10230) (#10930)
This is an interesting issue that happens in the following scenario:

1. A request is performed that will take some extra time to get a
   response or an error.
2. The request is cancelled BEFORE the delegate methods
   DidReceiveResponse, DidReceiveData or DidCompleteWithError and
   called. Yet we have not yet fully canceled the native request. It
   does take some time to do so, that is why we have a
   'NSURLSessionTaskStateCanceling' and not 'NSURLSessionTaskStateCancelled'

The issue happens because the GetInflightData checks if the task has
been canceled. In that method we have the following:

```csharp
if (inflight.CancellationToken.IsCancellationRequested)
  task?.Cancel ();
return inflight;
```

The call of the Cancel method in the NSData task has as ripple effect which
is the execution of the following callback:

```csharp
cancellationToken.Register (() => {
  RemoveInflightData (dataTask);
  tcs.TrySetCanceled ();
});
```

Which calls:

```csharp
void RemoveInflightData (NSUrlSessionTask task, bool cancel = true)
{
      lock (inflightRequestsLock) {
              if (inflightRequests.TryGetValue (task, out var data)) {
                      if (cancel)
                              data.CancellationTokenSource.Cancel ();
                      data.Dispose ();
                      inflightRequests.Remove (task);
              }
              // do we need to be notified? If we have not inflightData, we do not
              if (inflightRequests.Count == 0)
                      RemoveNotification ();
      }

      if (cancel)
              task?.Cancel ();

      task?.Dispose ();
}
```

The above call does call Dispose and Dipose in the inflight data does:
```csharp
if (disposing) {
    if (CancellationTokenSource != null) {
            CancellationTokenSource.Dispose ();
            CancellationTokenSource = null;
    }
}
```

If we follow these set of events for example in the
DidRecieveResponse:
```chsarp
[Preserve (Conditional = true)]
public override void DidReceiveResponse (NSUrlSession session, NSUrlSessionDataTask dataTask, NSUrlResponse response, Action<NSUrlSessionResponseDisposition> completionHandler)
{
    var inflight = GetInflightData (dataTask);

    if (inflight == null)
            return;

    try {
            var urlResponse = (NSHttpUrlResponse)response;
            var status = (int)urlResponse.StatusCode;

            var content = new NSUrlSessionDataTaskStreamContent (inflight.Stream, () => {
                    if (!inflight.Completed) {
                            dataTask.Cancel ();
                    }

                    inflight.Disposed = true;
                    inflight.Stream.TrySetException (new ObjectDisposedException ("The content stream was disposed."));

                    sessionHandler.RemoveInflightData (dataTask);
            }, inflight.CancellationTokenSource.Token);
```
If can happen that, when we get the delegate call to the method, the
request has been cancelled. That means that we are in the precise state
in which we do not longer care about the response BUT we did get a
infligh data reference.. that HAS BEEN DIPOSED!!! this later gives a NRE
in several places.

The correct way is to return null from the GetInflighData method if we
have been cancelled, this makes sense because if we cancelled we do not
care about the execution of any of the methods that required the data
since it has been disposed!


Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-03-22 16:51:45 -04:00
Manuel de la Pena a5e08705e1
Revert "[Xharness] Bump to the latests build in main. (#10926)" (#10929)
This reverts commit 70e475c3c1.
2021-03-22 15:21:16 -04:00
Sebastien Pouliot 70c6154298
[apidiff] Compare Xamarin.iOS between iOS and MacCatalyst (#10924)
Xamarin.MacCatalyst ships a `Xamarin.iOS.dll` assembly that contains
forwarders (to `Xamarin.MacCatalyst.dll`) and stubs that throws
`PlatformNotSupportedException`.

This is used to help code compatibility between both platforms - but
that requires exposing an identical surface and the best way to ensure
this is to compare (and report) them using `apidiff`

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2021-03-22 15:04:30 -04:00
Rolf Bjarne Kvinge c406cc1da7
[runtime] Don't install any logging/printing handlers for CoreCLR, there's no equivalent. (#10927)
This also means that we don't have to generate CoreCLR wrappers for the corresponding
embedding API, so adjust the generated code accordingly.
2021-03-22 15:18:37 +01:00
Manuel de la Pena 66e4516ddd
[CI] Add missing rule to generate the provisionator deps on older macs. (#10925) 2021-03-22 08:47:23 -04:00
Manuel de la Pena 70e475c3c1
[Xharness] Bump to the latests build in main. (#10926)
We believe we reverted the culprint in main.
2021-03-22 07:02:45 -04:00
Rolf Bjarne Kvinge d778cc28c8
[runtime/dotnet] Call coreclr_initialize/monovm_initialize at startup. (#10909)
We need to call coreclr_initialize/monovm_initialize at startup, so do that.
This is a partial implementation, in that we're not setting all the properties
that we should, and also the PINVOKE_OVERRIDE callback is not doing everything
it should either yet.

Ref: #10504.
2021-03-22 08:04:56 +01:00
Manuel de la Pena 350c8493ce
[CI][VSTS] Add support to run the tests on 10.12. (#10684) 2021-03-21 20:11:17 -04:00
Manuel de la Pena fbf1d2871e
Bump xharness to a version without an async change. (#10902) 2021-03-21 19:55:29 -04:00
Manuel de la Pena 84e4a6c6fb
[Xcode12.5] Add missing TV availability. #10920 (#10921)
API was added in 14.5 not earlier.

fixes https://github.com/xamarin/xamarin-macios/issues/10920
2021-03-21 11:07:26 -04:00
Manuel de la Pena fc738de03d
[Xcode12.5] Backport CI changes from main. (#10922)
Backport several fixes in the CI into xcode12.5 to be able to do the
following:

- Get device tests.
- Get older mac executions.

Includes a needed bump of maccore:

* [d16-9] [CI] remove login keychain password and xqa cert passwords (#2410)
2021-03-21 11:07:09 -04:00
Rachel Kang d9d19a4f98
Ignore unused OS 2021-03-19 18:10:43 -04:00
Rachel Kang f05658c0c2
More feedback updates 2021-03-19 18:10:42 -04:00
Rachel Kang a302ccb489
Update with more feedback fixes 2021-03-19 18:10:42 -04:00
Rachel Kang f587e8900c
Update with styling/formatting feedback 2021-03-19 18:10:42 -04:00
Rachel Kang 4871938dd0
[AVFoundation] Update bindings for Xcode 12.5 beta 1,2,3 2021-03-19 18:10:41 -04:00
Manuel de la Pena f7b208b980
[Xcode12.5] Fix regression test not to crash. fixes #10918 (#10919)
The api does not longer allow you to pass a null ptr. Create a dummy
controller:

fixes https://github.com/xamarin/xamarin-macios/issues/10918
2021-03-19 17:25:56 -04:00
Alex Soto 1c5fcde327
[ImageKit] Update bindings to Xcode 12.5 Beta 1 to Beta 3 (#10914) 2021-03-19 15:09:25 -04:00
Manuel de la Pena 47ceec63a2
[XHarness] Bump nuget to pickup watchOS sim bump. (#10627) 2021-03-19 09:34:45 -04:00
Sebastien Pouliot d1cc6f35d7
[mlcompute] Update for xcode12.5 beta 3 (#10905) 2021-03-18 20:18:10 -04:00