diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
index 43bd4484b505a..8cdcb03995b5f 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/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 28a6da5f793ad..0000000000000
--- 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 4a7d0a88c1996..6929c4752ed13 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 ff1c5b855032c..413a970afcf62 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 d9913b6b6d9b8..1dde789a5cad4 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
index 91859db1b0f80..d5c7c1cddc97c 100644
--- a/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml
+++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.xml
@@ -1,22 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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 c14dc49f0e61a..1b6f63912e5b6 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 b7d79959332de..0e06ab4da79e1 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/Metadata/MetadataUpdater.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs
index dac94886d752c..fa929ccba5d43 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.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs
index aca104df2b524..cc1855f53408d 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/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 6aa354ee23683..0000000000000
--- 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/Microsoft.Extensions.DependencyInjection.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/src/Microsoft.Extensions.DependencyInjection.csproj
index 6dc4c5cd9ce94..21e3e19194624 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
-
-
-
-
@@ -47,6 +43,10 @@
+
+
+
+
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs
index ff5efbe98cf33..9c2dfdbb0dffb 100644
--- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs
@@ -34,9 +34,11 @@ 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;
+ [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 d5df6acfa1cbc..0000000000000
--- 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.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj
index 6979742610c46..874d860b1bdcc 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.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesigntimeLicenseContextSerializer.cs
index 9c23426554eaf..8949472330c6e 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 b67ac8623c402..5580f696621c5 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.DiagnosticSource.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
index 3db1dbd5a06ef..cba0c88d32369 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.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs
index a80e0f478953e..7afc120baebe2 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 b64cc2d765d67..0000000000000
--- 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.Linq.Expressions.csproj b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj
index 66a070211ddca..d06dd2cabb1b9 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.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs
index c90f2bdad70f5..ef812058dc502 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 208bba9a30af6..0000000000000
--- 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.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj
index c6af468c25322..f127cf1f5733e 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.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs
index a8f7613b7e083..6037df88bef80 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 8c56e81a9bb76..0000000000000
--- 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.Security.csproj b/src/libraries/System.Net.Security/src/System.Net.Security.csproj
index 37d2d52b4f47b..ecf71f7c0f5c9 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.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs b/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs
index e1735a65a6f97..77c3a3454b1ce 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 3b747687397c0..0000000000000
--- 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 c6f8d232dc46d..1dfb1d930c587 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 29c26957ff6ee..0000000000000
--- 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 0fef70a8c2aa9..7634a76f42940 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.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
index 8ab45e10dfa8b..5f1cc55b9929c 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
@@ -59,9 +59,7 @@
-
-
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 7fdfef8f6d346..8bf344f4e7335 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 48ad57547327c..0b727874ddc5a 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
@@ -283,12 +283,13 @@ public partial class EventSource : IDisposable
internal const string DuplicateSourceNamesSwitch = "System.Diagnostics.Tracing.EventSource.AllowDuplicateSourceNames";
private static readonly bool AllowDuplicateSourceNames = AppContext.TryGetSwitch(DuplicateSourceNamesSwitch, out bool isEnabled) ? isEnabled : false;
-
+ [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 1e6e67af54bdc..7392f64bd801e 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 582c072efebd5..af37166b8cb2a 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 4683f6b19ca27..5a5a6db49d858 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 dc1e266ca3095..59cabf533971c 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 56d8acf0cd8ff..0febf7376f39f 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 0da875498afc1..9006732641d14 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 52cf62fc63618..0000000000000
--- 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.Private.Xml.csproj b/src/libraries/System.Private.Xml/src/System.Private.Xml.csproj
index a78f7c666e030..67233800dded2 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.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs
index a95f9105051da..88d9fbd3419f4 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.Resources.Extensions/src/System.Resources.Extensions.csproj b/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj
index 03f9bc0c11d58..506df9b54bf57 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.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj b/src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj
index 4a470747ab112..41db022b08037 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.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs
index a88f3edaecff2..1294b6fc6e921 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 e5c08f6132c8e..a272e40c33db3 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 891fc4c11e4b8..0000000000000
--- 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.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
index ff0f8cab28fdf..ebe9cb673b0bd 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
-
-
-
-
@@ -98,4 +94,8 @@
+
+
+
+
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 eead42d65a8c0..169eb991b71d9 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 a75a8bb9dd264..c854cb27bed6b 100644
--- a/src/libraries/System.Text.Json/ref/System.Text.Json.cs
+++ b/src/libraries/System.Text.Json/ref/System.Text.Json.cs
@@ -209,6 +209,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/ref/System.Text.Json.csproj b/src/libraries/System.Text.Json/ref/System.Text.Json.csproj
index f578aa9af4f58..dc2e4d28e75f0 100644
--- a/src/libraries/System.Text.Json/ref/System.Text.Json.csproj
+++ b/src/libraries/System.Text.Json/ref/System.Text.Json.csproj
@@ -24,6 +24,10 @@
+
+
+
+
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 026bbf9f13602..0000000000000
--- 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.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
index 8d0da4abcfc9a..1d301973915f4 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
-
-
-
-
@@ -369,6 +365,8 @@ The System.Text.Json library is built-in as part of the shared framework in .NET
+
+
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 f654826f5b0b2..0b3301fcc0a12 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 013a51fe11b75..67306e03081e2 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);