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

5084 Коммитов

Автор SHA1 Сообщение Дата
Chris Hamons ab5c0c6b56
[net6] Fix ILStrip'ed apps to actually work again (#13098)
* [net6] Fix ILStrip'ed apps to actually work again

- In a late minute change to the ILStrip PR (https://github.com/xamarin/xamarin-macios/pull/12563) a change to support XVS support broke execution of Apps that were stripped
- Applications were broken because none of the stripped assemblies were actually copied into the bundle
- However, the tests still passed, because all assemblies that were there had no IL (zero assemblies total)

Now why did this happen?
- The stripped assemblies were changed to return via an msbuild Output Element
- Output Element can return an Property or ItemGroup, depending if you use the PropertyName or ItemName attributes
- Unfortunately I used PropertyName, when I expected an ItemGroup. So I silently had a property created instead.
- Thus zero items were added to the list of files to copy into the bundle
- Which was undetected as the test did not confirm files were copied in, and manual tests were not run so late into the PR (3 weeks after PR was opened)

How was it fixed?
- Correctly using ItemName on Output created a valid item group to reference
- However, that still failed with an absurdly confusing error:

 PATH/Microsoft.NET.Publish.targets(277,5): error MSB3024: Could not copy the file FILE to the destination file PATH, because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.

- After a splunking through netcore targets, I found the metadata on these assemblies references really matters. Without it, they are not processed correctly at all.
- Thus, I updated ILStripBase to clone the existing metadata when changing the original assembly reference to the stripped path
- Finally, I corrected the test to assert that required files are copied in. I also manually ran our device test.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-10-25 11:31:42 -05:00
Rachel Kang 5d09fd774e
Merge pull request #13080 from rachelkang/cat_corewlan
[CoreWLAN] Updates for Catalyst
2021-10-25 10:44:47 -04:00
Rachel Kang 8ab022e8f0
Merge pull request #13097 from rachelkang/cat_uikit
[UIKit] Updates for Catalyst
2021-10-25 10:44:20 -04:00
Rolf Bjarne Kvinge dbe31e91df
[CFType] Subclass NativeObject + a few other code updates (#13086)
* Subclass NativeObject to reuse object lifetime code. This isn't for CFType
  itself, but all its subclasses.
* Add a public default constructor to maintain compat, but remove it for XAMCORE_4_0.
* Add an internal (IntPtr, bool) constructor to follow the NativeObject pattern.
* Enable nullability and fix code accordingly.
* Use CFString.CreateNative/ReleaseNative instead of other means to create
  native strings (the fastest and least memory hungry option).
* Use 'nameof (parameter)' instead of string constants.
2021-10-25 15:19:00 +02:00
Rachel Kang e8c066b123
[UIKit] Updates for Catalyst 2021-10-22 17:28:32 -04:00
Rachel Kang 3b1df5b27f
Merge pull request #13076 from rachelkang/cat_printcore
[PrintCore] Updates for Catalyst
2021-10-22 11:14:20 -04:00
Rachel Kang 410237ff14
Merge pull request #13056 from rachelkang/xcode13.0-intentsui-b1-b4
[IntentsUI] Update bindings for Xcode13.0 betas 1, 4
2021-10-22 11:02:05 -04:00
Rolf Bjarne Kvinge af23d61926
[runtime] Fix a toggle ref deadlock when retaining objects. Fixes #13066. (#13071)
The deadlock goes like this:

1. Thread A holds the framework_peer_release_lock lock, and tries to lock the
   refcount_mutex lock.
2. Thread B holds the refcount_mutex, and is waiting for the GC to complete
3. Thread C is trying to lock the framework_peer_release_lock while running
   the GC.

The fix is in thread A, by not doing anything at all with the
framework_peer_release_lock lock locked.

The code contains extensive comments explaining the situation and the solution.

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

Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
2021-10-22 09:05:07 +02:00
Rachel Kang f708a4e9da
[CoreWLAN] Updates for Catalyst 2021-10-21 16:03:25 -04:00
Rolf Bjarne Kvinge a862d505de
[CFBundle] Subclass NativeObject + numerous other code updates (#13041)
* Subclass NativeObject to reuse object lifetime code.
* Enable nullability and fix code accordingly.
* Use 'is' and 'is not' instead of '==' and '!=' for object identity.
* Use CFString.CreateNative/ReleaseNative instead of other means to create native
  strings (the fastest and least memory hungry option).
* Use 'nameof (parameter)' instead of string constants.
* Call 'GetCheckedHandle ()' (which will throw an ObjectDisposedException if
  Handle  == IntPtr.Zero) instead of manually checking for IntPtr.Zero and throwing
  ObjectDisposedException.
* Use CFArray helper methods to create arrays (and implement some helper methods
  that didn't exist).
* Add a few tests for the new CFArray helper methods.
2021-10-21 18:04:08 +02:00
Rachel Kang f1ff6ae0cb
Merge pull request #13062 from rachelkang/cat_security
[Security] Updates for Catalyst
2021-10-21 10:49:30 -04:00
Rachel Kang 39ca46b58f
[PrintCore] Updates for Catalyst 2021-10-21 10:36:54 -04:00
Rachel Kang 9bb7267b72
[UserNotifications] Updates for Catalyst (#13057) 2021-10-21 10:12:48 -04:00
Rachel Kang a392357eb0
[Security] Updates for Catalyst 2021-10-20 17:34:11 -04:00
Rolf Bjarne Kvinge 808419f3c3
[tests] Fix the name of monotouchtest. (#13042)
Fix the name of monotouchtest, so that the app/executable is found by the
makefile when trying to execute the test.
2021-10-20 21:17:55 +02:00
Rachel Kang 56b454a8cb
[IntentsUI] Update bindings for Xcode13.0 betas 1,4 2021-10-20 14:33:42 -04:00
Rachel Kang 861c40dbe4
Merge pull request #12990 from rachelkang/cat_networkextension
[NetworkExtension] Updates for Catalyst
2021-10-19 12:26:48 -04:00
Rachel Kang 4c2c4a38d4
Merge pull request #12978 from rachelkang/cat_executionpolicy
[ExecutionPolicy] Updates for MacCatalyst
2021-10-19 10:24:55 -04:00
Rachel Kang 8670f235c5
Merge pull request #12980 from rachelkang/cat_ituneslibrary
[iTunesLibrary] Updates for MacCatalyst
2021-10-19 10:24:34 -04:00
Rachel Kang 9dd375f179
Merge pull request #12991 from rachelkang/cat_videotoolbox
[VideoToolbox] Updates for Catalyst
2021-10-19 10:24:10 -04:00
Rachel Kang 3eea624ebb
Merge pull request #12971 from rachelkang/cat_medialibrary
[MediaLibrary] Update MacCatalyst Support
2021-10-19 10:23:41 -04:00
Alex Soto 78c367749a
[xcode13.1-rc] Bump macios to use Xcode 13.1 RC (#13025) 2021-10-19 09:30:44 +02:00
Rolf Bjarne Kvinge 60c20decf0
[tests] Fix LinkSdkRegressionTest.SpecialFolder on macOS 10.14. (#13004) 2021-10-19 08:16:21 +02:00
Rolf Bjarne Kvinge 6d065a7dcc
[tests] Minor fixes wrt executing packaged macOS tests. (#12982)
* Don't execute .NET tests in the 'legacy' targets (it's wasteful because
  we're already executing those .NET tests elsewhere).
* Fix reporting failures in the legacy tests.
2021-10-18 07:30:36 +02:00
Rolf Bjarne Kvinge 56892d996d
[src] Rename MAC_* variables to MACOS_* variables. (#12998)
This makes it easier to iterate over the platforms we're building for, because
we can use "macOS" to compute the variable names we're interested in (like we
already can for iOS, tvOS, watchOS and MacCatalyst).
2021-10-18 07:24:37 +02:00
Rachel Kang 72dc7f5d01
[NetworkExtension] Updates for Catalyst 2021-10-14 12:11:10 -04:00
Rachel Kang 6041aad59b
[VideoToolbox] Updates for Catalyst 2021-10-13 16:40:09 -04:00
Rachel Kang a8b0c29cc2
[iTunesLibrary] Updates for MacCatalyst 2021-10-12 17:25:07 -04:00
Rachel Kang d657af6ba9
[ExecutionPolicy] Updates for MacCatalyst 2021-10-12 14:59:39 -04:00
Rachel Kang 6e43ee83f1
[MediaLibrary] Update MacCatalyst Support 2021-10-11 14:38:17 -04:00
Rolf Bjarne Kvinge 3c2c3d062d
[generator] Fix the return type for blocks returning a type we've bound as an INativeObject. (#12941)
* Create all INativeObject subclasses using 'Runtime.GetINativeObject<T>' instead
  of 'new T ()'. Although it's somewhat slower, it automatically handles any IntPtr.Zero
  handles, and it also makes the generator code simpler. If something turns out to
  be a performance problem, we can always add custom static creation methods (like
  some of the existing types already have).

* This makes it so that the zero pointer check logic in the generator isn't necessary
  anymore.

* The most important part is where we use IntPtr as the marshalling type for returned
  INativeObjects in blocks (instead of the INativeObject class - which doesn't make
  sense really, because I have no idea how that's marshalled).

Example:

```diff
diff --git a/build/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs b/build-new/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs
index 97e58f3a91b..8a40748de8b 100644
--- a/build/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs
+++ b/build-new/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs
@@ -214,7 +214,7 @@ namespace ObjCRuntime {
    } /* class NIDAVAudioEngineManualRenderingBlock */
    [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
    [UserDelegateType (typeof (global::AVFoundation.AVAudioIONodeInputBlock))]
-   internal delegate global::AudioToolbox.AudioBuffers DAVAudioIONodeInputBlock (IntPtr block, uint frameCount);
+   internal delegate IntPtr DAVAudioIONodeInputBlock (IntPtr block, uint frameCount);
    //
    // This class bridges native block invocations that call into C#
    //
@@ -223,11 +223,11 @@ namespace ObjCRuntime {
      [Preserve (Conditional = true)]
      [global::System.Diagnostics.CodeAnalysis.DynamicDependency ("Handler")]
      [MonoPInvokeCallback (typeof (DAVAudioIONodeInputBlock))]
-     static unsafe global::AudioToolbox.AudioBuffers Invoke (IntPtr block, uint frameCount) {
+     static unsafe IntPtr Invoke (IntPtr block, uint frameCount) {
        var descriptor = (BlockLiteral *) block;
        var del = (global::AVFoundation.AVAudioIONodeInputBlock) (descriptor->Target);
        AudioToolbox.AudioBuffers retval = del (frameCount);
-       return retval;
+       return retval.GetHandle ();
      }
    } /* class SDAVAudioIONodeInputBlock */
    internal sealed class NIDAVAudioIONodeInputBlock : TrampolineBlockBase {
@@ -249,7 +249,7 @@ namespace ObjCRuntime {
      [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
      unsafe global::AudioToolbox.AudioBuffers Invoke (uint frameCount)
      {
-       var ret = invoker (BlockPointer, frameCount);
+       var ret = Runtime.GetINativeObject<global::AudioToolbox.AudioBuffers> (invoker (BlockPointer, frameCount), false);
        return ret!;
      }
    } /* class NIDAVAudioIONodeInputBlock */
```
2021-10-11 19:13:17 +02:00
Rachel Kang f6b344946c
[PushKit] Update PushKit MacCatalyst (#12957) 2021-10-08 16:17:05 -04:00
Rolf Bjarne Kvinge 4f613f4c9d
[xharness] Don't copy xharness.[css|js] to the output directory when they're already in the output directory. (#12958)
The problem is that cleaning the project would then remove these files, which
would break the next build.
2021-10-08 16:31:52 +02:00
Rolf Bjarne Kvinge 6d8ef62705
[AVFoundation] Fix a few issues with AudioUnit. (#12954)
* Add an (IntPtr, bool) constructor so that AudioUnit works with Runtime.GetINativeObject.
* Keep track of ownership, so that AudioUnit doesn't free the native resources
  when it doesn't own them.
* Update a test to verify that calling 'AVAudioIONode.AudioUnit' multiple
  times and disposing the result between them works (this fails if AudioUnit
  doesn't keep track of ownership).
2021-10-08 07:52:40 +02:00
Rolf Bjarne Kvinge b9de02c457
[introspection] Skip verifying the objc_msgSend[Super]_stret on all platforms. (#12939)
Now that macOS runs on ARM64 (and also the simulators soon), we need to have to same logic for all platforms.

Fixes:

    Introspection.iOSApiPInvokeTest
        [FAIL] Could not find the field 'objc_msgSend_stret' in /usr/lib/libobjc.dylib
        [FAIL] Could not find the field 'objc_msgSendSuper_stret' in /usr/lib/libobjc.dylib
        [FAIL] SymbolExists :   2 errors found in 5300 functions validated: objc_msgSend_stret, objc_msgSendSuper_stret
            Expected: 0
            But was:  2
                at Introspection.ApiPInvokeTest.SymbolExists() in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/introspection/ApiPInvokeTest.cs:line 182
2021-10-07 20:15:54 +02:00
Rachel Kang 9ebf14e85b
Merge pull request #12936 from rachelkang/xcode13.0-appkit-b1-b2-b3-b4-b5
[AppKit] Update Xcode 13.0 bindings for betas 1,2,3,4,5
2021-10-07 13:14:59 -04:00
Rolf Bjarne Kvinge 694ec2d0b3
[tests] Ignore TemplateProjectTest.CreateAppBundleDependsOnTest when the specified platform isn't included in the build. (#12933) 2021-10-07 09:10:16 +02:00
Rolf Bjarne Kvinge 6b27debb63
[tests] Bump our generic min macOS version to 10.14 for .NET tests. (#12938)
Fixes this when running our test suites on macOS 10.14:

    dyld: Library not loaded: /System/Library/Frameworks/AuthenticationServices.framework/Versions/A/AuthenticationServices
      Referenced from: /Users/runner/work/1/s/artifacts/mac-test-package/tests/./introspection/dotnet/macOS/bin/Debug/net6.0-macos/osx-x64/introspection.app/Contents/MacOS/introspection
      Reason: image not found
    make[2]: *** [exec-mac-dotnet-x64-introspection] Abort trap: 6
2021-10-07 09:09:46 +02:00
Rolf Bjarne Kvinge f12d09f405
[msbuild] Share the CompileEntitlements task implementation between iOS and macOS. (#12946) 2021-10-07 08:17:50 +02:00
Rolf Bjarne Kvinge afff63f04d
[tests] Fix make variables usage in template code. (#12940) 2021-10-06 18:54:27 +02:00
Rolf Bjarne Kvinge 63de01c21c
[tests] Fix packaging of Xamarin.Mac tests. (#12776)
I recently deleted the generated makefile support for building and running our
test suites. It turned out that it was used for building the packaged
Xamarin.Mac tests, so it wasn't as unused as I thought.

So fix the building and packaging of Xamarin.Mac tests to not use the
(non-existent) makefile targets, but instead replicate it with manual make
code.

Also take the opportunity to add packaging and execution of the .NET versions
of these test suites we execute on other macOS versions (both for macOS and
the Mac Catalyst).

* [devops] Use stricter matching when finding the Xamarin.Mac pkg link.

Otherwise the branch name in any package could end up matching the pattern we
were looking for:

	XM_PACKAGE=https://bosstoragemirror.blob.core.windows.net/wrench/tests-package-xamarin-mac-tests/15759261d425ae08494b0a26862a0b1356c5f8ec/5268864/package/Microsoft.iOS.Bundle.15.0.101-ci.tests-package-xamarin-mac-tests.68.pkg

is just clearly wrong.
2021-10-06 08:10:07 +02:00
Chris Hamons dade24c63a
Catalyst changes for CoreAnimation, CoreFoundation, and AVKit (#12926) 2021-10-05 16:42:37 -05:00
Manuel de la Pena 67e1ca5459
[Metal] Add support for xcode 13 beta5 . (#12875)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-10-05 13:32:48 -04:00
Rolf Bjarne Kvinge f1e4cbcfcd
[tests] Modify a few test directories with multiple projects to have the projects in subfolders. (#12921)
This fixes a problem where the build from the different projects could stomp
on eachother in the obj/bin folders. It's technically possible to make this
work by setting up custom [Base][Intermediate][OutputPath] properties in the
project files, but the simplest solution is to just make sure there's no more
than a single project per directory.
2021-10-05 18:06:35 +02:00
Chris Hamons 9230c798a9
[UIKit] Add Catalyst support (#12809) 2021-10-05 11:04:44 -05:00
Rachel Kang 517fbd9a02
[AppKit] Update Xcode 13.0 bindings for betas 1,2,3,4,5 2021-10-05 11:59:49 -04:00
Chris Hamons a300dfc56b
[msbuild] Add ILStrip'ing for net6 applications. Fixes #11445. (#12563)
- Controlled by EnableAssemblyILStripping which defaults to true
- Integration test included

Before - https://gist.github.com/chamons/c7886f7bacbc2e5ac5966e4251d13e71
After - https://gist.github.com/chamons/148e1bef22fa336f953f3d02dcf20667

859,136 -> 527,872 managed

Fixes https://github.com/xamarin/xamarin-macios/issues/11445.
2021-10-05 09:43:22 -05:00
Rolf Bjarne Kvinge b772397b63
[msbuild] Share the BTouch task implementation between iOS and macOS. (#12873) 2021-10-04 08:18:47 +02:00
Rolf Bjarne Kvinge 62bdd683cf
[dotnet] Add support for 'dotnet pack'. Fixes #12631. (#12900)
Add support for 'dotnet pack', by:

1. Add a workaround for the fact that as soon as a project has a
   'NativeReference' item, .NET's MSBuild logic wants to include a
   'Native.$(AssemblyName).manifest' file in the NuGet. This obviously breaks,
   because we don't create such a file, so we work around it by removing the
   file in question from the corresponding item groups.

2. Add any binding resource packages to the NuGet.

3. Add tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/12631.
2021-10-04 07:43:55 +02:00
Rolf Bjarne Kvinge 43d894da15
[msbuild/tools] Augment the CreateBindingResourcePackage to support creating a zipped binding resource package. (#12868)
Augment the CreateBindingResourcePackage to support creating a zipped binding
resource package (which is just a zipped version of the binding resource
package). This can either be manually chosen by the new 'Compressed' property,
or automatically detected (create a zipped version when there's a symlink in
the binding resource package).

The default is to not create a zipped version in legacy Xamarin, and
automatically detect for .NET.

The problem this is trying to solve is when creating a NuGet package - NuGet
doesn't handle symlinks correctly and it's not possible to create a NuGet with
symlinks. Instead we need to create a zipfile with all the binding resources.
The default has been chosen so that we automatically create a zip file when
it's required for .NET, while still maintaining old behavior with legacy
Xamarin.
2021-10-01 08:40:01 +02:00