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

30 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 34d1fca7f6
[StoreKit] Bind AppStore.requestReview. Fixes #21410. (#21441)
The existing Objective-C class to request an App Store review (SKStoreReviewController) is deprecated in Xcode 16+, and it doesn't even work on the corresponding OS versions.

The replacement API is Swift-only, but luckily it's a very simple API (just a static method), so it's possible to bind it manually.

This required a few other changes/improvements:

* Add support for Swift code in our runtime.

* Just to keep the changes to a minimum, bump the min OS version for legacy code to match the .NET min OS versions. This is because our build logic uses the legacy min versions when compiling native code (a more involved fix would be to update all the build logic to build native code to use the .NET min OS versions, but that's not the point of this PR, so I took the easy route). Fixes #10659.

I've tested the method locally, and it seems to work fine, but I've still marked
it as experimental for now. There are no unit tests because calling the method will
put up a dialog, which won't work correctly in unit tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/21410.
Fixes https://github.com/xamarin/xamarin-macios/issues/10659.
2024-10-16 11:06:47 +02:00
Rolf Bjarne Kvinge d99f6f8fa9
[AppKit/UIKit] Implement Xcode 16.0 beta 1-6 changes. (#21130) 2024-09-11 16:48:52 +02:00
Rolf Bjarne Kvinge 6aca92cd74
[Metal] Implement Xcode 16.0 beta 1-6 changes. (#20895)
Note: there were no changes in beta 3, beta 4 or beta 5.
2024-09-09 19:42:49 +02:00
Rolf Bjarne Kvinge f3a7879a28
[CloudKit] Implement Xcode 16.0 beta 1-6 changes. (#20861)
The bindings that have been removed haven't fully been removed from the
headers, but it looks like they will be soon. These bindings have also been
deprecated since before the earliest OS versions we support, so there should
be no need to keep them around.

Removing them preemptively also lessens the risk of running into App Store
rejections in the future.

A few tests changes were needed to ignore the newly obsoleted/hidden APIs.

Note: there were no changes in beta 2, beta 3, beta 4, beta 5 or beta 6.
2024-08-23 16:44:32 +02:00
Rolf Bjarne Kvinge e9d59d5f58
[bgen] Implement support for using default interface members to bind protocols. (#20681)
Given the following API definition:

```cs
[Protocol]
public interface Protocol {
    [Abstract]
    [Export ("requiredMethod")]
    void RequiredMethod ();

    [Export ("optionalMethod")]
    void OptionalMethod ();
}
```

we're now binding it like this:

```cs
[Protocol ("Protocol")]
public interface IProtocol : INativeObject {
    [RequiredMember]
    [Export ("requiredMethod")]
    public void RequiredMethod () { /* default implementation */ }

    [OptionalMember]
    [Export ("optionalMethod")]
    public void OptionalMethod () { /* default implementation */ }
}
```

The main difference from before is that the only difference between required
and optional members is the [RequiredMember]/[OptionalMember] attributes.

This has one major advantage: it's now possible to switch a member from being
required to being optional, or vice versa, without breaking neither source nor
binary compatibility.

It also improves intellisense for optional members. In the past optional
members were implemented using extension methods, which were not very
discoverable when you were supposed to implement a protocol in your own class.

The main downside is that the C# compiler won't enforce developers to
implement required protocol members (which is a necessary side effect of the
fact that we want to be able to switch members between being required and
optional without breaking compatibility). If this turns out to be a problem,
we can implement a custom source analyzer and/or linker step that detects
missing implementations and issue warnings/errors.

This PR also:

* Adds numerous tests.
* Updates the requiredness of a few members in Metal to test that it works as
  expected.
* Adds documentation.
* Handles numerous corner cases, which are documented in code and docs.

This PR is probably best reviewed commit-by-commit.

Fixes https://github.com/xamarin/xamarin-macios/issues/13294.
2024-06-07 16:35:48 +02:00
Rolf Bjarne Kvinge 0e42551756
[tests] Port the ModelMustBeProtocol test from monotouch-test to cecil-test. (#19561)
It uses reflection, so it upsets NativeAOT, so just move it to cecil-test instead.

This will make it run faster, and also more predictable (it's supposed to
check all types, but types in monotouch-test may have been linked away).

Ref: https://github.com/dotnet/runtime/issues/95444
2023-12-04 08:25:07 +01:00
Rolf Bjarne Kvinge cfa2734a3a Merge remote-tracking branch 'origin/main' into bump-main-in-net8.0-2023-03-14 2023-03-23 15:33:43 +01:00
Rolf Bjarne Kvinge 999c5a3e97
[tests] Share code to verify failures. (#17872)
We have some code that verifies a list of failures against a known set of
failures and:

* Fails if any known failure is fixed.
* Fails if there any new (unknown) failures.

Create a helper method that contains this logic, since it's duplicated quite a
few times across various tests.
2023-03-22 11:47:54 +01:00
Rolf Bjarne Kvinge 7f52b11753 [cecil-tests] Remove a known failure that's been fixed now. 2023-02-03 09:10:47 +01:00
Rolf Bjarne Kvinge 50c01fe10c
[generator] Fix an issue where we'd not copy attributes from inlined protocols. (#17381)
Protocols with one set of introduced attributes ([TV (12, 0)]) inlined in
types that were introduced in a different version ([TV (10, 0)]) would always
use the attributes from the type.

This is wrong if the protocol was introduced after the type, in which case we
should instead use the introduced attributes from the protocol.

Fix this by choosing the latest introduced attribute when we have multiple to
choose from.

This required passing a bit more information around so that we always know if
a member is being inlined in another type.

This PR will also print availability attributes on the protocol members themselves:

	[Protocol]
	interface IProtocol
	{
		[TV (12, 0)] // this was not printed before
		[Export ("someProperty")]
		string SomeProperty { get; set; }
	}

Also add and improve some tests.

Contributes towards https://github.com/xamarin/xamarin-macios/issues/14802.
2023-01-30 08:00:06 +01:00
Rolf Bjarne Kvinge 688fa45856
[tests] Improve the AttributeTest.FindSupportedOnElementsThatDoNotExistInThatAssembly cecil test. (#17367)
* Fix an issue where it would not compute the correct grouping key for each member,
  effectively grouping unrelated members together and coming up with weird and incorrect
  results.
* Make it match failures exactly, which makes it possible to detect (and report,
  which it now does) when a known failure is fixed.
* Ignore any hidden members (EditorBrowsableState.Never), because they're most
  likely mistakes.
* Ignore any members in AppKit and UIKit, because these namespaces have a lot of
  conflicting availability attributes. This is tracked in a separate bug (#17292).

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-01-25 20:55:28 +01:00
Rolf Bjarne Kvinge e3f549fc7e
[tests] Improve cecil-tests's member filtering API. (#17001)
* Improve these methods to find members inside nested types as well.
* Simplify their implementation somewhat.
* Make the filter method optional to allow enumerating everything.
* Rename these methods to Enumerate* to better express what they do.
* Make them extension methods on AssemblyDefinition to make them more
  discoverable and easier to use.
2022-12-13 17:09:45 +01:00
Rolf Bjarne Kvinge 081505b173
[tests] Improve perf in cecil-tests by only loading assemblies once. (#16997)
Improve perf in cecil-tests by caching loaded assemblies, and thus only
loading them once. The gain isn't all that much - it saves about 3s of ~2m on
my machine, so ~1.5% faster - but it'll be more and more important as we write
more tests. Also the code becomes slightly simpler too.
2022-12-13 09:23:25 +01:00
Israel Soto d910c1ba60
[GameController] Added support to Xcode 14.1 b1 (#16094)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-10-13 11:42:52 -04:00
Israel Soto 9543d817f4
[MapKit] Add support for Xcode 14 beta 1 & 2 & 5 (#15562) 2022-10-12 12:10:01 -04:00
Alex Soto 27e6958b0a
[xcode14.1] Bump to Xcode 14.1 Beta 3 (#16010)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-10-03 17:24:41 +02:00
GitHub Actions Autoformatter 14f7a23833 Auto-format source code 2022-09-26 20:49:33 +00:00
Rolf Bjarne Kvinge 9c3458dc33 Merge main into xcode14.1. 2022-09-26 22:46:59 +02:00
Rolf Bjarne Kvinge deb0faa4f2
Autoformat cecil-tests.csproj. (#16103)
All other changes should be blank space only.

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2022-09-26 21:00:28 +02:00
Rolf Bjarne Kvinge f4d5e6eeab Merge main into xcode14.1. 2022-09-22 07:50:58 +02:00
Rolf Bjarne Kvinge 8e92e9e5c5
[tests] Ignore tests that require platforms not included in the current build. (#16000) 2022-09-22 07:33:42 +02:00
Manuel de la Pena b99f35a800
[AuthenticationServices] Add support for Xcode 14 beta 4. (#15604)
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-09-07 11:11:34 -04:00
Manuel de la Pena e95ae331e3
[Mediaplayer] Add support for xcode14 beta 4. (#15654)
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-08-26 10:38:21 -04:00
Chris Hamons 3c359f5838
[foundation] Xcode 13 & Xcode 14 beta 1-3 bindings (#15579)
- Xcode 13 section Based upon https://github.com/xamarin/xamarin-macios/pull/13328- 
- Some disabled due to https://github.com/xamarin/maccore/issues/2608
2022-08-01 10:22:39 -05:00
Rolf Bjarne Kvinge 82482edc70
[cecil-tests] Improve these tests a bit. (#14994) 2022-05-13 20:50:02 +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
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 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 e25163f573
[.NET] Rename our product assemblies. Fixes #13748. (#13847)
Rename our product assemblies to:

* Microsoft.iOS.dll
* Microsoft.tvOS.dll
* Microsoft.macOS.dll
* Microsoft.MacCatalyst.dll

This makes it easy to distinguish between legacy Xamarin and .NET whenever the
product assembly is mentioned, and I've also chosen the platform part of the
name to match how the platforms are named elsewhere (this also makes it
possible to simplify our build logic, since we can remove a lot of special
casing).

Fixes https://github.com/xamarin/xamarin-macios/issues/13748.
2022-02-16 21:30:32 +01:00
Chris Hamons 39d52ba64f
[tests] Add disabled NET6 availability attribute test (#14106) 2022-02-11 09:11:02 -06:00