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

281 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge e7586e4411 [net9.0] Merge main into net9.0. 2024-06-12 15:08:25 +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 7e9abebc8e Merge remote-tracking branch 'origin/main' into bump-main-in-net9.0-2024-06-05 2024-06-06 11:03:04 +02:00
Rolf Bjarne Kvinge 7670afb6aa
[src/docs] Add xml documentation for types. (#20672)
Import all the xml documentation for types from https://github.com/xamarin/apple-api-docs.

Some of this documentation should probably be rewritten, and potentially moved
to conceptual documentation, in particular those that contain images (because
images can't be imported into xml documentation).

Note that the documentation hasn't been modified in any way; that's not the purpose of this PR. If documentation should be modified for whatever reason, it can be done in a later PR.

The xml documentation for members will come in a later PR.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/17399.
2024-06-06 07:37:52 +02:00
Rolf Bjarne Kvinge 0e537376a4 [net9.0] Merge main into net9.0. 2024-06-05 17:23:29 +02:00
Rolf Bjarne Kvinge 7b3ad09aac
[bgen] Add support for binding static members in protocols. (#20645)
Add support for binding static members in protocols.

Given the following API definition:

```cs
[Protocol]
public interface Protocol {
    [Abstract]
    [Static]
    [Export ("requiredStaticMethod")]
    void RequiredStaticMethod ();

    [Static]
    [Export ("optionalStaticMethod")]
    void OptionalStaticMethod ();

    [Abstract]
    [Static]
    [Export ("requiredStaticProperty")]
    IntPtr RequiredStaticProperty { get; set; }

    [Static]
    [Export ("optionalStaticProperty")]
    IntPtr OptionalStaticProperty { get; set; }
}
```

we're binding it like this:

```cs
[Protocol ("Protocol")]
public interface IProtocol : INativeObject {
    [Export ("requiredStaticMethod")]
    public static void RequiredStaticMethod<T> () where T: NSObject, IProtocol { /* implementation */ }

    [Export ("optionalStaticMethod")]
    public static void OptionalStaticMethod<T> () where T: NSObject, IProtocol { /*  implementation */ }

    [Property ("RequiredStaticProperty")]
    [Export ("requiredStaticProperty")]
    public static IntPtr GetRequiredStaticProperty<T> () where T: NSObject, IProtocol { /* implementation */ }

    [Property ("RequiredStaticProperty")]
    [Export ("setRequiredStaticProperty:")]
    public static void SetRequiredStaticProperty<T> (IntPtr value) where T: NSObject, IProtocol { /* implementation */ }

    [Property ("OptionalStaticProperty")]
    [Export ("optionalStaticProperty")]
    public static IntPtr GetOptionalStaticProperty<T> () where T: NSObject, IProtocol { /* implementation */ }

    [Property ("OptionalStaticProperty")]
    [Export ("setOptionalStaticProperty:")]
    public static void SetOptionalStaticProperty<T> (IntPtr value) where T: NSObject, IProtocol { /* implementation */ }
}
```

Also add documentation and tests.
2024-05-31 13:00:57 +02:00
Rolf Bjarne Kvinge 36bc43f7dc
[CryptoTokenKit] Bind this framework. Fixes #7876. (#20587)
Fixes https://github.com/xamarin/xamarin-macios/issues/7876.

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2024-05-29 20:38:40 +02:00
Rolf Bjarne Kvinge 8c39f793ac [net9.0] Merge main into net9.0. 2024-05-28 08:37:23 +02:00
Rolf Bjarne Kvinge f78af68fb2
[bgen] Add support for binding constructors in protocols. Fixes #14039. (#20583)
Add support for binding constructors in protocols.

Given the api definition:

```cs
[Protocol]
public interface Protocol {
    [Abstract]
    [Export ("init")]
    IntPtr Constructor ();

    [Export ("initWithValue:")]
    IntPtr Constructor (IntPtr value);

    [BindAs ("Create")]
    [Export ("initWithPlanet:")]
    IntPtr Constructor ();
}
```

we're binding it like this:

```cs
[Protocol ("Protocol")]
public interface IProtocol : INativeObject {
    [Export ("init")]
    public static T CreateInstance<T> () where T: NSObject, IProtocol { /* default implementation */ }

    [Export ("initWithValue:")]
    public static T CreateInstance<T> () where T: NSObject, IProtocol { /* default implementation */ }

    [Export ("initWithPlanet:")]
    public static T Create<T> () where T: NSObject, IProtocol { /* default implementation */ }
}
```

Also add documentation and tests.

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

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@soto.dev>
2024-05-24 11:29:53 +02:00
Rolf Bjarne Kvinge f052e014d0 [net9.0] Merge main into net9.0. 2024-05-21 16:12:35 +02:00
Rolf Bjarne Kvinge c5f93a2061
[bgen] Add support for marking API bindings as preview APIs using the Experimental attribute. (#20591) 2024-05-09 18:54:08 +02:00
Rolf Bjarne Kvinge 1a12994513 [net9.0] Merge main into net9.0. 2024-04-26 15:08:47 +02:00
Rolf Bjarne Kvinge 1e0cc8f0fb
[docs] Review and update the 'Binding errors' document. (#20481)
Note that this document is currently not published on our documentation web site.

* Consolidate on a single way to specify message arguments (* instead of {...}).
* Mark messages that will only be show in legacy as such (but keep them)
* Escape star characters in headers.
* Remove mentions of Xamarin.
* Misc other updates.
2024-04-24 09:41:10 +02:00
Rolf Bjarne Kvinge 50f8494961 [net9.0] Merge main into net9.0. 2024-04-23 15:35:11 +02:00
Rolf Bjarne Kvinge 417236e279
[docs] Bring back documentation updates from the documentation repository. (#20453)
It's been a few years since we've synchronized the documentation here with the
documentation in the documentation repository
(https://github.com/MicrosoftDocs/xamarin-docs-pr/), so bring all updates done
there over here.

This PR is probably best reviewed commit-by-commit.
2024-04-22 18:32:21 +02:00
Rolf Bjarne Kvinge 22b2f7de91 [net9.0] Merge main into net9.0. 2024-04-09 16:47:41 +02:00
Michael Cummings (MSFT) d0c3d23043
Apple Privacy Manifest doc updates (#20391)
Update documentation for binding projects
2024-04-02 13:33:37 -04:00
Rolf Bjarne Kvinge daa9d6a2c8 [net9.0] Merge main into net9.0. 2024-03-22 10:20:42 +01:00
Gerald Versluis a3af464fb3
Fix Apple Privacy Manifest doc typos
Spotted a couple of typos
2024-03-21 12:37:15 +01:00
Michael Cummings (MSFT) 4854f70f09
Add documentation on how to provide the Apple Privacy Manifest (#20292)
From https://developer.apple.com/news/?id=3d8a9yyh

> Starting March 13: If you upload a new or updated app to App Store
Connect that uses an API requiring approved reasons, we'll will send you
an email letting you know if you’re missing reasons in your app’s
privacy manifest. This is in addition to the existing notification in
App Store Connect.
> 
> Starting May 1: You’ll need to include approved reasons for the listed
APIs used by your app’s code to upload a new or updated app to App Store
Connect. If you’re not using an API for an allowed reason, please find
an alternative. And if you add a new third-party SDK that’s on the list
of commonly used third-party SDKs, these API, privacy manifest, and
signature requirements will apply to that SDK. Make sure to use a
version of the SDK that includes its privacy manifest and note that
signatures are also required when the SDK is added as a binary
dependency.

[Document
preview](928100b38f/docs/apple-privacy-manifest.md)

fixes: https://github.com/xamarin/xamarin-macios/issues/20059

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
2024-03-21 07:04:27 -04:00
Haritha Mohan 20ea4a457f
[msbuild] Disable stripping symbols by default for Debug builds (#20308)
Fixes https://github.com/xamarin/xamarin-macios/issues/20235
2024-03-18 08:13:47 -07:00
Rolf Bjarne Kvinge c303a9c7c7
[dotnet] Multi target with Xcode 15.0 (#20155)
Add multi-targeting support for our initial .NET 8 packs (for Xcode
15.0).

This means a library/binding project can do:

```xml
<TargetFrameworks>net8.0-ios17.0;net8.0-ios17.2</TargetFrameworks>
```

and the library will be built in two varieties: once using our iOS 17.0
bindings, and once using our iOS 17.2 bindings.

An app project can also do:

```xml
<TargetFramework>net8.0-ios17.0</TargetFramework>
```

to build with the iOS 17.0 bindings (which is typically not very useful,
since building with the latest iOS SDK is usually best).
2024-02-28 09:03:53 +01:00
Rolf Bjarne Kvinge 720a4f7ce2
[src] Remove the Protocolize attribute. (#19684)
Remove support for the Protocolize attribute from the generator, and remove
all usages of it in our api definitions - just use the protocol interface.

The Protocolize attribute was used to support binding stuff using the Model
class with Classic Xamarin code + and binding stuff using the protocol
interface with Unified Xamarin code, using the same source code.

Classic Xamarin has been dead for quite a few years ago now though, so there's
no need to keep his code around anymore, we can just upgrade the api
definitions to use the protocol interface directly.

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

---------

Co-authored-by: Alex Soto <alex@soto.dev>
2024-01-11 16:23:15 +01:00
Rolf Bjarne Kvinge 88ae3b0834
[docs] Document NativeAOT support. Fixes #18585. (#19362)
Fixes https://github.com/xamarin/xamarin-macios/issues/18585.

---------

Co-authored-by: Šimon Rozsíval <simon@rozsival.com>
Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
2023-11-09 16:05:54 +01:00
Rolf Bjarne Kvinge 8c71cecf59
[docs] Improve a few things in the managed static registrar doc. (#19368) 2023-10-29 13:09:03 -04:00
Rolf Bjarne Kvinge 17126b3d7e
[docs] Point to general documentation about workloads in the documentation for multi targeting. (#18923) 2023-09-06 12:16:35 +02:00
Rolf Bjarne Kvinge 6e4a98b1fa
[docs] Document how we plan to do multi targeting. (#18523)
Document the plan to:

* Compile against an earlier version of our bindings.
    * https://github.com/dotnet/sdk/issues/30103
* Consume preview packages for a preview version of Xcode.
    * https://github.com/xamarin/xamarin-macios/issues/18343
2023-08-31 08:59:00 +02:00
Šimon Rozsíval 7f67aa0bae
[registrar] Create instances of NSObjects and INativeObjects without using reflection in the managed static registrar (#18519)
This PR adds lookup tables and factory methods for INativeObjects and
NSObjects. These generated methods allow us to create instances of these
objects without needing reflection.

Closes #18358.
2023-08-15 08:30:46 +02:00
dustin-wojciechowski 2606b2341e
[docs]Created a doc for preparing an app for TestFlight (#18125)
I created a short doc to help anyone uploading their app to Test Flight.

I targeted MacCatalyst apps for the Mac App Store but would work the
same for iOS apps.
2023-05-30 17:46:10 -04:00
Rolf Bjarne Kvinge 3a8b988563
Apply suggestions from code review
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
2023-05-15 15:16:39 +02:00
Rolf Bjarne Kvinge 5693250429
Update docs/managed-static-registrar.md
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
2023-05-12 08:05:11 +02:00
Rolf Bjarne Kvinge dd64974d6a
Update docs/managed-static-registrar.md
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
2023-05-12 08:05:03 +02:00
Rolf Bjarne Kvinge 527cba2382 [docs] Document the managed static registrar. 2023-05-11 12:16:48 +02:00
Rolf Bjarne Kvinge 36af029204
Change all null checking expressions to use 'is' and 'is not'. (#18176)
Change all null checking expressions to use 'is null' and 'is not null'
instead of '== null' and '!= null'.

This was mostly done with sed, so code can probably be improved in many
other ways with manual inspection, but that will come over time.

Also add code to the autoformat script to automatically fix these issues in the future.
2023-05-05 17:52:19 +02:00
Haritha Mohan 6dcb8e3b02
[docs] Document properties for configurations (#17940)
Fixes #17738
Addresses the initial issue of just documenting which properties are
tied to which configuration. But to make the documentation more helpful,
we should provide further context about what exactly these properties
mean. However, this isn't trivial as some properties are a bit
cryptic..once further info is acquired, it will be integrated in a later
revision.
2023-03-30 12:22:32 -07:00
Rolf Bjarne Kvinge 49c3fd44f5
[fabricbot] Handle the 'need-repro' label. (#17272)
Handle the 'need-repro' label like the 'need-info' label:

* Add a comment that we need a repro, and how to get one.
* Close the issue if no comments within 7 days.
* Add a 'need-attention' label if reporter comments.

Also add a document explaining how to create a repro, modeled after (copied)
MAUI's document (https://github.com/dotnet/maui/blob/main/.github/repro.md).
2023-01-18 18:33:48 +01:00
Rolf Bjarne Kvinge b6d484e3c4
Remove Xamarin.Analysis. (#16149)
It's not used by anyone anymore, and there are better alternatives for .NET.

This removes a dependency on a private component, which makes a potential move
into the dotnet org easier.
2022-09-28 16:25:07 +02:00
Rolf Bjarne Kvinge 3be1d9d760
Use unix-style line endings in project files. (#15303)
This also removes the BOM in a few project files.

This is a whitespace-only change, as can be seen here: https://github.com/xamarin/xamarin-macios/pull/15303/files?w=1
2022-06-21 17:22:58 +02:00
Rolf Bjarne Kvinge 5a45a3c3aa
[src] Remove the ModelAttribute.AutoGeneratedName property in .NET. (#13619)
AutoGeneratedName was a toggle to implement a certain (correct) behavior,
while at the same time not cause breaking changes.

Now that we can do breaking changes in .NET, we can remove the toggle (i.e.
the property), and just always do the right thing (that is: automatically
generate a _unique_ Objective-C name for Model classes, unless a name is
specified manually).

Ref: https://github.com/xamarin/xamarin-macios/issues/5107
2021-12-22 21:28:19 +01:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
Rolf Bjarne Kvinge aa7e9d06d1
[configure] Add option to use a locally built dotnet/runtime. (#11643)
* Add a configure option to use a locally built dotnet/runtime.
* Add documentation how to build dotnet/runtime the way we need it built.
* Modify our build to consume the custom dotnet/runtime if so configured.

This is useful when trying to debug the runtime locally, or trying out new
features there are no packages for yet.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2021-05-21 22:18:25 +02:00
Chris Hamons 5e105f6f30
[docs] Clarify optional protocol support with class vs interface (#10021)
- From https://github.com/xamarin/ios-samples/pull/410

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2020-12-03 13:38:46 -05:00
Rolf Bjarne Kvinge 95e42b9266
Rename master to main. (#8851)
* Fix links that point to master to point to main instead.
* Implement support in the sample tester for specifying the default branch for
  each sample repo.
* Fix various text / documentation to say 'main' instead of 'master.'
* Push to 'main' instead of 'master' in xamarin-macios-data.
* Fix xharness to make 'main' the special branch with regards to documentation tests as opposed to 'master'.
* Fix various CI to use 'main' instead of 'master'.
* Bump maccore

    New commits in xamarin/maccore:

    * xamarin/maccore@ed6d146822 Rename 'master' to 'main'. (#2233)

    Diff: 424fa26148..ed6d146822
2020-06-16 15:51:44 +02:00
Chris Hamons 78dcb51fe3
Remove notice from generated iOS Apps (#8857)
- The notice points to an out of date page, currently dead (will be redirected soon)
- https://github.com/xamarin/xamarin-macios/issues/8849 is the new home
2020-06-15 15:52:08 -05:00
Sebastien Pouliot d9ee6ab36d
[generator] Remove [RetainList] from generator-attributes and docs (#8746)
It's been long gone from the generator code itself.
2020-06-03 20:15:43 -04:00
Sebastien Pouliot c8a8fb3156
[mtouch] Always enable experimental-xforms-product-type (#8425)
Not an experiment anymore - it works as expected.

This half-remove the optimization option (it must remain there to avoid
breaking all projects that have it defined) but it will always be `true`
so `Xamarin.Forms.Platform.iOS.dll` will **always** be considered as SDK
code by the linker.

Fix https://github.com/xamarin/xamarin-macios/issues/8407
2020-04-17 17:18:20 -04:00
Sebastien Pouliot 54f2dae935
[mtouch] Add `force-rejected-types-removal` optimization (#8009)
This optimization can be enabled when it's not possible to use the
managed linker (e.g. **Don't link**) or when the managed linker cannot
remove references to deprecated types that would cause an application
to be rejected by Apple.

References to the existing types will be renamed, e.g. `UIWebView` to
`DeprecatedWebView`, in every assemblies.

The type definition is also renamed (for validity) and all custom
attributes on the types and their members will be removed.
Code inside the members will be replaced with a
`throw new NotSupportedException ();`.

The msbuild test app `MyReleaseBuild` has been updated to test that the
optimization is working as expected (device builds are slow so reusing
this test has little impact in test time).

Basically the test ensure that `UIWebView` is used and cannot be removed
by the compiler (optimization) or the managed linker (since it's
referenced). Since the optimization is enabled then we can `grep` then
final `.app` directory to ensure there's no mention of `UIWebView` inside
any of the files that would be submitted.

The application can be run, by itself, and will turn green if OK, red if
`DeprecatedWebView` can't be found (skeleton replacement for `UIWebView`)
or orange if a `NotSupportedException` is thrown.

Finally introspection tests have been updated to skip over the deprecated
(and renamed) types. It should not be an issue right now, since this
optimization is not enabled by default, but it made testing easier.
2020-03-02 09:20:29 -05:00
Rolf Bjarne Kvinge 2f4dae9e00
[mmp] Don't ignore failures to execute pkg-config and simplify/improve logic. (#7969)
* [mmp] Don't ignore failures to execute pkg-config and simplify/improve logic.

* Show proper errors if pkg-config fails to execute.
* Extract logic to verify system mono version into its own function.
* Extract logic to execute pkg-config into its own function.

* Simplify code slightly.

* [mmp] Remove the MM5301 error message.

It's never used in mmp, and the same error code is already used in mtouch.
2020-02-26 00:38:20 +01:00
Sebastien Pouliot d83e13edf1
[mtouch][mmp] Add a `--warn-on-type-ref=X` option (#7949)
Using this option it's possible to test for the presence of a type
reference in both pre-linked and post-linked assemblies.

This makes it possible to detect if
* a 3rd party assemblies are using some specific type you would like to avoid;
* a type reference has been removed during the build (e.g. linker)

Notes:
* Custom attributes are encoded differently and not included in the assembly type references metadata.
* Assembly that define a type `X` do not have a reference (but the definition) of the type (and won't be reported).

If either the pre or post-linked warnings are not useful then it's possible
 to add `-nowarn:150x` to exclude the results.

E.g.
* `-nowarn:1502` would not report references in pre-linked assemblies;
* `-nowarn:1503` would not report references in post-linked assemblies;

Finally `-warnaserror:150x` can be used to stop a build that would not
satisfy either the pre or post-linked condition.

* `-warnaserror:1502` would not report references in pre-linked assemblies;
* `-warnaserror:1503` would not report references in post-linked assemblies;

_side note_ same as https://github.com/xamarin/xamarin-macios/pull/7925
except that this one uses the localized mtouch/mmp errors only in master (so far)
2020-02-20 22:25:23 -05:00
Rolf Bjarne Kvinge 9fe358650b
Use relative paths in scripts. (#7545)
It makes relocating XI/XM easier.
2019-12-10 12:47:30 +01:00