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

10556 Коммитов

Автор SHA1 Сообщение Дата
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
Mauro Agnoletti c9d1760cfc Fixing CoreiOSSdkDirectory definition for legacy project system
The way that CoreiOSSdkDirectory was definded ($(MSBuildThisFileDirectory.Replace('...', '...'))) was returning an encoded string value that caused issues in legacy project systems. The reason of the issues is that the CoreiOSSdkDirectory value for legacy project systems is `Program Files (x86)`, and the "Replace'" function was encoding the '(' and ')' causing the "UsingTask" for fail because the Assembly File path was wrong (because it contains those encoding values).

The fix consist of applying the "Replace" function only when the path of the targets belongs to a .net SDK path, in which case it won't fail because it's under "Program Files".

We need to discuss with the MSBuild team to show this issue and know if it's a bug or how we can avoid the failure
2021-03-18 18:20:24 -03:00
Mauro Agnoletti dcdfe8ebfa Fixed iOS Binding projects build in Windows
iOS Binding projects were not building remotely since 16.9. This commit fixes that and allows to start building remotely.

Xamarin.iOS.ObjCBinding.CSharp.After.props is imported too early and because it was also importing the Messaging targets, some things like RebuildDependsOn and BuildDependsOn were being overridden by other targets, resulting on not hooking up on the remote execution.
2021-03-18 18:20:24 -03:00
Rolf Bjarne Kvinge 1da2d452dd
[msbuild/dotnet] Add support for parsing --setenv from bundler arguments. (#10896)
Add support for parsing --setenv from bundler arguments and passing them to
dotnet-linker so that the environment variables can be baked into the app at
launch (like they would be for mtouch/mmp).
2021-03-18 15:15:02 +01:00
Rolf Bjarne Kvinge 307f97e529
[dotnet] Add a IsCoreCLR initialization flag. (#10900)
So that we can detect in managed code whether we're running with CoreCLR or
MonoVM.
2021-03-18 14:29:06 +01:00
Sebastien Pouliot 9a4c06e006
[tests] Fix introspection build for iOS (and related) (#10906) 2021-03-18 09:15:26 -04:00
Sebastien Pouliot 60da845437
[xtro] Fix 'make gen-all' for Catalyst (when xtro has not run yet) (#10907) 2021-03-18 09:14:17 -04:00
Sebastien Pouliot 842a83ab4e
[coremotion] Fix xtro data files (nothing left todo) (#10908) 2021-03-18 09:12:42 -04:00
Rolf Bjarne Kvinge af5651accf
[runtime] Move MonoVM-specific initialization to MonoVM-specific code. (#10899)
* [runtime] Download the CoreCLR embedding header file

* [runtime] Create VM-specific code and header files and include them in the build

* [runtime] Move MonoVM-specific initialization to MonoVM-specific code.
2021-03-18 07:23:39 +01:00
mathieubourgeois a921ee2fb1
Xamarin.Mac native Apple Silicon targetting support (#10115)
* Add support for Xamarin.Mac arm64

* Add compile product definition task

Xamarin.Mac can be provided with a ProductDefinition file for the generated pkg. Normally, providing a product definition was optional. However, with Apple Silicon, we have an extra issue : `productbuild` needs to know what architectures your package target. If not provided with them, it will guess to the best of its abilities. However, on Catalina and lower, the guess is x86_64, even if you have an arm64 slice. To fix this, we add a new task to compile the product definition and use this file to create the pkg. If you provide your own Product Definition, we can check and warn if the architectures don't match what we expect. If the file doesn't exist or there is no architecture, we set it ourselves based on our target architectures.

* Don't reference dynamic objC_send on arm64

When building in debug, we currently try to link dynamic objC_send symbols when targeting a 64-bit architecture. However, this is actually only defined on Intel architectures, not on arm64, so we end up failing because we're referring symbols that don't exist. Rework the `GetRequiredSymbols` to take an abi, and tag those symbols to only be valid on i386/x86_64, so they don't get referred at all when building on arm64, but still get referred in x86_64.

* Fix improper delete/move with already existing directories

* Fix stret requirement for Xamarin.Mac in arm64.

The generator supposes that we're running in x64 mode, refactor to take into account the possibility of running in arm64.

* Implement OS version generation in Product.plist, based on MinimumSystemVersion of the app

* Re-generalize some mmp registrar rules

`Microsoft.macOS.registrar` was missed by the current rule set

* Fix mmp tests

* Set E7072 as not translated

Tests were failing otherwise

* Rename Xamarin.Mac lib/x86_64 folder to 64bits (currently all targeted archs are the same)

* Fix style issues

* Fix `ToLower` usage for invariant usage

* Fix xtro-sharpie test
2021-03-17 21:48:02 -04:00
Alex Soto 724f09d54e
[AudioToolbox] Update bindings to Xcode 12.5 Beta 1 to Beta 3 (#10894)
* [AudioToolbox] Update bindings to Xcode 12 Beta 1 to Beta 3

* Apply suggestions from code review
2021-03-17 19:21:27 -04:00
Rolf Bjarne Kvinge 3f018eedb6
[tests] Don't forcefully exit macOS tests. (#10844)
* [tests] Don't forcefully exit macOS tests.

Instead give the process a chance to exist (3 seconds), before we take drastic
measures.

* Bump Touch.Unit.

New commits in spouliot/Touch.Unit:

* spouliot/Touch.Unit@f19eb45 [TouchRunner] Try to make MacRunner exit nicely. (#100)

Diff: a33e0c3f2e..f19eb45cb6

* It looks like mono from 2020-02 doesn't want to exit no matter what, so limit this to .NET.
2021-03-17 18:46:29 +01:00
Manuel de la Pena cb18cb881f
Revert "[Xharness] Bump to the new nuget in the xharness main branch. (#10761)" (#10898)
This reverts commit 7db547617a.
2021-03-17 11:35:14 -04:00
Alex Soto 2358d636e5
[Intents] Update bindings to Xcode 12.5 from Beta 1 to Beta 3 (#10862)
* [Intents] Update bindings to Xcode 12.5 from Beta 1 to Beta 3

* Fix watch availability

* Fix some more

* fix xtro
2021-03-17 11:33:09 -04:00
Sebastien Pouliot bc12a3908c
[healthkit] Update for xcode 12.5 beta 3 (#10892) 2021-03-17 08:31:50 -04:00
Sebastien Pouliot 403a6665e5
[gamecontroller] Update for Xcode 12.5 beta 3 (#10893) 2021-03-17 08:30:18 -04:00
Connor Adsit 8785b954b1
[CI] Remove login keychain references (#10778)
* Remove references to the login keychaintools/devops/automation/templates/build/build.yml

* remove login-keychain envvar, add credential envvars

* use special branch of maccore

* Fix variable references

* Add keyringPass back in

* and here, too

* Change maccore to HEAD of current needed version + keychain fixes

* Bump back to maccore/main.

New commits in xamarin/maccore:

* xamarin/maccore@e81fac5451 [CI] remove login keychain password and xqa cert passwords (#2404)
* xamarin/maccore@548fa45432 [mlaunch] Disable building mlaunch when not including the legacy Xamarin build. (#2403)

Removed commits from xamarin/maccore:

* xamarin/maccore@ef5502ee51 remove login keychain password and xqa cert passwords

Diff: ef5502ee51..e81fac5451

* revert pipeline branch of maccore to main

* [maccore] Bump maccore

New commits in xamarin/maccore:

* xamarin/maccore@b9aaee7254 Remove unneeded block intended to add creds to login.keychain
* xamarin/maccore@0ac61f1fba [dotnet] Changes the msbuild.zip to include Windows files (#2408)
* xamarin/maccore@e81fac5451 [CI] remove login keychain password and xqa cert passwords (#2404)

Diff: 548fa45432..b9aaee7254

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2021-03-17 08:16:58 +01:00
Rolf Bjarne Kvinge 79cd5d203f
[NSObject] Rework the SuperHandle property to not return a pointer into managed memory. (#10888)
Previously, the SuperHandle property returned a pointer into the middle of the
NSObject instance. This is not safe, because we can't make pin the NSObject
instance past the return of the SuperHandle property getter.

So rework the logic, to allocate a chunk of native memory that SuperHandle can
return, and use that instead. This means a little bit of book-keeping to
create and destroy this native memory.

Unfortunately it will also increase the memory usage for each NSObject
instance, but I don't see a way around that, while still fixing the problem
with SuperHandle, given that we can't change the signature of SuperHandle.
2021-03-17 08:01:51 +01:00
Rolf Bjarne Kvinge 46c999f0ad
[runtime] Resolve symlinks using API provided by NSString instead of Mono. (#10889)
Mono's way doesn't work with CoreCLR anyway.
2021-03-17 07:54:52 +01:00
Rolf Bjarne Kvinge 913d6e6f0e
[xharness] Fix execution results for mac tests. (#10852)
The test run can fail even if all the tests pass: in case the process crashes
or deadlocks at exit for instance. Don't overwrite such failures with the unit
test results.
2021-03-17 07:38:16 +01:00
Alex Soto ea7fe76d60
[Foundation] Update bindings to Xcode 12.5 Beta 1 to Beta 3 (#10859) 2021-03-16 21:59:21 -04:00
Manuel de la Pena 7db547617a
[Xharness] Bump to the new nuget in the xharness main branch. (#10761) 2021-03-16 18:10:30 -04:00
TJ Lambert 5006fb8fce
[Localization] Add Step to Generate LocProject.json (#10876)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2021-03-16 17:34:19 -04:00
Sebastien Pouliot 584b45a25e
[catalyst] Remove extraneous API detected by xtro (#10872)
This fixes almost [1] all `extra` API detected from the extrospection
(header-based) tests for MacCatalyst. This is needed to complete the
introspection fixes (without having _too large PR).

[1] except `!extra-null-allowed!` since those are still in progress for
all platforms
2021-03-16 16:04:01 -04:00
Rolf Bjarne Kvinge 13e458ebff
[msbuild] Fix logic to copy windows files (#10873)
By creating a directory before trying to copy files into it.
2021-03-16 18:48:44 +01:00
Rolf Bjarne Kvinge 32e4d05195
[dotnet] Add support for specifying the VM with the _XamarinRuntime property. (#10881)
Use a private property (prefixed with underscore) for now, until we can decide
on a better/general name.

Also add a variation to xharness to build monotouch-test with CoreCLR
(building works fine, but it crashes at startup, which is expected at this
point).
2021-03-16 18:32:04 +01:00
Rolf Bjarne Kvinge ddf1645748
[runtime] Remove unnecessary cast (#10875) 2021-03-16 15:23:58 +01:00
Rolf Bjarne Kvinge 7ac3c658e0
[tests] Preserve all test fixtures. (#10870)
* [tests] Preserve all test fixtures.

This fixes the wildly diffetent number of tests when running xammac tests with and without linking.

Without linking:

> Tests run: 2446 Passed: 2321 Inconclusive: 9 Failed: 0 Ignored: 125

vs with linking:

> Tests run: 1885 Passed: 1802 Inconclusive: 4 Failed: 0 Ignored: 83

Now we run the same tests either with or without linking.

One test was updated to not fail when linking is enabled.

Also add a test to ensure all future test fixtures are preserved.

* Remove whitespace noise.
2021-03-16 15:15:30 +01:00
Rolf Bjarne Kvinge 3087174202
[runtime] Use xamarin_gchandle_free instead of mono_gchandle_free. (#10874)
Our own functions support pointer-sized GCHandles, so this is one less place
to fix for CoreCLR.
2021-03-16 14:00:35 +01:00
Sebastien Pouliot 079b683a02
[coremidi] Add missing API for macOS (10.15+) (#10878)
The API were already available (iOS) and this helps fixing tests for
MacCatalyst (as it's based on our iOS API but expose the same issue
as macOS wrt extra ctor/init).
2021-03-16 08:35:14 -04:00
Rolf Bjarne Kvinge bc340502fe
[runtime] Move parts of NSObject creation from native to managed. (#10869)
Move the creation of an uninitialized NSObject from native to managed, which:

* Removes the need for the mono_object_new Embedding API.
* Removes one location where we write to managed memory from native code (to
  write the handle + flags in the uninitialized NSObject).
* Makes things easier for CoreCLR.
2021-03-16 07:40:19 +01:00