Bridges the worlds of .NET with the native APIs of macOS, iOS, tvOS, and watchOS.
Перейти к файлу
Šimon Rozsíval 40c3f422c4
[NativeAOT] Improve the transformation of [Preserve(AllMembers = true)] (#19516)
Closes #19505 

We transform `[Preserve(AllMembers = true)]` into
`[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(T))]`.
There is difference between which members are preserved in these two
cases. The `DynamicallyAccessedMemberTypes.All` preserves many more,
especially nested types and their members. This manifested with the
`IL3050` AOT analysis warning we got from ILC when building any app:
1. `NSObject_Disposer` has `[Preserve(AllMembers = true)]`
2. `NSObject_Disposer` is a subclass of NSObject
3. `NSObject` has nested enums `Flags` and `XamarinGCHandleFlags`
4. the base class `Enum` has a public static method `GetValues(Type)`
5. the `GetValues` method is annotated with `RequiresDynamicCode` and
ILC produces a warning because even though it isn't used anywhere in the
codebase, it could be used via reflection

I changed two things when transforming Preserve:
- For enums, we only need to preserve public fields. We especially want
to avoid `PublicMethods` since that would preserve public methods in the
base class which includes the `GetValues(Type)` method.
- For other types, I list explicitly the member types that should be
preserved instead of using `All`.
- The code is verbose, but in the end, I chose the explicit list instead
of `All ^ PublicNestedTypes ^ NonPublicNestedTypes` since that would
automatically include any new flag added to the enum in the future.
2023-11-30 11:39:27 +01:00
.config [main] Update dependencies from dotnet/installer (#15119) 2022-05-26 08:51:49 +02:00
.github Bump actions/github-script from 6.4.1 to 7.0.1 (#19488) 2023-11-20 17:31:45 +01:00
Localize Bring changes from Localization branch #20231025.9 (#19340) 2023-10-31 16:00:11 -04:00
builds [msbuild] Fix resolving static libraries inside an XCFramework in a NuGet. (#19502) 2023-11-27 08:54:48 +01:00
docs [docs] Document NativeAOT support. Fixes #18585. (#19362) 2023-11-09 16:05:54 +01:00
dotnet [dotnet] Generate WorkloadManifest.targets for each platform using a script. (#19421) 2023-11-13 10:36:40 +01:00
eng [main] Update dependencies from dotnet/installer (#19537) 2023-11-30 10:58:36 +01:00
external Bump api-tools to get fix for default interface members. (#19441) 2023-11-14 08:59:04 +01: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 [Maccore] Bump to latest to get ADR updates (#19424) 2023-11-13 07:17:53 -08:00
mono Add config file for libmono-native dllmap 2019-03-13 00:34:47 +01:00
msbuild [msbuild] Merge the CompileNativeCode[TaskBase] classes. (#19527) 2023-11-29 08:11:11 +01:00
release [net8.0] Revert multi-targeting support. (#19145) 2023-10-10 17:20:09 +02:00
runtime [runtime] Use objc_[retain|release|autorelease] instead of sending messages. (#19415) 2023-11-14 07:42:55 +01:00
src [Generator] Remove properties that are used very few times. (#19531) 2023-11-28 11:13:33 -05:00
tests [NativeAOT] Improve the transformation of [Preserve(AllMembers = true)] (#19516) 2023-11-30 11:39:27 +01:00
tools [NativeAOT] Improve the transformation of [Preserve(AllMembers = true)] (#19516) 2023-11-30 11:39:27 +01:00
.editorconfig [Code Style] Add some extra style checks focused on nullability. (#17831) 2023-06-22 13:31:04 -04: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 Merge branch 'net8.0' into merge-main-net8 2023-07-11 10:27:22 -04:00
CODEOWNERS [WebKit] Merge WKWebKit into WebKit. (#17062) 2022-12-19 18:37:53 +01:00
DOWNLOADS.md Update DOWNLOADS.md with new releases. (#19174) 2023-10-12 17:20:10 +02:00
Directory.Build.props Bump MSBuild.StructuredLogger to v2.2.100 (#19503) 2023-11-28 15:15:29 +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 Bump api references for .NET 8 and legacy Xamarin. (#19434) 2023-11-14 07:44:02 +01:00
Make.versions Update Make.versions 2023-10-11 18:15:46 +02: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/xharness (#19487) 2023-11-21 07:49:51 +01:00
README.md [Readme] Update link to the forums. (#19361) 2023-10-26 19:28:51 +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 Bump to Xcode 15 and the corresponding OS version. 2023-08-04 11:47:27 -04:00
Versions-mac.plist.in Bump to Xcode 15 and the corresponding OS version. 2023-08-04 11:47:27 -04: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 [configure] Make 'macos' work like 'mac'. (#18627) 2023-08-07 19:19:37 +02: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 (#19537) 2023-11-30 10:58:36 +01: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 [xcode15] Bump Xcode 15 to Beta 6 (#18668) 2023-08-12 07:10:00 -04:00
versions-check.csharp [versions-check.csharp] Improve this script a bit (#10323) 2021-01-11 10:47:57 +01:00

README.md

Xamarin.iOS + Xamarin.Mac logo

Xamarin.iOS & Xamarin.Mac

Welcome!

This module is the main repository for both Xamarin.iOS and Xamarin.Mac.

These SDKs allow us to create native iOS, tvOS, watchOS and macOS 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 two first-class IDEs—Visual Studio for Mac and Visual Studio—at our fingertips.

This repository is where we do development for the Xamarin.iOS and Xamarin.Mac SDKs. There are a few ways that you can contribute, for example:

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.