From b2bcad7a947d502db1355f017966a897966c9bb1 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 26 Jan 2018 18:38:23 +0100 Subject: [PATCH] Add a BindingImpl attribute and use to to teach the linker look for it to search for optimizable code. (#3299) * [ObjCRuntime] Add a BindingImplAttribute. * [linker] Make ProviderToString an extension method on ICustomAttributeProvider to make it more discoverable. * [generator] Use [BindingImpl] instead of [CompilerGenerated]. The entire diff is big (89MB), so it can't be gisted. However, most of it is either removal of `using System.Runtime.CompilerServices;` or the change from `[CompilerGenerated]` to `[BindingImpl (...)]` like this: https://gist.github.com/rolfbjarne/8bfda3ed37b956d0342a1c1e9b079244 If I remove those parts of the diff, there's nothing significant left: https://gist.github.com/rolfbjarne/4156164d6bdb1376366200394eb8a091 * [linker] Teach the linker about the new [BindingImpl] attribute. In addition to the existing logic where the linker would optimize some [CompilerGenerated] code (sometimes with additional requirements), it will now also optimize all [BindingImpl (Optimizable)] code (without any additional requirements). * [tests] Add tests to make sure [BindingImpl (Optimizable)] works as expected. * [linker] Check for [BindingImpl] before [CompilerGenerated] and stop checking for [CompilerGenerated] in XAMCORE_4_0. Check for [BindingImpl] before checking for [CompilerGenerated], since the former is more common. Also stop checking for [CompilerGenerated] (at least to mean that code is optimizable) in our next non-compatible evolutionary leap (XAMCORE_4_0): * [introspection] Impl a better typo check. --- docs/website/mtouch-errors.md | 4 + src/Makefile.generator | 1 + src/ObjCRuntime/BindingImplAttribute.cs | 27 ++++++ src/frameworks.sources | 1 + src/generator-enums.cs | 2 +- src/generator-filters.cs | 12 +-- src/generator.cs | 20 ++--- tests/introspection/ApiTypoTest.cs | 1 + .../link sdk/OptimizeGeneratedCodeTest.cs | 76 ++++++++++++++--- tools/common/Driver.cs | 2 + tools/linker/CoreMarkStep.cs | 6 +- tools/linker/CoreOptimizeGeneratedCode.cs | 23 ++++-- tools/linker/CoreRemoveAttributes.cs | 4 + tools/linker/MobileExtensions.cs | 82 +++++++++++++++++++ .../PreserveSmartEnumConversionsSubStep.cs | 19 ++--- tools/mmp/Makefile | 1 + tools/mmp/mmp.csproj | 3 + tools/mtouch/Makefile | 1 + tools/mtouch/mtouch.csproj | 3 + 19 files changed, 234 insertions(+), 54 deletions(-) create mode 100644 src/ObjCRuntime/BindingImplAttribute.cs diff --git a/docs/website/mtouch-errors.md b/docs/website/mtouch-errors.md index 448e540359..88dad0baa0 100644 --- a/docs/website/mtouch-errors.md +++ b/docs/website/mtouch-errors.md @@ -1296,6 +1296,10 @@ Mixed-mode assemblies can not be processed by the linker. See https://msdn.microsoft.com/en-us/library/x0w2664k.aspx for more information on mixed-mode assemblies. +### MT2105: The [BindingImpl] attribute on the member * is invalid: * + +The `[BindingImpl]` attribute on the mentioned member is invalid. The expected format is `[BindingImpl (BindingImplOptions.ValueA | BindingImplOptions.ValueB)]`. + # MT3xxx: AOT error messages