From 09d484640636b72c26c3a6ea7408f050b849c1b1 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 16 Aug 2024 22:07:32 +0000 Subject: [PATCH 1/9] Use FeatureSwitchDefinition in a few places --- .../ILLink/ILLink.Substitutions.Windows.xml | 10 -------- .../InteropServices/InMemoryAssemblyLoader.cs | 1 + .../Reflection/Metadata/MetadataUpdater.cs | 2 ++ .../InteropServices/Marshal.CoreCLR.cs | 1 + .../src/ILLink/ILLink.Substitutions.xml | 24 ------------------- .../Collections/Generic/Comparer.NativeAot.cs | 3 ++- .../Generic/EqualityComparer.NativeAot.cs | 3 ++- .../Reflection/Runtime/General/TypeUnifier.cs | 2 ++ .../src/System/RuntimeType.cs | 1 + .../src/ILLink/ILLink.Substitutions.xml | 5 ---- .../StackTraceMetadata/StackTraceMetadata.cs | 3 ++- .../src/ILLink/ILLink.Substitutions.xml | 10 -------- .../src/ServiceProvider.cs | 1 + .../src/ILLink/ILLink.Substitutions.xml | 7 ------ .../DesigntimeLicenseContextSerializer.cs | 1 + .../ILLink/ILLink.Substitutions.Shared.xml | 3 --- .../src/System/Diagnostics/Metrics/Meter.cs | 2 ++ .../src/ILLink/ILLink.Substitutions.xml | 7 ------ .../System/Dynamic/Utils/DelegateHelpers.cs | 2 +- .../ILLink/ILLink.Substitutions.mobile.xml | 8 ------- .../Net/Http/HttpClientHandler.AnyMobile.cs | 1 + .../src/ILLink/ILLink.Substitutions.xml | 7 ------ .../Net/NegotiateAuthenticationPal.Unix.cs | 2 ++ .../src/ILLink/ILLink.Substitutions.OSX.xml | 7 ------ .../ILLink/ILLink.Substitutions.Shared.xml | 23 ------------------ .../ILLink/ILLink.Substitutions.Windows.xml | 8 ------- .../InteropServices/ComponentActivator.cs | 1 + .../src/System/Diagnostics/StackTrace.cs | 1 + .../System/Diagnostics/Tracing/EventSource.cs | 3 ++- .../src/System/LocalAppContextSwitches.cs | 2 ++ .../src/System/Resources/ResourceReader.cs | 1 + .../src/System/StartupHookProvider.cs | 1 + .../src/System/Threading/AutoreleasePool.cs | 2 ++ .../src/System/Threading/Tasks/Task.cs | 1 + .../System/Threading/ThreadPool.Windows.cs | 2 ++ .../src/ILLink/ILLink.Substitutions.xml | 8 ------- .../Xml/Core/LocalAppContextSwitches.cs | 2 ++ .../src/ILLink/ILLink.Substitutions.xml | 10 -------- .../InteropServices/Marshalling/ComObject.cs | 3 +++ .../ref/System.Runtime.Loader.cs | 1 + .../src/ILLink/ILLink.Substitutions.xml | 7 ------ .../Serialization/LocalAppContextSwitches.cs | 2 ++ .../System.Text.Json/ref/System.Text.Json.cs | 1 + .../src/ILLink/ILLink.Substitutions.xml | 8 ------- .../Serialization/JsonSerializer.Helpers.cs | 1 + .../Reflection/Metadata/MetadataUpdater.cs | 2 ++ 46 files changed, 46 insertions(+), 157 deletions(-) delete mode 100644 src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml delete mode 100644 src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/Microsoft.Extensions.DependencyInjection/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.mobile.xml delete mode 100644 src/libraries/System.Net.Security/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml delete mode 100644 src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml delete mode 100644 src/libraries/System.Private.Xml/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.Runtime.InteropServices/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.Runtime.Serialization.Formatters/src/ILLink/ILLink.Substitutions.xml delete mode 100644 src/libraries/System.Text.Json/src/ILLink/ILLink.Substitutions.xml diff --git a/src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml b/src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml deleted file mode 100644 index 28a6da5f793ad6..00000000000000 --- a/src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs index 4a7d0a88c19962..6929c4752ed13c 100644 --- a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs +++ b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs @@ -15,6 +15,7 @@ namespace Internal.Runtime.InteropServices [SupportedOSPlatform("windows")] internal static class InMemoryAssemblyLoader { + [FeatureSwitchDefinition("System.Runtime.InteropServices.EnableCppCLIHostActivation")] private static bool IsSupported { get; } = InitializeIsSupported(); private static bool InitializeIsSupported() => AppContext.TryGetSwitch("System.Runtime.InteropServices.EnableCppCLIHostActivation", out bool isSupported) ? isSupported : true; diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs index ff1c5b855032c4..413a970afcf622 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -59,6 +60,7 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDel /// /// Returns true if the apply assembly update is enabled and available. /// + [FeatureSwitchDefinition("System.Reflection.Metadata.MetadataUpdater.IsSupported")] public static bool IsSupported { get; } = IsApplyUpdateSupported(); } } diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs index d9913b6b6d9b80..1dde789a5cad46 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs @@ -330,6 +330,7 @@ internal static unsafe bool IsPinnable(object? obj) => (obj == null) || !RuntimeHelpers.GetMethodTable(obj)->ContainsGCPointers; #if TARGET_WINDOWS + [FeatureSwitchDefinition("System.Runtime.InteropServices.BuiltInComInterop.IsSupported")] internal static bool IsBuiltInComSupported { get; } = IsBuiltInComSupportedInternal(); [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "MarshalNative_IsBuiltInComSupported")] diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml b/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 91859db1b0f80e..00000000000000 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/Comparer.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/Comparer.NativeAot.cs index c14dc49f0e61aa..1b6f63912e5b6d 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/Comparer.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/Comparer.NativeAot.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #nullable enable +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; @@ -12,7 +13,7 @@ namespace System.Collections.Generic { public abstract partial class Comparer : IComparer, IComparer { - // The AOT compiler can flip this to false under certain circumstances. + [FeatureSwitchDefinition("System.Collections.Generic.DefaultComparers")] private static bool SupportsGenericIComparableInterfaces => true; [Intrinsic] diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.NativeAot.cs index b7d79959332de1..0e06ab4da79e11 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/EqualityComparer.NativeAot.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #nullable enable +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; @@ -12,7 +13,7 @@ namespace System.Collections.Generic { public abstract partial class EqualityComparer : IEqualityComparer, IEqualityComparer { - // The AOT compiler can flip this to false under certain circumstances. + [FeatureSwitchDefinition("System.Collections.Generic.DefaultComparers")] private static bool SupportsGenericIEquatableInterfaces => true; [Intrinsic] diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs index aca104df2b5247..cc1855f53408dd 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Concurrent; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Reflection.Runtime.General; using System.Reflection.Runtime.MethodInfos; @@ -36,6 +37,7 @@ namespace System.Reflection.Runtime.General { internal static partial class TypeUnifier { + [FeatureSwitchDefinition("System.Reflection.IsTypeConstructionEagerlyValidated")] // This can be replaced at native compile time using a feature switch. internal static bool IsTypeConstructionEagerlyValidated => true; diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs index 59423d258179c7..76d257a87acd5b 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs @@ -46,6 +46,7 @@ internal void Free() RuntimeImports.RhHandleFree(_runtimeTypeInfoHandle); } + [FeatureSwitchDefinition("System.Reflection")] private static bool IsReflectionDisabled => false; private static bool DoNotThrowForNames => AppContext.TryGetSwitch("Switch.System.Reflection.Disabled.DoNotThrowForNames", out bool doNotThrow) && doNotThrow; diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 3d124ed9adef52..00000000000000 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs index 15c65d5e9dd63c..f2042dbc388205 100644 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection.Runtime.General; using Internal.Metadata.NativeFormat; @@ -186,7 +187,7 @@ private static string FormatAssemblyName(MetadataReader reader, ScopeReferenceHa return $"{reader.GetString(scopeRef.Name)}, Version={scopeRef.MajorVersion}.{scopeRef.MinorVersion}.{scopeRef.BuildNumber}.{scopeRef.RevisionNumber}"; } - // Can be rewritten to false through a feature switch. + [FeatureSwitchDefinition("System.Reflection.IsReflectionExecutionAvailable")] private static bool IsReflectionExecutionAvailable() => true; /// diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ILLink/ILLink.Substitutions.xml b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 6aa354ee23683c..00000000000000 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs index ff5efbe98cf334..92c8952125a61d 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs @@ -37,6 +37,7 @@ public sealed class ServiceProvider : IServiceProvider, IKeyedServiceProvider, I internal static bool VerifyOpenGenericServiceTrimmability { get; } = AppContext.TryGetSwitch("Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability", out bool verifyOpenGenerics) ? verifyOpenGenerics : false; + [FeatureSwitchDefinition("Microsoft.Extensions.DependencyInjection.DisableDynamicEngine")] internal static bool DisableDynamicEngine { get; } = AppContext.TryGetSwitch("Microsoft.Extensions.DependencyInjection.DisableDynamicEngine", out bool disableDynamicEngine) ? disableDynamicEngine : false; diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index d5df6acfa1cbc4..00000000000000 --- a/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs index 9c23426554eafa..8949472330c6e0 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs @@ -17,6 +17,7 @@ public class DesigntimeLicenseContextSerializer { internal const byte BinaryWriterMagic = 255; + [FeatureSwitchDefinition("System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization")] private static bool EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization { get; } = AppContext.TryGetSwitch("System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization", out bool isEnabled) ? isEnabled : false; // Not creatable. diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/ILLink/ILLink.Substitutions.Shared.xml b/src/libraries/System.Diagnostics.DiagnosticSource/src/ILLink/ILLink.Substitutions.Shared.xml index b67ac8623c402a..5580f696621c58 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/ILLink/ILLink.Substitutions.Shared.xml +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/ILLink/ILLink.Substitutions.Shared.xml @@ -1,8 +1,5 @@ - - - diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs index a80e0f478953ed..7afc120baebe21 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Threading; namespace System.Diagnostics.Metrics @@ -20,6 +21,7 @@ public class Meter : IDisposable internal bool Disposed { get; private set; } + [FeatureSwitchDefinition("System.Diagnostics.Metrics.Meter.IsSupported")] internal static bool IsSupported { get; } = InitializeIsSupported(); private static bool InitializeIsSupported() => diff --git a/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index b64cc2d765d67c..00000000000000 --- a/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs index c90f2bdad70f5b..ef812058dc5025 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs @@ -13,7 +13,7 @@ namespace System.Dynamic.Utils { internal static class DelegateHelpers { - // This can be flipped to false using feature switches at publishing time + [FeatureSwitchDefinition("System.Linq.Expressions.CanEmitObjectArrayDelegate")] internal static bool CanEmitObjectArrayDelegate => true; // Separate class so that the it can be trimmed away and doesn't get conflated diff --git a/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.mobile.xml b/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.mobile.xml deleted file mode 100644 index 208bba9a30af6c..00000000000000 --- a/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.mobile.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs index a8f7613b7e0834..6037df88bef807 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs @@ -789,6 +789,7 @@ private void ThrowForModifiedManagedSslOptionsIfStarted() _socketHandler!.SslOptions = _socketHandler!.SslOptions; } + [FeatureSwitchDefinition("System.Net.Http.UseNativeHttpHandler")] private static bool IsNativeHandlerEnabled => RuntimeSettingParser.QueryRuntimeSettingSwitch( "System.Net.Http.UseNativeHttpHandler", false); diff --git a/src/libraries/System.Net.Security/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Net.Security/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 8c56e81a9bb768..00000000000000 --- a/src/libraries/System.Net.Security/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs b/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs index e1735a65a6f97e..77c3a3454b1ce6 100644 --- a/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs +++ b/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs @@ -21,6 +21,8 @@ internal partial class NegotiateAuthenticationPal { private static readonly Lazy _hasSystemNetSecurityNative = new Lazy(CheckHasSystemNetSecurityNative); internal static bool HasSystemNetSecurityNative => _hasSystemNetSecurityNative.Value; + + [FeatureSwitchDefinition("System.Net.Security.UseManagedNtlm")] private static bool UseManagedNtlm { get; } = AppContext.TryGetSwitch("System.Net.Security.UseManagedNtlm", out bool useManagedNtlm) ? useManagedNtlm : diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml deleted file mode 100644 index 3b747687397c0b..00000000000000 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml index c6f8d232dc46dd..1dfb1d930c587d 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml @@ -1,18 +1,11 @@ - - - - - - - @@ -23,27 +16,11 @@ - - - - - - - - - - - - - - - - diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml deleted file mode 100644 index 29c26957ff6ee5..00000000000000 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Windows.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index 0fef70a8c2aa99..7634a76f429408 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -29,6 +29,7 @@ internal static partial class ComponentActivator // To indicate the specific error when IsSupported is false private const int HostFeatureDisabled = unchecked((int)0x800080a7); + [FeatureSwitchDefinition("System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting")] private static bool IsSupported { get; } = InitializeIsSupported(); private static bool InitializeIsSupported() => AppContext.TryGetSwitch("System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting", out bool isSupported) ? isSupported : true; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs index 7fdfef8f6d3467..8bf344f4e73356 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs @@ -17,6 +17,7 @@ namespace System.Diagnostics /// public partial class StackTrace { + [FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsSupported")] internal static bool IsSupported { get; } = InitializeIsSupported(); private static bool InitializeIsSupported() => diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index e765a1df9209f5..350dfaa9545ba4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -224,12 +224,13 @@ internal sealed class EventSourceAutoGenerateAttribute : Attribute [DynamicallyAccessedMembers(ManifestMemberTypes)] public partial class EventSource : IDisposable { - + [FeatureSwitchDefinition("System.Diagnostics.Tracing.EventSource.IsSupported")] internal static bool IsSupported { get; } = InitializeIsSupported(); private static bool InitializeIsSupported() => AppContext.TryGetSwitch("System.Diagnostics.Tracing.EventSource.IsSupported", out bool isSupported) ? isSupported : true; + [FeatureSwitchDefinition("System.Diagnostics.Metrics.Meter.IsSupported")] internal static bool IsMeterSupported { get; } = InitializeIsMeterSupported(); private static bool InitializeIsMeterSupported() => diff --git a/src/libraries/System.Private.CoreLib/src/System/LocalAppContextSwitches.cs b/src/libraries/System.Private.CoreLib/src/System/LocalAppContextSwitches.cs index 1e6e67af54bdc1..7392f64bd801ed 100644 --- a/src/libraries/System.Private.CoreLib/src/System/LocalAppContextSwitches.cs +++ b/src/libraries/System.Private.CoreLib/src/System/LocalAppContextSwitches.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace System @@ -8,6 +9,7 @@ namespace System internal static partial class LocalAppContextSwitches { private static int s_enableUnsafeUTF7Encoding; + [FeatureSwitchDefinition("System.Text.Encoding.EnableUnsafeUTF7Encoding")] public static bool EnableUnsafeUTF7Encoding { [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs index 582c072efebd5b..af37166b8cb2ac 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs @@ -140,6 +140,7 @@ public sealed partial class ReadResources(); } + [FeatureSwitchDefinition("System.Resources.ResourceManager.AllowCustomResourceTypes")] internal static bool AllowCustomResourceTypes { get; } = AppContext.TryGetSwitch("System.Resources.ResourceManager.AllowCustomResourceTypes", out bool allowReflection) ? allowReflection : true; public void Close() diff --git a/src/libraries/System.Private.CoreLib/src/System/StartupHookProvider.cs b/src/libraries/System.Private.CoreLib/src/System/StartupHookProvider.cs index 4683f6b19ca277..5a5a6db49d8585 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StartupHookProvider.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StartupHookProvider.cs @@ -18,6 +18,7 @@ internal static partial class StartupHookProvider private const string InitializeMethodName = "Initialize"; private const string DisallowedSimpleAssemblyNameSuffix = ".dll"; + [FeatureSwitchDefinition("System.StartupHookProvider.IsSupported")] private static bool IsSupported => AppContext.TryGetSwitch("System.StartupHookProvider.IsSupported", out bool isSupported) ? isSupported : true; private struct StartupHookNameOrPath diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/AutoreleasePool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/AutoreleasePool.cs index dc1e266ca30958..59cabf533971c4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/AutoreleasePool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/AutoreleasePool.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Threading { @@ -26,6 +27,7 @@ private static bool CheckEnableAutoreleasePool() #endif } + [FeatureSwitchDefinition("System.Threading.Thread.EnableAutoreleasePool")] public static bool EnableAutoreleasePool { get; } = CheckEnableAutoreleasePool(); [ThreadStatic] diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 56d8acf0cd8ff4..0febf7376f39f9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -819,6 +819,7 @@ private protected virtual bool ShouldNotifyDebuggerOfWaitCompletion /// Gets whether the task's debugger notification for wait completion bit is set. /// true if the bit is set; false if it's not set. + [FeatureSwitchDefinition("System.Diagnostics.Debugger.IsSupported")] internal bool IsWaitNotificationEnabled => // internal only to enable unit tests; would otherwise be private (m_stateFlags & (int)TaskStateFlags.WaitCompletionNotification) != 0; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index 0da875498afc18..9006732641d149 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -10,6 +11,7 @@ namespace System.Threading { public static partial class ThreadPool { + [FeatureSwitchDefinition("System.Threading.ThreadPool.UseWindowsThreadPool")] internal static bool UseWindowsThreadPool { get; } = AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool"); diff --git a/src/libraries/System.Private.Xml/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Private.Xml/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 52cf62fc636186..00000000000000 --- a/src/libraries/System.Private.Xml/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs index a95f9105051da1..88d9fbd3419f4a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using SwitchesHelpers = System.LocalAppContextSwitches; @@ -59,6 +60,7 @@ public static bool AllowDefaultResolver } private static int s_isNetworkingEnabledByDefault; + [FeatureSwitchDefinition("System.Xml.XmlResolver.IsNetworkingEnabledByDefault")] public static bool IsNetworkingEnabledByDefault { [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/libraries/System.Runtime.InteropServices/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Runtime.InteropServices/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 958b0e0280bb1d..00000000000000 --- a/src/libraries/System.Runtime.InteropServices/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs index a88f3edaecff29..1294b6fc6e921e 100644 --- a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs +++ b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs @@ -16,7 +16,10 @@ namespace System.Runtime.InteropServices.Marshalling /// public sealed unsafe class ComObject : IDynamicInterfaceCastable, IUnmanagedVirtualMethodTableProvider, ComImportInteropInterfaceDetailsStrategy.IComImportAdapter { + [FeatureSwitchDefinition("System.Runtime.InteropServices.BuiltInComInterop.IsSupported")] internal static bool BuiltInComSupported { get; } = AppContext.TryGetSwitch("System.Runtime.InteropServices.BuiltInComInterop.IsSupported", out bool supported) ? supported : true; + + [FeatureSwitchDefinition("System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop")] internal static bool ComImportInteropEnabled { get; } = AppContext.TryGetSwitch("System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop", out bool enabled) ? enabled : false; private readonly void* _instancePointer; diff --git a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs index e5c08f6132c8ea..a272e40c33db39 100644 --- a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs +++ b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs @@ -16,6 +16,7 @@ public static partial class AssemblyExtensions public static partial class MetadataUpdater { public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDelta, ReadOnlySpan ilDelta, ReadOnlySpan pdbDelta) { throw null; } + [System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute("System.Reflection.Metadata.MetadataUpdater.IsSupported")] public static bool IsSupported { get { throw null; } } } [System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)] diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Runtime.Serialization.Formatters/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 891fc4c11e4b84..00000000000000 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/LocalAppContextSwitches.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/LocalAppContextSwitches.cs index eead42d65a8c0d..169eb991b71d9c 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/LocalAppContextSwitches.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/LocalAppContextSwitches.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace System @@ -8,6 +9,7 @@ namespace System internal static partial class LocalAppContextSwitches { private static int s_binaryFormatterEnabled; + [FeatureSwitchDefinition("System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization")] public static bool BinaryFormatterEnabled { [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.cs b/src/libraries/System.Text.Json/ref/System.Text.Json.cs index d1394f939f1a1d..ab33effd894ffe 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.cs +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.cs @@ -208,6 +208,7 @@ public readonly partial struct JsonReaderState } public static partial class JsonSerializer { + [System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault")] public static bool IsReflectionEnabledByDefault { get { throw null; } } public static object? Deserialize(System.IO.Stream utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] diff --git a/src/libraries/System.Text.Json/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Text.Json/src/ILLink/ILLink.Substitutions.xml deleted file mode 100644 index 026bbf9f136024..00000000000000 --- a/src/libraries/System.Text.Json/src/ILLink/ILLink.Substitutions.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs index f654826f5b0b21..0b3301fcc0a125 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Helpers.cs @@ -21,6 +21,7 @@ public static partial class JsonSerializer /// The value of the property is backed by the "System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault" /// setting and defaults to if unset. /// + [FeatureSwitchDefinition("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault")] public static bool IsReflectionEnabledByDefault { get; } = AppContext.TryGetSwitch( switchName: "System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs index 013a51fe11b75f..67306e03081e28 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace System.Reflection.Metadata @@ -49,6 +50,7 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDel internal static string GetCapabilities() => s_ApplyUpdateCapabilities.Value; + [FeatureSwitchDefinition("System.Reflection.Metadata.MetadataUpdater.IsSupported")] public static bool IsSupported { get; } = ApplyUpdateEnabled(justComponentCheck: 0) != 0; private static readonly Lazy s_ApplyUpdateCapabilities = new Lazy(InitializeApplyUpdateCapabilities); From 4e0259a787e8cba000f0c179a80c13b9079ee502 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 20 Aug 2024 11:02:19 -0700 Subject: [PATCH 2/9] Fix project files --- .../System.Private.CoreLib/System.Private.CoreLib.csproj | 1 - .../src/System.Private.StackTraceMetadata.csproj | 4 ---- .../src/Microsoft.Extensions.DependencyInjection.csproj | 4 ---- .../src/System.ComponentModel.TypeConverter.csproj | 4 ---- .../src/System.Linq.Expressions.csproj | 4 ---- src/libraries/System.Net.Http/src/System.Net.Http.csproj | 4 ---- .../System.Net.Security/src/System.Net.Security.csproj | 1 - .../src/System.Private.CoreLib.Shared.projitems | 2 -- .../System.Private.Xml/src/System.Private.Xml.csproj | 4 ---- .../src/System.Runtime.InteropServices.csproj | 4 ---- .../src/System.Runtime.Serialization.Formatters.csproj | 4 ---- src/libraries/System.Text.Json/src/System.Text.Json.csproj | 4 ---- 12 files changed, 40 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 5ac4d2d78b58ec..f1e39865f2165f 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -25,7 +25,6 @@ - diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj index cc44031e9ac552..cd40e0ec8ba54d 100644 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj @@ -4,10 +4,6 @@ false - - - - diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj index 6dc4c5cd9ce94d..62c36a5b5bf15d 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj @@ -18,10 +18,6 @@ '$(ILEmitBackendSaveAssemblies)' == 'true'">$(DefineConstants);SAVE_ASSEMBLIES - - - - diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index 6979742610c466..874d860b1bdcc0 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -7,10 +7,6 @@ false - - - - diff --git a/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj index 66a070211ddca4..d06dd2cabb1b9e 100644 --- a/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj +++ b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj @@ -12,10 +12,6 @@ false - - - - diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index c6af468c253228..f127cf1f5733ef 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -28,10 +28,6 @@ - - - - diff --git a/src/libraries/System.Net.Security/src/System.Net.Security.csproj b/src/libraries/System.Net.Security/src/System.Net.Security.csproj index 37d2d52b4f47b4..ecf71f7c0f5c97 100644 --- a/src/libraries/System.Net.Security/src/System.Net.Security.csproj +++ b/src/libraries/System.Net.Security/src/System.Net.Security.csproj @@ -295,7 +295,6 @@ - diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 412fb8ba8b8644..122a3f04809671 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -58,9 +58,7 @@ - - diff --git a/src/libraries/System.Private.Xml/src/System.Private.Xml.csproj b/src/libraries/System.Private.Xml/src/System.Private.Xml.csproj index a78f7c666e030b..67233800dded25 100644 --- a/src/libraries/System.Private.Xml/src/System.Private.Xml.csproj +++ b/src/libraries/System.Private.Xml/src/System.Private.Xml.csproj @@ -7,10 +7,6 @@ false - - - - diff --git a/src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj b/src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj index 4a470747ab1128..41db022b08037d 100644 --- a/src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj +++ b/src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj @@ -76,10 +76,6 @@ - - - - diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index ff0f8cab28fdf6..983534829bff9f 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -18,10 +18,6 @@ true - - - - diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj index 8d0da4abcfc9ab..1bba3aa9dccf84 100644 --- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj @@ -19,10 +19,6 @@ The System.Text.Json library is built-in as part of the shared framework in .NET $(NoWarn);nullable - - - - From 75bf9f4ecdf04947926aef60ee8deb7e1931078d Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 20 Aug 2024 11:22:16 -0700 Subject: [PATCH 3/9] Missed one --- .../System.Private.CoreLib/src/System.Private.CoreLib.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index 8cb3c82645e695..cd8d656f0efce2 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -8,7 +8,6 @@ - From c00e11b6f60d401fc1e9385884914984e4d6f9f8 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 20 Aug 2024 11:54:47 -0700 Subject: [PATCH 4/9] Fix native AOT feature switches - IsReflectionExecutionAvaliable shouldn't have used FeatureSwitchDefinitionAttribute because it's not a property - Added missing FeatureSwitchDefinitionAttribute to MetadataUpdater.IsSupported --- .../src/System/Reflection/Metadata/MetadataUpdater.cs | 3 +++ .../src/ILLink/ILLink.Substitutions.xml | 5 +++++ .../src/Internal/StackTraceMetadata/StackTraceMetadata.cs | 1 - .../src/System.Private.StackTraceMetadata.csproj | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs index dac94886d752c5..fa929ccba5d438 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; + namespace System.Reflection.Metadata { public static class MetadataUpdater @@ -10,6 +12,7 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDel throw new PlatformNotSupportedException(); } + [FeatureSwitchDefinition("System.Reflection.Metadata.MetadataUpdater.IsSupported")] public static bool IsSupported => false; } } diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml new file mode 100644 index 00000000000000..3d124ed9adef52 --- /dev/null +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/ILLink/ILLink.Substitutions.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs index f2042dbc388205..1f72256082d9db 100644 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs @@ -187,7 +187,6 @@ private static string FormatAssemblyName(MetadataReader reader, ScopeReferenceHa return $"{reader.GetString(scopeRef.Name)}, Version={scopeRef.MajorVersion}.{scopeRef.MinorVersion}.{scopeRef.BuildNumber}.{scopeRef.RevisionNumber}"; } - [FeatureSwitchDefinition("System.Reflection.IsReflectionExecutionAvailable")] private static bool IsReflectionExecutionAvailable() => true; /// diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj index cd40e0ec8ba54d..cc44031e9ac552 100644 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/System.Private.StackTraceMetadata.csproj @@ -4,6 +4,10 @@ false + + + + From 33695c71e503e540cb2882cd229c67f9bf1545b6 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 20 Aug 2024 11:56:20 -0700 Subject: [PATCH 5/9] Cleanup --- .../src/Internal/StackTraceMetadata/StackTraceMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs index 1f72256082d9db..15c65d5e9dd63c 100644 --- a/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs +++ b/src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Reflection.Runtime.General; using Internal.Metadata.NativeFormat; @@ -187,6 +186,7 @@ private static string FormatAssemblyName(MetadataReader reader, ScopeReferenceHa return $"{reader.GetString(scopeRef.Name)}, Version={scopeRef.MajorVersion}.{scopeRef.MinorVersion}.{scopeRef.BuildNumber}.{scopeRef.RevisionNumber}"; } + // Can be rewritten to false through a feature switch. private static bool IsReflectionExecutionAvailable() => true; /// From f6d6578cf6b753338520cf2ce376a0eaff2297c5 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 21 Aug 2024 12:59:08 -0700 Subject: [PATCH 6/9] Fix System.Text.Json build --- src/libraries/System.Text.Json/ref/System.Text.Json.csproj | 1 + src/libraries/System.Text.Json/src/System.Text.Json.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.csproj b/src/libraries/System.Text.Json/ref/System.Text.Json.csproj index f578aa9af4f587..f4d1b4c75becb1 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.csproj @@ -17,6 +17,7 @@ + diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj index 1bba3aa9dccf84..d4a9190df16409 100644 --- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj @@ -349,6 +349,7 @@ The System.Text.Json library is built-in as part of the shared framework in .NET + From 3f3609b8c486d548e3fd490dbf863e7670928e05 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Thu, 22 Aug 2024 18:30:06 +0000 Subject: [PATCH 7/9] Fix allconfigurations libraries build --- .../src/Microsoft.Extensions.DependencyInjection.csproj | 4 ++++ .../src/System.Diagnostics.DiagnosticSource.csproj | 4 ++++ .../src/System.Resources.Extensions.csproj | 4 ++++ .../src/System.Runtime.Serialization.Formatters.csproj | 4 ++++ src/libraries/System.Text.Json/ref/System.Text.Json.csproj | 5 ++++- src/libraries/System.Text.Json/src/System.Text.Json.csproj | 3 ++- 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj index 62c36a5b5bf15d..21e3e191946247 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj @@ -43,6 +43,10 @@ + + + + diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj index 3db1dbd5a06efc..cba0c88d32369c 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj @@ -123,6 +123,10 @@ System.Diagnostics.DiagnosticSource + + + + diff --git a/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj b/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj index 03f9bc0c11d585..506df9b54bf577 100644 --- a/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj +++ b/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj @@ -88,6 +88,10 @@ System.Resources.Extensions.PreserializedResourceWriter + + + + + + + + diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.csproj b/src/libraries/System.Text.Json/ref/System.Text.Json.csproj index f4d1b4c75becb1..dc2e4d28e75f03 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.csproj @@ -17,7 +17,6 @@ - @@ -25,6 +24,10 @@ + + + + diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj index d4a9190df16409..1d301973915f4a 100644 --- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj @@ -349,7 +349,6 @@ The System.Text.Json library is built-in as part of the shared framework in .NET - @@ -366,6 +365,8 @@ The System.Text.Json library is built-in as part of the shared framework in .NET + + From 69c1c743020deff462b4131ff00a5fafe3d59295 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 23 Aug 2024 17:35:53 +0000 Subject: [PATCH 8/9] Revert System.Reflection FeatureSwitchDefinition --- .../src/ILLink/ILLink.Substitutions.xml | 7 +++++++ .../src/System.Private.CoreLib.csproj | 1 + .../System.Private.CoreLib/src/System/RuntimeType.cs | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml b/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml new file mode 100644 index 00000000000000..d5c7c1cddc97c5 --- /dev/null +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index e5eb797f1cf5d5..fc97632716fd2a 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -8,6 +8,7 @@ + diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs index 76d257a87acd5b..59423d258179c7 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs @@ -46,7 +46,6 @@ internal void Free() RuntimeImports.RhHandleFree(_runtimeTypeInfoHandle); } - [FeatureSwitchDefinition("System.Reflection")] private static bool IsReflectionDisabled => false; private static bool DoNotThrowForNames => AppContext.TryGetSwitch("Switch.System.Reflection.Disabled.DoNotThrowForNames", out bool doNotThrow) && doNotThrow; From cd6455e55f8f9d5f5d62254da47b3c71953c8361 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 23 Aug 2024 12:03:55 -0700 Subject: [PATCH 9/9] Update src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs Co-authored-by: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> --- .../src/ServiceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs index 92c8952125a61d..9c2dfdbb0dffb9 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs @@ -34,6 +34,7 @@ public sealed class ServiceProvider : IServiceProvider, IKeyedServiceProvider, I internal ServiceProviderEngineScope Root { get; } + [FeatureSwitchDefinition("Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability")] internal static bool VerifyOpenGenericServiceTrimmability { get; } = AppContext.TryGetSwitch("Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability", out bool verifyOpenGenerics) ? verifyOpenGenerics : false;