1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System.Runtime;
using System.Runtime.CompilerServices;
namespace System
{
[FriendAccessAllowed]
internal static class CompatibilitySwitches
{
private static bool s_AreSwitchesSet;
#if FEATURE_CORECLR && !FEATURE_CORESYSTEM
private static bool s_isAppEarlierThanSilverlight4;
#endif //FEATURE_CORECLR && !FEATURE_CORESYSTEM
#if FEATURE_LEGACYNETCF
private static bool s_isAppEarlierThanWindowsPhone8;
private static bool s_isAppEarlierThanWindowsPhoneMango;
#endif //FEATURE_LEGACYNETCF
#if FEATURE_CORECLR
private static bool s_isAppSilverlight81; // The app targets SL8.1 version
private static bool s_useLatestBehaviorWhenTFMNotSpecified; // Which behavior to use when the TFM is not specified.
#endif //FEATURE_CORECLR
#if !FEATURE_CORECLR
private static bool s_isNetFx40TimeSpanLegacyFormatMode;
private static bool s_isNetFx40LegacySecurityPolicy;
private static bool s_isNetFx45LegacyManagedDeflateStream;
#endif //!FEATURE_CORECLR
public static bool IsCompatibilityBehaviorDefined
{
get
{
return s_AreSwitchesSet;
}
}
private static bool IsCompatibilitySwitchSet(string compatibilitySwitch)
{
bool? result = AppDomain.CurrentDomain.IsCompatibilitySwitchSet(compatibilitySwitch);
return (result.HasValue && result.Value);
}
internal static void InitializeSwitches()
{
#if FEATURE_CORECLR && !FEATURE_CORESYSTEM
s_isAppEarlierThanSilverlight4 = IsCompatibilitySwitchSet("APP_EARLIER_THAN_SL4.0");
#endif //FEATURE_CORECLR && !FEATURE_CORESYSTEM
#if FEATURE_CORECLR
s_isAppSilverlight81 = IsCompatibilitySwitchSet("WindowsPhone_5.1.0.0");
s_useLatestBehaviorWhenTFMNotSpecified = IsCompatibilitySwitchSet("UseLatestBehaviorWhenTFMMissing");
#endif //FEATURE_CORECLR
#if FEATURE_LEGACYNETCF
s_isAppEarlierThanWindowsPhoneMango = IsCompatibilitySwitchSet("WindowsPhone_3.7.0.0");
s_isAppEarlierThanWindowsPhone8 = s_isAppEarlierThanWindowsPhoneMango ||
IsCompatibilitySwitchSet("WindowsPhone_3.8.0.0");
#endif //FEATURE_LEGACYNETCF
#if !FEATURE_CORECLR
s_isNetFx40TimeSpanLegacyFormatMode = IsCompatibilitySwitchSet("NetFx40_TimeSpanLegacyFormatMode");
s_isNetFx40LegacySecurityPolicy = IsCompatibilitySwitchSet("NetFx40_LegacySecurityPolicy");
s_isNetFx45LegacyManagedDeflateStream = IsCompatibilitySwitchSet("NetFx45_LegacyManagedDeflateStream");
#endif //FEATURE_CORECLR
s_AreSwitchesSet = true;
}
public static bool IsAppEarlierThanSilverlight4
{
get
{
#if FEATURE_CORECLR && !FEATURE_CORESYSTEM
return s_isAppEarlierThanSilverlight4;
#else
return false;
#endif //FEATURE_CORECLR && !FEATURE_CORESYSTEM
}
}
#if FEATURE_CORECLR
/// <summary>
/// This property returns whether the app is hosted under SL 8.1 version
/// </summary>
internal static bool IsAppSilverlight81
{
get
{
// PS - Do not use this property for adding quirks. Please use the exposed properties of BinaryCompatiblity class instead.
return s_isAppSilverlight81;
}
}
/// <summary>
/// This property returns whether to give the latest behavior when the TFM is missing
/// </summary>
internal static bool UseLatestBehaviorWhenTFMNotSpecified
{
get
{
return s_useLatestBehaviorWhenTFMNotSpecified;
}
}
#endif //FEATURE_CORECLR
public static bool IsAppEarlierThanWindowsPhone8
{
get
{
#if FEATURE_LEGACYNETCF
return s_isAppEarlierThanWindowsPhone8;
#else
return false;
#endif //FEATURE_LEGACYNETCF
}
}
public static bool IsAppEarlierThanWindowsPhoneMango
{
get
{
#if FEATURE_LEGACYNETCF
return s_isAppEarlierThanWindowsPhoneMango;
#else
return false;
#endif //FEATURE_LEGACYNETCF
}
}
public static bool IsNetFx40TimeSpanLegacyFormatMode
{
get
{
#if !FEATURE_CORECLR
return s_isNetFx40TimeSpanLegacyFormatMode;
#else
return false;
#endif //!FEATURE_CORECLR
}
}
public static bool IsNetFx40LegacySecurityPolicy
{
get
{
#if !FEATURE_CORECLR
return s_isNetFx40LegacySecurityPolicy;
#else
return false;
#endif //!FEATURE_CORECLR
}
}
public static bool IsNetFx45LegacyManagedDeflateStream
{
get
{
#if !FEATURE_CORECLR
return s_isNetFx45LegacyManagedDeflateStream;
#else
return false;
#endif //!FEATURE_CORECLR
}
}
}
}
|