diff options
Diffstat (limited to 'src/mscorlib/src/System/AppContext')
4 files changed, 47 insertions, 57 deletions
diff --git a/src/mscorlib/src/System/AppContext/AppContext.cs b/src/mscorlib/src/System/AppContext/AppContext.cs index 0b0643d7b4..41e44508f0 100644 --- a/src/mscorlib/src/System/AppContext/AppContext.cs +++ b/src/mscorlib/src/System/AppContext/AppContext.cs @@ -21,9 +21,6 @@ namespace System public static string BaseDirectory { -#if FEATURE_CORECLR - [System.Security.SecuritySafeCritical] -#endif get { // The value of APP_CONTEXT_BASE_DIRECTORY key has to be a string and it is not allowed to be any other type. @@ -41,14 +38,53 @@ namespace System } } -#if FEATURE_CORECLR - [System.Security.SecuritySafeCritical] -#endif public static object GetData(string name) { return AppDomain.CurrentDomain.GetData(name); } + public static void SetData(string name, object data) + { + AppDomain.CurrentDomain.SetData(name, data); + } + + public static event UnhandledExceptionEventHandler UnhandledException + { + add + { + AppDomain.CurrentDomain.UnhandledException += value; + } + + remove + { + AppDomain.CurrentDomain.UnhandledException -= value; + } + } + + public static event System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs> FirstChanceException + { + add + { + AppDomain.CurrentDomain.FirstChanceException += value; + } + remove + { + AppDomain.CurrentDomain.FirstChanceException -= value; + } + } + + public static event System.EventHandler ProcessExit + { + add + { + AppDomain.CurrentDomain.ProcessExit += value; + } + remove + { + AppDomain.CurrentDomain.ProcessExit -= value; + } + } + #region Switch APIs static AppContext() { @@ -65,9 +101,9 @@ namespace System public static bool TryGetSwitch(string switchName, out bool isEnabled) { if (switchName == null) - throw new ArgumentNullException("switchName"); + throw new ArgumentNullException(nameof(switchName)); if (switchName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName"); + throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(switchName)); // By default, the switch is not enabled. isEnabled = false; @@ -161,9 +197,9 @@ namespace System public static void SetSwitch(string switchName, bool isEnabled) { if (switchName == null) - throw new ArgumentNullException("switchName"); + throw new ArgumentNullException(nameof(switchName)); if (switchName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName"); + throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(switchName)); SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) | SwitchValueState.HasLookedForOverride; diff --git a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs index c80913e3a6..52bdf9d427 100644 --- a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs +++ b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs @@ -12,10 +12,6 @@ namespace System internal static readonly string SwitchNoAsyncCurrentCulture = "Switch.System.Globalization.NoAsyncCurrentCulture"; internal static readonly string SwitchThrowExceptionIfDisposedCancellationTokenSource = "Switch.System.Threading.ThrowExceptionIfDisposedCancellationTokenSource"; internal static readonly string SwitchPreserveEventListnerObjectIdentity = "Switch.System.Diagnostics.EventSource.PreserveEventListnerObjectIdentity"; -#if FEATURE_PATHCOMPAT - internal static readonly string SwitchUseLegacyPathHandling = "Switch.System.IO.UseLegacyPathHandling"; - internal static readonly string SwitchBlockLongPaths = "Switch.System.IO.BlockLongPaths"; -#endif // This is a partial method. Platforms can provide an implementation of it that will set override values // from whatever mechanism is available on that platform. If no implementation is provided, the compiler is going to remove the calls @@ -43,13 +39,7 @@ namespace System AppContext.DefineSwitchDefault(SwitchNoAsyncCurrentCulture, true); AppContext.DefineSwitchDefault(SwitchThrowExceptionIfDisposedCancellationTokenSource, true); } -#if FEATURE_PATHCOMPAT - if (version <= 40601) - { - AppContext.DefineSwitchDefault(SwitchUseLegacyPathHandling, true); - AppContext.DefineSwitchDefault(SwitchBlockLongPaths, true); - } -#endif + break; } case "WindowsPhone": diff --git a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs index 7ab7ffbc04..9f00e8148c 100644 --- a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs +++ b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs @@ -30,7 +30,6 @@ namespace System if (!TryParseFrameworkName(targetFrameworkMoniker, out identifier, out version, out profile)) { -#if FEATURE_CORECLR // If we can't parse the TFM or we don't have a TFM, default to latest behavior for all // switches (ie. all of them false). // If we want to use the latest behavior it is enough to set the value of the switch to string.Empty. @@ -39,11 +38,6 @@ namespace System // identifier we are simply saying -- don't turn on any switches, and we are going to get the latest // behavior for all the switches identifier = string.Empty; -#else - identifier = ".NETFramework"; - version = 40000; - profile = string.Empty; -#endif } } diff --git a/src/mscorlib/src/System/AppContext/AppContextSwitches.cs b/src/mscorlib/src/System/AppContext/AppContextSwitches.cs index 3a96ec2159..5fdd2bc1e6 100644 --- a/src/mscorlib/src/System/AppContext/AppContextSwitches.cs +++ b/src/mscorlib/src/System/AppContext/AppContextSwitches.cs @@ -39,36 +39,6 @@ namespace System } } -#if FEATURE_PATHCOMPAT - private static int _useLegacyPathHandling; - - /// <summary> - /// Use legacy path normalization logic and blocking of extended syntax. - /// </summary> - public static bool UseLegacyPathHandling - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return GetCachedSwitchValue(AppContextDefaultValues.SwitchUseLegacyPathHandling, ref _useLegacyPathHandling); - } - } - - private static int _blockLongPaths; - - /// <summary> - /// Throw PathTooLongException for paths greater than MAX_PATH or directories greater than 248 (as per CreateDirectory Win32 limitations) - /// </summary> - public static bool BlockLongPaths - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return GetCachedSwitchValue(AppContextDefaultValues.SwitchBlockLongPaths, ref _blockLongPaths); - } - } -#endif // FEATURE_PATHCOMPAT - // // Implementation details // |