Bridges the worlds of .NET with the native APIs of macOS, iOS, tvOS, and watchOS.
Перейти к файлу
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
.config [main] Update dependencies from dotnet/installer (#15119) 2022-05-26 08:51:49 +02:00
.github [actions] Improve commit message in the bump-global-json action. (#20649) 2024-05-29 11:49:00 +02:00
Localize Update AOTCompile task to handle cycles in up-to-date check (#20103) 2024-02-15 17:29:18 +01:00
builds [dotnet] Differentiate between "OS version we support as TargetPlatformVersion" and "OS version we support or have supported". (#19882) 2024-01-23 19:17:25 +01:00
docs [bgen] Implement support for using default interface members to bind protocols. (#20681) 2024-06-07 16:35:48 +02:00
dotnet Enable dedup optimization in FullAOT mode only (#20687) 2024-06-07 13:21:41 +02:00
eng [main] Update dependencies from dotnet/xharness (#20676) 2024-06-07 11:56:03 +02:00
external Bump Xamarin.MacDev. (#20518) 2024-04-26 09:09:10 +02:00
fsharp Add config file for libmono-native dllmap 2019-03-13 00:34:47 +01:00
jenkins [jenkins] Jenkins is dead, long live ~Wrench~ Azure Devops. (#16396) 2022-10-21 10:05:59 +02:00
mk [msbuild/dotnet] Automatically link with Swift's system libraries if a binding project has the IsSwift=true property. (#20546) 2024-05-20 20:17:29 +02:00
mono Add config file for libmono-native dllmap 2019-03-13 00:34:47 +01:00
msbuild [msbuild] Unify MonoBundlingExtraArgs and MtouchExtraArgs into AppBundleExtraOptions. Fixes #12807. (#20594) 2024-05-28 14:57:52 +02:00
release [dotnet] Rename packs to contain target framework. (#19765) 2024-02-19 13:14:20 +01:00
runtime [runtime] Remove dead code. (#20655) 2024-05-29 20:15:08 +02:00
src [bgen] Implement support for using default interface members to bind protocols. (#20681) 2024-06-07 16:35:48 +02:00
tests [bgen] Implement support for using default interface members to bind protocols. (#20681) 2024-06-07 16:35:48 +02:00
tools [devops] Fully disable CodeQL, it crashes on x64 as well. (#20693) 2024-06-07 11:22:47 +02:00
.editorconfig Update editorconfig. (#19909) 2024-01-26 08:24:58 +01:00
.gitattributes [dotnet] Fix line endings in template localizations. (#16981) 2022-12-12 17:12:35 +01:00
.gitignore [net8.0] [build] Require using EnablePreviewFeatures=true when using preview releases. Contributes towards #18343. (#18476) 2023-06-22 08:16:50 +02:00
.gitmodules [Build] Update submodules remotes. (#19632) 2023-12-18 11:45:25 -05:00
CODEOWNERS [WebKit] Merge WKWebKit into WebKit. (#17062) 2022-12-19 18:37:53 +01:00
DOWNLOADS.md Update DOWNLOADS.md with new releases. (#19595) 2023-12-11 08:47:13 +01:00
Directory.Build.props Get Mono.Cecil from NuGet everywhere. (#19535) 2023-12-04 20:15:03 +01:00
ISSUE_TEMPLATE.md Add newlines to issue template to fix markdown formatting problems. (#15152) 2022-05-31 18:43:01 +02:00
LICENSE Adjust license to match requested format 2016-04-25 16:38:57 -04:00
Make.config [msbuild/dotnet] Automatically link with Swift's system libraries if a binding project has the IsSwift=true property. (#20546) 2024-05-20 20:17:29 +02:00
Make.versions [dotnet] Multi target with Xcode 15.0 (#20155) 2024-02-28 09:03:53 +01:00
Makefile [build] Add support for worktree checkouts (#19240) 2023-10-19 09:22:37 -07:00
NOTICE.txt Add NOTICE.txt and cgmanifest tool (#8843) 2020-06-12 14:30:21 -05:00
NuGet.config [main] Update dependencies from dotnet/installer (#20551) 2024-05-21 19:56:42 +02:00
README.md Update README (#20536) 2024-05-01 08:29:31 +02:00
SECURITY.MD Add SECURITY.MD to repo (as suggested by OSPO) (#7019) 2019-09-19 17:44:22 -04:00
Versions-ios.plist.in [Xcode 15.2] Bump to Xcode 15.2 (#19785) 2024-01-12 04:56:22 -05:00
Versions-mac.plist.in [Xcode 15.2] Bump to Xcode 15.2 (#19785) 2024-01-12 04:56:22 -05:00
Xamarin.Mac.sln Fix path to dont link project in Xamarin.Mac.sln. (#8109) 2020-03-16 09:42:52 +01:00
Xamarin.iOS.sln [tests] Make the mtouch test project reference the actual mtouch project. (#11400) 2021-05-04 14:10:03 +02:00
banner.png [README] Add Xamarin.iOS + Xamarin.Mac banner (#1665) 2017-02-08 17:42:48 -05:00
configure convert to if ... fi 2023-11-30 21:58:56 -05:00
create-make-config.sh Encode the .NET version we're targeting in the third NuGet version number. (#17818) 2023-03-17 07:39:59 +01:00
global.json [main] Update dependencies from dotnet/installer (#20694) 2024-06-07 11:39:45 +02:00
mac-entitlements.plist Implement notarization. (#6928) 2019-09-09 00:34:11 -07:00
product.snk Add our mono runtimes to the build. 2016-04-24 14:47:24 -04:00
system-dependencies.sh Update Homebrew install URL (#19968) 2024-02-05 10:03:21 -05:00
versions-check.csharp [dotnet] Differentiate between "OS version we support as TargetPlatformVersion" and "OS version we support or have supported". (#19882) 2024-01-23 19:17:25 +01:00

README.md

.NET for iOS, Mac Catalyst, macOS, tvOS

Welcome!

This module is the main repository for:

  • .NET for iOS
  • .NET for Mac Catalyst
  • .NET for macOS
  • .NET for tvOS

These SDKs allow us to create native iOS, Mac Catalyst, macOS and tvOS applications using the same UI controls we would in Objective-C and Xcode, except with the flexibility and elegance of a modern language (C#), the power of the .NET Base Class Library (BCL), and first-class IDEs and editors—Visual Studio and Visual Studio Code—at our fingertips.

This repository is where we do development for the .NET for iOS, Mac Catalyst, macOS, and tvOS SDKs. .NET for iOS, Mac Catalyst, macOS, and tvOS are part of .NET MAUI, and may also be used independently for native iOS and macOS development with .NET.

There are a few ways that you can contribute, for example:

Support

.NET for iOS, Mac Catalyst, macOS, and tvOS are part of .NET MAUI, since it was introduced in May 2022 as part of .NET 6, and is currently supported as described on the .NET MAUI Support Policy.

Support for Xamarin.iOS and Xamarin.Mac ended on May 1, 2024 as per the Xamarin Support Policy:

Xamarin support ended on May 1, 2024 for all Xamarin SDKs including Xamarin.Forms. Android API 34 and Xcode 15 SDKs (iOS and iPadOS 17, macOS 14) are the final versions Xamarin targets from existing Xamarin SDKs (i.e. no new APIs are planned).

Contributing

If you are interested in fixing issues and contributing directly to the code base, please see the document How to Contribute, which covers the following:

Downloads

The preferred method for installing Xamarin.iOS and Mac is to use the Visual Studio installers (Windows, Mac).

The team also strongly recommends using the latest Xamarin SDK and Xcode whenever possible.

However, we provide links to older Xamarin.iOS and Mac packages for macOS downgrades and build machine configuration, see Downloads.

Feedback

Discord

License

Copyright (c) .NET Foundation Contributors. All rights reserved. Licensed under the MIT License.