1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------
5 namespace System.IdentityModel
8 using System.Runtime.CompilerServices;
10 // When adding a quirk, name it such that false is new behavior and true is old behavior.
11 // You are opting IN to old behavior. The new behavior is default.
12 // For example, we want to enable the functionality to explicitly add a connection close header
13 // in 4.6 and above. So we set DisableExplicitConnectionCloseHeader to true if running 4.5.2 or less.
14 internal static class LocalAppContextSwitches
16 private const string EnableCachedEmptyDefaultAuthorizationContextString = "Switch.System.IdentityModel.EnableCachedEmptyDefaultAuthorizationContext";
17 private const string DisableMultipleDNSEntriesInSANCertificateString = "Switch.System.IdentityModel.DisableMultipleDNSEntriesInSANCertificate";
18 private const string DisableUpdatingRsaProviderTypeString = "Switch.System.IdentityModel.DisableUpdatingRsaProviderType";
20 private static int enableCachedEmptyDefaultAuthorizationContext;
21 private static int disableMultipleDNSEntriesInSANCertificate;
22 private static int disableUpdatingRsaProviderType;
24 public static bool EnableCachedEmptyDefaultAuthorizationContext
26 [MethodImpl(MethodImplOptions.AggressiveInlining)]
29 return LocalAppContext.GetCachedSwitchValue(EnableCachedEmptyDefaultAuthorizationContextString, ref enableCachedEmptyDefaultAuthorizationContext);
33 public static bool DisableMultipleDNSEntriesInSANCertificate
35 [MethodImpl(MethodImplOptions.AggressiveInlining)]
38 return LocalAppContext.GetCachedSwitchValue(DisableMultipleDNSEntriesInSANCertificateString, ref disableMultipleDNSEntriesInSANCertificate);
42 public static bool DisableUpdatingRsaProviderType
44 [MethodImpl(MethodImplOptions.AggressiveInlining)]
47 return LocalAppContext.GetCachedSwitchValue(DisableUpdatingRsaProviderTypeString, ref disableUpdatingRsaProviderType);
51 public static void SetDefaultsLessOrEqual_452()
53 #pragma warning disable BCL0012
54 // Define the switches that should be true for 4.5.2 or less, false for 4.6+.
55 LocalAppContext.DefineSwitchDefault(EnableCachedEmptyDefaultAuthorizationContextString, true);
56 #pragma warning restore BCL0012
59 public static void SetDefaultsLessOrEqual_46()
61 #pragma warning disable BCL0012
62 // Define the switches that should be true for 4.6 or less, false for 4.6.1+.
63 LocalAppContext.DefineSwitchDefault(DisableMultipleDNSEntriesInSANCertificateString, true);
64 #pragma warning restore BCL0012