[coop] Temporarily restore MonoThreadInfo when TLS destructor runs. Fixes #43099
[mono.git] / mcs / class / referencesource / System.IdentityModel / System / IdentityModel / LocalAppContextSwitches.cs
1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //------------------------------------------------------------
4
5 namespace System.IdentityModel
6 {
7     using System;
8     using System.Runtime.CompilerServices;
9
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
15     {
16         private const string EnableCachedEmptyDefaultAuthorizationContextString = "Switch.System.IdentityModel.EnableCachedEmptyDefaultAuthorizationContext";
17         private const string DisableMultipleDNSEntriesInSANCertificateString = "Switch.System.IdentityModel.DisableMultipleDNSEntriesInSANCertificate";
18
19         private static int enableCachedEmptyDefaultAuthorizationContext;
20         private static int disableMultipleDNSEntriesInSANCertificate;
21
22         public static bool EnableCachedEmptyDefaultAuthorizationContext
23         {
24             [MethodImpl(MethodImplOptions.AggressiveInlining)]
25             get
26             {
27                 return LocalAppContext.GetCachedSwitchValue(EnableCachedEmptyDefaultAuthorizationContextString, ref enableCachedEmptyDefaultAuthorizationContext);
28             }
29         }
30
31         public static bool DisableMultipleDNSEntriesInSANCertificate
32         {
33             [MethodImpl(MethodImplOptions.AggressiveInlining)]
34             get
35             {
36                 return LocalAppContext.GetCachedSwitchValue(DisableMultipleDNSEntriesInSANCertificateString, ref disableMultipleDNSEntriesInSANCertificate);
37             }
38         }
39
40         public static void SetDefaultsLessOrEqual_452()
41         {
42             // Define the switches that should be true for 4.5.2 or less, false for 4.6+.
43             LocalAppContext.DefineSwitchDefault(EnableCachedEmptyDefaultAuthorizationContextString, true);
44         }
45
46         public static void SetDefaultsLessOrEqual_46()
47         {
48             // Define the switches that should be true for 4.6 or less, false for 4.6.1+.
49             LocalAppContext.DefineSwitchDefault(DisableMultipleDNSEntriesInSANCertificateString, true);
50         }
51     }
52 }