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

5572 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge f8314a435e
Add a [NativeName] attribute we can use to declare the native name for a type (enum/struct). (#14918)
We already have a few attributes that can specify the native name for a type, whenever the native name doesn't match the managed name:

* [Register ("DifferentClassName"): specifies the Objective-C class name
* [Native ("DifferentEnumName")]: specifies the Objective-C enum name (and also that it's a native-sized enum)
* [Protocol ("DifferentProtocolName")]: specifies the Objective-C protocol name
* [Category ("DifferentCategoryName")]: specifies the Objective-C category name

Unfortunately this leaves (at least) two cracks:

* Objective-C structs.
* Objective-C enums which aren't native-sized.

So I'm adding a [NativeName] attribute for this purpose, and updating numerous
types to specify the native name (either using an existing [Native] attribute
for enums that already have one, or by adding a new [NativeName] attribute).

The static registrar needs to know the native name for such types, in case
they appear as parameter types in function signatures.

This also allows us to simplify xtro a bit, to not have a separate map of
managed name given a native name, because we can now build that map
dynamically.
2022-05-09 22:16:17 +02:00
Steve Hawley 5631ca5c8e
[nnyeah] Start testing (#14913)
Added code to:

compile a string to a platform library
collect the output of the compilation process
check for errors
Added a single unit test of the smoke test variety.
2022-05-09 09:42:34 -04:00
Manuel de la Pena 99de095726
[XHarness] Enable nullable and fix some code issues (wrong inheritance) (#14867) 2022-05-06 17:14:00 -04:00
Chris Hamons 6a1622624a
Fix crash with NSUrl implicit conversion and null (#14860)
- Fixes: https://github.com/xamarin/xamarin-macios/issues/14786
2022-05-06 08:52:37 -05:00
Chris Hamons 7d3fd33b2a
[introspection] Fix failures on older iOS/tvOS (#14911)
- Fixes https://github.com/xamarin/xamarin-macios/issues/14905 by skipping with a link to https://github.com/xamarin/xamarin-macios/issues/14802
2022-05-06 08:51:55 +02:00
Manuel de la Pena caf68aac82
[Xharness]Enable nullability and update C# to new code patterns. (#14866)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-05-04 10:46:34 -04:00
Manuel de la Pena 0069323b6a
[Xharness] Add a label per test project to later be able to filter them. (#14844) 2022-05-04 10:46:07 -04:00
Rolf Bjarne Kvinge b72e7be297
[tests] Add two test projects to compare app size between MAUI and Xamarin.Forms. (#14850)
Add a default MAUI and a default Xamarin.Forms project as size comparison apps
(both created from templates).

This reveals that a MAUI app is ~30% bigger than a Xamarin.Forms app (42MB vs
31MB). Notably there's 21% *less* managed code, but 33% *more* native code.

https://gist.github.com/rolfbjarne/d294171969226f7511d90a817b9ac328
2022-05-03 10:54:54 +02:00
Chris Hamons 1dcefc9c56
[NET Attribute Conversion][generator] Generate NET style attributes (#14779)
This PR teaches our code generator to generate .NET 6 style availability attributes, adds a 4th Cecil test to verify our generated attributes, and a metric ton of API changes to satisfy that test.

The generator work is the core of this PR, and includes:

- Hacking out chunks of generator.cs that "helpfully" remove duplicate attributes, which are no longer duplicate in the new order that NET6 attributes force upon us. See changes in FilterMinimumVersion and PrintPlatformAttributes
- Prevent a crash when the generator processes availability attributes with no version included (example: introduced on iOS but no version). See Is64BitiOSOnly.
- The meat, GetPlatformAttributesToPrint, which synthesizes many attributes "out of thing air" from:
        - The parent context
        - Implied introduced just because the class exists on a given framework at all
        - Implied Catalyst because iOS exists
- A few cludgy hacks PrintPlatformAttributesNoDuplicates and GenerateProperty because the existing PrintPlatformAttributes did not pass down parent context down, and the refactor was dangerous/too time consuming given time pressure.

There are two intended API changes introduced by the reviews in this PR:

- GetCurrentInputDevice was obviously intended by availability attributes to exist on Catalyst but due to define confusion was excluded. It is an addition in Microsoft.MacCatalyst.dll only.
- The NEAppRule constructors were mis-marked on platforms, and were showing up incorrectly on Mac/Catalyst. I corrected the Catalyst one unconditionally, as we have not shipped Catalyst yet, but Mac is only fixed in NET6.

There is a lot of follow up work in https://github.com/xamarin/xamarin-macios/issues/14802 to do to remove a number of hard coded test failures, but this should be almost all of the remaining work in NET6 attributes.

🤞 this doesn't break too much for future us.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-05-02 09:44:25 -05:00
Manuel de la Pena 7a69d08cf0
[Xharness] Clean test task code. (#14857)
We are going to be changing code in xharness. Is a good time to clean
things a little, make code more modern then enable nullability.

Try to get as much help from the new features and try to clean alittle
debt we have from the last time we moved code.
2022-04-30 10:12:31 -04:00
TJ Lambert 6dc0eed0a8
[healthkit] Add nullability to (generated and manual) bindings (#14730)
* remove null ignores and add nullability

* throw better exception

* use is null

* remove extra ignores

* Add the tests

* use a progma ignore instead

* revert monotouch-test.csproj

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-28 11:54:23 -05:00
TJ Lambert 717b141f16
[gameplaykit] Add nullability to (generated and manual) bindings (#14615)
* adding Nullability

* throw better null exceptions

* use is null

* Added test

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-04-28 11:26:18 -05:00
TJ Lambert bd4501ac88
[naturallanguage] Add nullability to (generated and manual) bindings (#14741)
* adding nullability changes

* throwing better exceptions

* using is null

* address Rolf and Manuel nullability changes

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-26 09:50:51 -05:00
Rolf Bjarne Kvinge 50283a8b97
[static registrar] Fix lookup of block proxy attributes. (#14820)
Fix lookup of block proxy attributes to look in protocols declared on base classes.

Broken pseudo code:

    class BaseApplicationDelegate : NSObject, IUIApplicationDelegate {}
    class MyApplicationDelegate : BaseApplicationDelegate {
        [Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]
        public void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { }
    }

the static registrar wouldn't figure out that the DidReceiveRemoteNotification method
comes from the UIApplicationDelegate, because it would only look in protocols defined
on MyApplicationDelegate, not any base classes.

The fix is to look in base classes too.

Also:

* Fix a boolean logic error when matching parameters between methods in another
  (rarely used) code path when looking for matching binding methods in the extension
  class for protocols with optional members.
* Add tests.

Fixes https://github.com/dotnet/maui/issues/6259.
2022-04-26 13:47:18 +02:00
Rolf Bjarne Kvinge 042c97735c
[tests] Fix registrar tests to not return unretained INativeObjects to Objective-C. Fixes #xamarin/maccore@2572. (#14807)
We can't return unretained INativeObjects to Objective-C, because they might
be freed at any point when the GC collects the managed object. Instead return
retained objects, that way they're not freed even if the GC collects the
managed object.

This fixes a random crash in the TestRegistrar.TestINativeObject when the GC
would run just after we've returned an INativeObject to native code, and later
used that native handle thinking it would still be valid.

Fixes https://github.com/xamarin/maccore/issues/2572.
2022-04-26 07:28:50 +02:00
Eric Sink b84b80902c
Build fixes (-dotnet) for app extensions (#14685)
Resolves #14285 

1.  Make sure `libextension-dotnet.a` gets built, and with the `-DEXTENSION` flag.
2.  Make sure `libextension-dotnet.a` gets included in the package alongside `libxamarin-dotnet.a`
3. At build time, make sure to link with the correct lib[tv]extension-dotnet.a library depending when we need to.
4. Add some tests.

Co-authored-by: Eric Sink <eric@Erics-MacBook-Pro.local>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-25 16:56:52 +02:00
Rolf Bjarne Kvinge 6a43d470d9
[msbuild] Fix typo in warning message. (#14808) 2022-04-25 08:32:28 +02:00
Rolf Bjarne Kvinge 054fb36507
[tests] Set the test name for the MySimpleApp test project. (#14798)
This way the 'make run' target in this project knows what to run.
2022-04-22 07:55:29 +02:00
Rolf Bjarne Kvinge beec791bda
[tests] Add some code to try to diagnose why certain test failures aren't ignored in CI. (#14769) 2022-04-20 08:19:50 +02:00
Přemek Vysoký 1730426ec9
[Xharness] Bump Microsoft.DotNet.XHarness.iOS.Shared to `1.0.0-prerelease.22211.4` (#14743) 2022-04-14 16:10:14 -04:00
Rolf Bjarne Kvinge 254a47c440
[tests] Improve NWProtocolStackTest to not crash the process if the state change handler throws an exception. (#14697) 2022-04-11 16:38:20 -04:00
Rolf Bjarne Kvinge 2125c8febe
[tests] Make MonoTests.System.Net.Http.MessageHandlerTest handle some 504's. (#14688) 2022-04-07 18:01:25 +02:00
Chris Hamons cf77b790cb
[NET Attribute Conversion] Add missing attributes in code-behind by re-running conversion (#14660)
* [NET Attribute Conversion] Chip Framework
* [NET Attribute Conversion] Rerun with many fixes
* Fix generator crash when compiling attributes with no introduced version
* Test changes for availability re-run. One new test
2022-04-07 10:46:15 -05:00
Rolf Bjarne Kvinge 9c185e1fff
[msbuild] Ask ditto to thin native libraries according to the architectures we're targetting. Fixes #13081. (#14403)
Ask ditto to thin native libraries and frameworks when copying them to the app
bundle to remove slices for architectures we're not building for.

Also add tests.

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

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-04-07 08:17:01 +02:00
Rolf Bjarne Kvinge 1b37c48ac5
[dotnet] Add support for Mac Catalyst apps optimized interface for macOS. Fixes #14621. (#14663)
This also required bumping Xamarin.MacDev.

New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@0717ac3 Add a new device type for Mac Catalyst.
* xamarin/Xamarin.MacDev@ed2a604 Remove net451 target framework from
Xamarin.MacDev.csproj

Diff: 9e6e29f2a4..0717ac3c24

Fixes https://github.com/xamarin/xamarin-macios/issues/14621.
2022-04-07 08:14:42 +02:00
Rolf Bjarne Kvinge 6af4b9607c
[tools] Make the TargetFramework.DotNet* variables version-agnostic. (#14669)
This minimizes the code changes required for .NET 7.
2022-04-06 21:33:46 +02:00
Rolf Bjarne Kvinge a46afd0147
[tests] Use 'BundledNETCoreAppTargetFrameworkVersion' to specify the .NET version in the project files. (#14666)
This way we don't have to update all these files when moving to .NET 7.
2022-04-06 20:58:20 +02:00
Rolf Bjarne Kvinge 34dfcbf3aa
[tests] Stop hardcoding system assembly version number in linker tests. (#14668)
Another step towards .NET 7.
2022-04-06 17:57:39 +02:00
Chris Hamons d51bd343f7
Add nullability on one UndoManager API (#14653)
- Fixes https://github.com/xamarin/xamarin-macios/issues/14646
- I checked UIDocument and AppKit versions and those are not nullable.
2022-04-06 10:43:29 -05:00
Rolf Bjarne Kvinge 3d904dae2c
[tests] A few test fixes to make testing system installs better. (#14652)
* Make the custom-type-assembly library build using assemblies relative to
  MAC_DESTDIR, instead of poking into $(TOP)/_mac-build (for legacy Xamarin).
* Build the custom-type-assembly using a project file for .NET (and use our
  local .NET).
* Change the default for [IOS|MAC]_DESTDIR when TESTS_USE_SYSTEM is set to
  point to the system installation.
* Make sure 'MSBuildSDKsPath' isn't set when building the custom-type-assembly
  (set by xibuild), it breaks a lot of things.
2022-04-06 08:35:25 +02:00
Alex Soto 132d5694d6
[ScreenCaptureKit] Add ScreenCaptureKit bindings up to Xcode 13.3 (#14644)
* [ScreenCaptureKit] Add ScreenCaptureKit bindings up to Xcode 13.3

* Use more appropriate exceptions.

* Remove ScreenCaptureKit from Mac Catalyst.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-05 20:16:31 -04:00
Rolf Bjarne Kvinge 906b94cb00
[mmptest] Fix resolving paths to required test files. Fixes #xamarin/maccore@2560. (#14566)
* Fix resolving paths to required test files (test files can be found relative to the root path of the repository, not relative to where Xamarin.Mac is installed)
* Don't try to sign symlinks - we can end up trying to sign the target of the symlink twice simultaneously.
* Fix finding libxammac.dylib and Xamarin.Mac.dll when testing a system installation (when MAC_DESTDIR or TESTS_USE_SYSTEM are set).
* Remove a few .NET tests we don't need anymore.

Fixes https://github.com/xamarin/maccore/issues/2560.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-05 14:30:35 +02:00
Rolf Bjarne Kvinge 277baaf521
[tests] Request labels after each test from NUnit. (#14628)
Fixes this NUnit warning:

> labels=All is deprecated and will be removed in a future release. Please use labels=Before instead.

We don't follow the suggestion from the warning, because the advantage of
writing the label after each test is that the test result will also be
printed, which means it's possible to see if any tests failed during the test
run, as opposed to having to wait until the entire test run is completed
(which can take a while) to realize that pretty much every test failed with
some silly mistake which could have been quickly fixed before re-running the
tests.
2022-04-04 19:19:45 +02:00
Rolf Bjarne Kvinge 42d561c623
[tests] Execute tests on older macOS bots with a timeout. (#14593)
This prevents a single test hang from breaking the entire test run.

Also bump timeout to 45 minutes.
2022-04-04 19:16:48 +02:00
Chris Hamons 612c32ca20
[metalperformanceshaders] Add one troublesome missing method (#14557)
- Fixes https://github.com/xamarin/xamarin-macios/issues/14450
- There is a significant amount of additional bindings to be done, but this way
we at least get the trivia one in now.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-04 11:08:55 -05:00
Rolf Bjarne Kvinge 6e348f0e65
[dotnet] Port the iOS tabbed app template to .NET. (#14592)
Ref: https://github.com/xamarin/xamarin-macios/issues/10747
2022-04-04 10:05:08 +02:00
Rolf Bjarne Kvinge 06140f1712
[tests] Adjust the Xamarin.Tests.Misc.PublicSymbols test to accept Brotli-related symbols. (#14605)
Our latest mono bump (in fd772aa82b), brought in
these new public symbols. Accept them for now, but hopefully we'll be able to
make them private at some point.

Fixes https://github.com/xamarin/xamarin-macios/issues/14604.
2022-04-04 09:55:05 +02:00
Rolf Bjarne Kvinge 53fdca45c8
[tests] Fix dependencies to build the mtouch tests. (#14606)
The corresponding project was renamed some time ago, but not all places that
used the derived Make variable were updated at the same time as they should
have been.
2022-04-04 09:53:08 +02:00
Manuel de la Pena 46af411d1c
[Foundation] Allow null parameters when creating a NSUrl from a string. (#14603)
The headers do not say that a null parameter is allowed, but the
documentation and tests state otherwise:

https://developer.apple.com/documentation/foundation/nsurl/1572047-urlwithstring

The URL string with which to initialize the NSURL object. Must be a URL that conforms to RFC 2396. This method parses URLString according to RFCs 1738 and 1808.
2022-04-02 15:13:52 -04:00
Rolf Bjarne Kvinge e191c613ce
[Foundation] Enable nullability in NSUrlSessionHandler. (#14597) 2022-04-01 14:48:57 +02:00
Rolf Bjarne Kvinge 1c4a64c0c4
[EventKitUI] Add this framework to Mac Catalyst. (#14374)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-01 14:29:30 +02:00
Rolf Bjarne Kvinge 08978fa4b1
[dotnet] Rename hardcoded 'net6.0' to use a 'DOTNET_TFM' variable instead. (#14524)
This makes things easier for .NET 7.
2022-04-01 13:48:09 +02:00
Rolf Bjarne Kvinge 0887599ccb
[cecil-tests] Enable previously disabled tests. (#14587)
Looks like these might be fixed now.

Fixes https://github.com/xamarin/maccore/issues/2547.
2022-04-01 07:22:27 +02:00
Rolf Bjarne Kvinge 7b16e71349
[tests] Ignore the BindingLibraryDSymCreated test until we've fixed the underlying issue. (#14599) 2022-04-01 07:20:54 +02:00
Rolf Bjarne Kvinge 23737939db
[CarPlay] Ignore this framework on Mac Catalyst. (#14381)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-31 14:20:50 +02:00
Rolf Bjarne Kvinge 77bac878d6
[IdentityLookupUI] Add this framework to Mac Catalyst. (#14385)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-31 14:20:08 +02:00
Rolf Bjarne Kvinge e687c20dd6
[AppClip] Add this framework to Mac Catalyst. (#14378)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-31 13:52:52 +02:00
Rolf Bjarne Kvinge 7cfc86d159
[CoreLocationUI] Add this framework to Mac Catalyst. (#14382)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-31 12:49:34 +02:00
Rolf Bjarne Kvinge 38528043d1
[AddressBookUI] Ignore this framework on Mac Catalyst. (#14377)
It exists, and is apparently usable, but it's already deprecated (and it's been deprecated on iOS for a while):

"Do not use the AddressBookUI framework in iOS 9 and later. Use the APIs defined in the Contacts UI framework instead."

Ref: https://developer.apple.com/documentation/addressbookui

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-31 11:17:03 +02:00
Rolf Bjarne Kvinge 209942854f
[WatchConnectivity] Ignore this framework on Mac Catalyst. (#14384)
I'm not sure if WatchConnectivity is of any use on Mac Catalyst,
so until proven it's useful, ignore it.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-31 10:54:29 +02:00