From b5638eddd49564c5b5686670c7ae8b43e76b0a7e Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 19 Nov 2024 22:02:59 +0000 Subject: [PATCH] Remove unsupported _AggressiveAttributeTrimming switch --- docs/workflow/trimming/feature-switches.md | 1 - .../src/ILLink/ILLink.LinkAttributes.xml | 13 - .../ILLink/ILLink.LinkAttributes.Shared.xml | 263 ------------------ .../AggressiveAttributeTrimmingTest.cs | 80 ------ .../System.Runtime.TrimmingTests.proj | 4 - .../System.Private.CoreLib.csproj | 3 - .../src/ILLink/ILLink.LinkAttributes.xml | 16 -- 7 files changed, 380 deletions(-) delete mode 100644 src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/AggressiveAttributeTrimmingTest.cs delete mode 100644 src/mono/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml diff --git a/docs/workflow/trimming/feature-switches.md b/docs/workflow/trimming/feature-switches.md index 76714d95f2c2ba..667d08a3f457c1 100644 --- a/docs/workflow/trimming/feature-switches.md +++ b/docs/workflow/trimming/feature-switches.md @@ -12,7 +12,6 @@ configurations but their defaults might vary as any SDK can set the defaults dif | DynamicCodeSupport | System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported | Changes RuntimeFeature.IsDynamicCodeSupported to false to allow testing AOT-safe fallback code without publishing for Native AOT. | | EnableGeneratedComInterfaceComImportInterop | System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop | When set to true, enables casting source-generated COM object wrappers to built-in COM-based COM interfaces. | | VerifyDependencyInjectionOpenGenericServiceTrimmability | Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability | When set to true, DependencyInjection will verify trimming annotations applied to open generic services are correct. | -| _AggressiveAttributeTrimming | System.AggressiveAttributeTrimming | When set to true, aggressively trims attributes to allow for the most size savings possible, even if it could result in runtime behavior changes | | _ComObjectDescriptorSupport | System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported | When set to true, supports creating a TypeDescriptor based view of COM objects. | | _DataSetXmlSerializationSupport | System.Data.DataSet.XmlSerializationIsSupported | When set to false, DataSet implementation of IXmlSerializable will throw instead of using trim-incompatible XML serialization. | | _DefaultValueAttributeSupport | System.ComponentModel.DefaultValueAttribute.IsSupported | When set to true, supports creating a DefaultValueAttribute at runtime. | diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml b/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml index d2691fa8803934..a82594ff868e25 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml @@ -20,17 +20,4 @@ - - - - - - - - - - - - - diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml index db98894014bc5c..ca7f802dc2add2 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.Shared.xml @@ -85,267 +85,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Serviceable - - - - - - - PreferInbox - - - - - - - RepositoryUrl - - - - - - - SourceCommitUrl - - - - - - - CommitHash - - - - - - - IsTrimmable - - - - diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/AggressiveAttributeTrimmingTest.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/AggressiveAttributeTrimmingTest.cs deleted file mode 100644 index dfdce520e1904d..00000000000000 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/AggressiveAttributeTrimmingTest.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#nullable enable - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Reflection; - -/// -/// Ensures setting _AggressiveAttributeTrimming = true causes various attributes to be trimmed -/// -class Program -{ - [UnconditionalSuppressMessage ("ReflectionAnalysis", "IL2111", Justification = "Expected trim warning for reflection over annotated members.")] - [UnconditionalSuppressMessage ("ReflectionAnalysis", "IL2026", Justification = "Expected trim warning for reflection over annotated members.")] - static int Main(string[] args) - { - // Reference to IsDynamicCodeSupported (which has FeatureGuard(typeof(RequiresDynamicCodeAttribute))) - // should not produce a warning because both RequiresDynamicCodeAttribute and FeatureGuardAttribute are removed. - if (RuntimeFeature.IsDynamicCodeSupported) - { - UseDynamicCode(); - } - - // Check that a few attribute instances are indeed removed - CheckRemovedAttributes(typeof(MembersWithRemovedAttributes)); - - return 100; - } - - [RequiresDynamicCode(nameof(UseDynamicCode))] - static void UseDynamicCode() { } - - class MembersWithRemovedAttributes - { - static void DynamicallyAccessedMembers([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type t) { } - - [FeatureGuard(typeof(RequiresUnreferencedCodeAttribute))] - static bool FeatureGuard => throw null!; - - [FeatureSwitchDefinition("Program.MembersWithRemovedAttributes.FeatureSwitchDefinition")] - static bool FeatureSwitchDefinition => throw null!; - - [RequiresDynamicCode(nameof(RequiresDynamicCode))] - static void RequiresDynamicCode() { } - - [RequiresUnreferencedCode(nameof(RequiresUnreferencedCode))] - static void RequiresUnreferencedCode() { } - } - - static void CheckRemovedAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type) - { - Console.WriteLine($"Validating {type}"); - foreach (var member in type.GetMembers(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) - { - CheckRemovedAttributes(member); - - if (member is MethodInfo method) - { - foreach (var parameter in method.GetParameters()) - { - CheckRemovedAttributes(parameter); - } - } - } - } - - static void CheckRemovedAttributes(ICustomAttributeProvider provider) - { - foreach (var attribute in provider.GetCustomAttributes(false)) - { - if (attribute is NullableContextAttribute) - continue; - - throw new Exception($"Unexpected attribute {attribute.GetType()} on {provider}"); - } - } -} diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj index ac7ab0c60226b8..7976b3a89c221d 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj @@ -2,10 +2,6 @@ - - _AggressiveAttributeTrimming - SuppressTrimAnalysisWarnings;TrimmerSingleWarn - osx-x64;linux-x64;browser-wasm diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 8f6fbf18070cd1..36877bc84b33cd 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -142,9 +142,6 @@ - - - diff --git a/src/mono/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml b/src/mono/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml deleted file mode 100644 index 90bb636cc6e5a6..00000000000000 --- a/src/mono/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - -