Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.IdentityModel / System / IdentityModel / LocalAppContextSwitches.cs
1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //------------------------------------------------------------
4
5 #pragma warning disable 0436 //Disable the type conflict warning for the types used by LocalAppContext framework (Quirking)
6 namespace System.IdentityModel
7 {
8     using System;
9     using System.Runtime.CompilerServices;
10
11     // When adding a quirk, name it such that false is new behavior and true is old behavior.
12     // You are opting IN to old behavior. The new behavior is default.
13     // For example, we want to enable the functionality to explicitly add a connection close header
14     // in 4.6 and above. So we set DisableExplicitConnectionCloseHeader to true if running 4.5.2 or less.
15     internal static class LocalAppContextSwitches
16     {
17         private const string EnableCachedEmptyDefaultAuthorizationContextString = "Switch.System.IdentityModel.EnableCachedEmptyDefaultAuthorizationContext";
18         private const string DisableMultipleDNSEntriesInSANCertificateString = "Switch.System.IdentityModel.DisableMultipleDNSEntriesInSANCertificate";
19         private const string DisableUpdatingRsaProviderTypeString = "Switch.System.IdentityModel.DisableUpdatingRsaProviderType";
20         private const string DisableCngCertificatesString = "Switch.System.IdentityModel.DisableCngCertificates";
21
22         private static int enableCachedEmptyDefaultAuthorizationContext;
23         private static int disableMultipleDNSEntriesInSANCertificate;
24         private static int disableUpdatingRsaProviderType;
25         private static int disableCngCertificatesString;
26
27         public static bool EnableCachedEmptyDefaultAuthorizationContext
28         {
29             [MethodImpl(MethodImplOptions.AggressiveInlining)]
30             get
31             {
32                 return LocalAppContext.GetCachedSwitchValue(EnableCachedEmptyDefaultAuthorizationContextString, ref enableCachedEmptyDefaultAuthorizationContext);
33             }
34         }
35
36         public static bool DisableMultipleDNSEntriesInSANCertificate
37         {
38             [MethodImpl(MethodImplOptions.AggressiveInlining)]
39             get
40             {
41                 return LocalAppContext.GetCachedSwitchValue(DisableMultipleDNSEntriesInSANCertificateString, ref disableMultipleDNSEntriesInSANCertificate);
42             }
43         }
44
45         public static bool DisableUpdatingRsaProviderType
46         {
47             [MethodImpl(MethodImplOptions.AggressiveInlining)]
48             get
49             {
50                 return LocalAppContext.GetCachedSwitchValue(DisableUpdatingRsaProviderTypeString, ref disableUpdatingRsaProviderType);
51             }
52         }
53
54         public static bool DisableCngCertificates
55         {
56             [MethodImpl(MethodImplOptions.AggressiveInlining)]
57             get
58             {
59                 return LocalAppContext.GetCachedSwitchValue(DisableCngCertificatesString, ref disableCngCertificatesString);
60             }
61         }
62
63         public static void SetDefaultsLessOrEqual_452()
64         {
65 #pragma warning disable BCL0012
66             // Define the switches that should be true for 4.5.2 or less, false for 4.6+.
67             LocalAppContext.DefineSwitchDefault(EnableCachedEmptyDefaultAuthorizationContextString, true);
68 #pragma warning restore BCL0012
69         }
70
71         public static void SetDefaultsLessOrEqual_46()
72         {
73 #pragma warning disable BCL0012
74             // Define the switches that should be true for 4.6 or less, false for 4.6.1+.
75             LocalAppContext.DefineSwitchDefault(DisableMultipleDNSEntriesInSANCertificateString, true);
76 #pragma warning restore BCL0012
77         }
78
79         public static void SetDefaultsLessOrEqual_462()
80         {
81 #pragma warning disable BCL0012
82             // Define the switches that should be true for 4.6.2 or less, false for above 4.6.2.
83             LocalAppContext.DefineSwitchDefault(DisableCngCertificatesString, true);
84 #pragma warning restore BCL0012
85         }
86     }
87 }