You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@@ -7,7 +7,7 @@
|
||||
//
|
||||
// AggregateException.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// Public type to communicate multiple failures to an end-user.
|
||||
//
|
||||
|
@@ -8,6 +8,19 @@ using System.Collections.Generic;
|
||||
|
||||
namespace System
|
||||
{
|
||||
|
||||
//
|
||||
// The AppContext class consists of a collection of APIs that applications can use to reason about the context
|
||||
// in which they are running.
|
||||
//
|
||||
// One of the APIs that are available to the application (and the framework) are the ones related to the
|
||||
// configuration switches (SetSwitch, TryGetSwitch). Those APIs are used to set and retrieve the value of a switch.
|
||||
//
|
||||
// Inside the framework we use those APIs to provide backward compatibility for our in-place updates. In order for
|
||||
// that to work in as many cases as possible we have intentionally coded the APIs to use very low level concepts.
|
||||
// For instance, we are directly P/Invoking into the Registry calls and so that we don't initialize the infrastructure
|
||||
// for accessing registry. Doing that would allow us to use AppContext switches inside the Registry code.
|
||||
//
|
||||
public static class AppContext
|
||||
{
|
||||
[Flags]
|
||||
@@ -18,7 +31,13 @@ namespace System
|
||||
HasLookedForOverride = 0x4,
|
||||
UnknownValue = 0x8 // Has no default and could not find an override
|
||||
}
|
||||
|
||||
// The Dictionary is intentionally left without specifying the comparer. StringComparer.Ordinal for instance will
|
||||
// end up pulling in Globalization since all StringComparers are initialized in the static constructor (including the
|
||||
// ones that use CultureInfo).
|
||||
// Not specifying a comparer means that the dictionary will end up with a GenericEqualityComparer<string> comparer
|
||||
private static readonly Dictionary<string, SwitchValueState> s_switchMap = new Dictionary<string, SwitchValueState>();
|
||||
private static volatile bool s_defaultsInitialized = false;
|
||||
|
||||
public static string BaseDirectory
|
||||
{
|
||||
@@ -37,21 +56,35 @@ namespace System
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// Forward the value that is set on the current domain.
|
||||
return AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetData (string name)
|
||||
#if FEATURE_CORECLR
|
||||
[System.Security.SecuritySafeCritical]
|
||||
#endif
|
||||
public static object GetData(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return AppDomain.CurrentDomain.GetData(name);
|
||||
}
|
||||
|
||||
#region Switch APIs
|
||||
static AppContext()
|
||||
|
||||
private static void InitializeDefaultSwitchValues()
|
||||
{
|
||||
// populate the AppContext with the default set of values
|
||||
AppContextDefaultValues.PopulateDefaultValues();
|
||||
}
|
||||
// To save a method call into this method, we are first checking
|
||||
// the value of s_defaultsInitialized in the caller.
|
||||
lock (s_switchMap)
|
||||
{
|
||||
if (s_defaultsInitialized == false)
|
||||
{
|
||||
// populate the AppContext with the default set of values
|
||||
AppContextDefaultValues.PopulateDefaultValues();
|
||||
s_defaultsInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to get the value of the switch.
|
||||
@@ -66,6 +99,14 @@ namespace System
|
||||
if (switchName.Length == 0)
|
||||
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName");
|
||||
|
||||
if (s_defaultsInitialized == false)
|
||||
{
|
||||
InitializeDefaultSwitchValues();
|
||||
}
|
||||
#if DEBUG
|
||||
BCLDebug.Assert(s_defaultsInitialized == true, "AppContext defaults should have been initialized.");
|
||||
#endif
|
||||
|
||||
// By default, the switch is not enabled.
|
||||
isEnabled = false;
|
||||
|
||||
@@ -158,6 +199,14 @@ namespace System
|
||||
if (switchName.Length == 0)
|
||||
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName");
|
||||
|
||||
if (s_defaultsInitialized == false)
|
||||
{
|
||||
InitializeDefaultSwitchValues();
|
||||
}
|
||||
#if DEBUG
|
||||
BCLDebug.Assert(s_defaultsInitialized == true, "AppContext defaults should have been initialized.");
|
||||
#endif
|
||||
|
||||
SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue)
|
||||
| SwitchValueState.HasLookedForOverride;
|
||||
lock (s_switchMap)
|
||||
@@ -169,13 +218,30 @@ namespace System
|
||||
|
||||
/// <summary>
|
||||
/// This method is going to be called from the AppContextDefaultValues class when setting up the
|
||||
/// default values for the switches. !!!! This method is called during the static constructor so it does not
|
||||
/// take a lock !!!! If you are planning to use this outside of that, please ensure proper locking.
|
||||
/// default values for the switches.
|
||||
/// </summary>
|
||||
internal static void DefineSwitchDefault(string switchName, bool isEnabled)
|
||||
{
|
||||
#if DEBUG
|
||||
BCLDebug.Assert(System.Threading.Monitor.IsEntered(s_switchMap), "Expected the method to be called within a lock");
|
||||
#endif
|
||||
|
||||
s_switchMap[switchName] = isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is going to be called from the AppContextDefaultValues class when setting up the
|
||||
/// override default values for the switches.
|
||||
/// </summary>
|
||||
internal static void DefineSwitchOverride(string switchName, bool isEnabled)
|
||||
{
|
||||
#if DEBUG
|
||||
BCLDebug.Assert(System.Threading.Monitor.IsEntered(s_switchMap), "Expected the method to be called within a lock");
|
||||
#endif
|
||||
|
||||
s_switchMap[switchName] = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue)
|
||||
| SwitchValueState.HasLookedForOverride;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// ==++==
|
||||
// ==++==
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
@@ -15,9 +15,9 @@ namespace System
|
||||
internal static readonly string SwitchPreserveEventListnerObjectIdentity = "Switch.System.Diagnostics.EventSource.PreserveEventListnerObjectIdentity";
|
||||
internal static readonly string SwitchUseLegacyPathHandling = "Switch.System.IO.UseLegacyPathHandling";
|
||||
internal static readonly string SwitchBlockLongPaths = "Switch.System.IO.BlockLongPaths";
|
||||
internal static readonly string SwitchDoNotAddrOfCspParentWindowHandle = "Switch.System.Security.Cryptography.DoNotAddrOfCspParentWindowHandle";
|
||||
internal static readonly string SwitchSetActorAsReferenceWhenCopyingClaimsIdentity = "Switch.System.Security.ClaimsIdentity.SetActorAsReferenceWhenCopyingClaimsIdentity";
|
||||
|
||||
|
||||
// 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
|
||||
// to it from the code
|
||||
@@ -52,6 +52,11 @@ namespace System
|
||||
AppContext.DefineSwitchDefault(SwitchSetActorAsReferenceWhenCopyingClaimsIdentity, true);
|
||||
}
|
||||
|
||||
if (version <= 40602)
|
||||
{
|
||||
AppContext.DefineSwitchDefault(SwitchDoNotAddrOfCspParentWindowHandle, true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "WindowsPhone":
|
||||
@@ -63,6 +68,7 @@ namespace System
|
||||
AppContext.DefineSwitchDefault(SwitchThrowExceptionIfDisposedCancellationTokenSource, true);
|
||||
AppContext.DefineSwitchDefault(SwitchUseLegacyPathHandling, true);
|
||||
AppContext.DefineSwitchDefault(SwitchBlockLongPaths, true);
|
||||
AppContext.DefineSwitchDefault(SwitchDoNotAddrOfCspParentWindowHandle, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
// ==--==
|
||||
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -55,7 +56,7 @@ namespace System
|
||||
if (bool.TryParse(value, out switchValue))
|
||||
{
|
||||
// If multiple switches have the same name, the last value that we find will win.
|
||||
AppContext.SetSwitch(name, switchValue);
|
||||
AppContext.DefineSwitchOverride(name, switchValue);
|
||||
}
|
||||
}
|
||||
previousSemicolonPos = currentPos;
|
||||
@@ -96,10 +97,10 @@ namespace System
|
||||
overrideFound = false;
|
||||
|
||||
// Read the value from the registry if we can (ie. the key exists)
|
||||
if (s_switchesRegKey != null)
|
||||
if (s_errorReadingRegistry != true)
|
||||
{
|
||||
// try to read it from the registry key and return null if the switch name is not found
|
||||
valueFromConfig = s_switchesRegKey.GetValue(switchName, (string)null) as string;
|
||||
valueFromConfig = GetSwitchValueFromRegistry(switchName);
|
||||
}
|
||||
|
||||
// Note: valueFromConfig will be null only if the key is not found.
|
||||
@@ -118,19 +119,44 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
// Cached registry key used to read value overrides from the registry
|
||||
private static RegistryKey s_switchesRegKey = OpenRegKeyNoThrow();
|
||||
|
||||
/// <summary>
|
||||
/// Opens the registry key where the switches are stored and returns null if there is an issue opening the key
|
||||
/// </summary>
|
||||
private static RegistryKey OpenRegKeyNoThrow()
|
||||
private volatile static bool s_errorReadingRegistry;
|
||||
[SecuritySafeCritical]
|
||||
private static string GetSwitchValueFromRegistry(string switchName)
|
||||
{
|
||||
//
|
||||
// We are using P/Invokes directly instead of using the RegistryKey class to avoid pulling in the
|
||||
// globalization stack that is required by RegistryKey.
|
||||
//
|
||||
const string REG_KEY_APPCONTEXT = @"SOFTWARE\Microsoft\.NETFramework\AppContext";
|
||||
try
|
||||
{
|
||||
return Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework\AppContext");
|
||||
using (SafeRegistryHandle hklm = new SafeRegistryHandle((IntPtr)RegistryHive.LocalMachine, true))
|
||||
{
|
||||
SafeRegistryHandle hkey = null;
|
||||
|
||||
if (Win32Native.RegOpenKeyEx(hklm, REG_KEY_APPCONTEXT, 0, Win32Native.KEY_READ, out hkey) == 0)
|
||||
{
|
||||
int size = 6; // "false".Length+1
|
||||
int type = 0;
|
||||
System.Text.StringBuilder keyBuffer = new System.Text.StringBuilder((int)size);
|
||||
if (Win32Native.RegQueryValueEx(hkey, switchName, null, ref type, keyBuffer, ref size) == 0)
|
||||
{
|
||||
return keyBuffer.ToString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we could not open the AppContext key, don't try it again.
|
||||
s_errorReadingRegistry = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { return null; }
|
||||
catch
|
||||
{
|
||||
// If there was an error, flag it so that we don't try this again.
|
||||
s_errorReadingRegistry = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -88,6 +88,16 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
private static int _doNotAddrOfCspParentWindowHandle;
|
||||
public static bool DoNotAddrOfCspParentWindowHandle
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
return GetCachedSwitchValue(AppContextDefaultValues.SwitchDoNotAddrOfCspParentWindowHandle, ref _doNotAddrOfCspParentWindowHandle);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Implementation details
|
||||
//
|
||||
|
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// Lazy.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// --------------------------------------------------------------------------------------
|
||||
//
|
||||
@@ -431,7 +431,7 @@ namespace System
|
||||
}
|
||||
else if (factory == ALREADY_INVOKED_SENTINEL)
|
||||
{
|
||||
// Another thread ----d with us and beat us to successfully invoke the factory.
|
||||
// Another thread raced with us and beat us to successfully invoke the factory.
|
||||
return null;
|
||||
}
|
||||
boxed = new Boxed(factory());
|
||||
|
@@ -1 +1 @@
|
||||
2a704e83006fa15410f41e5e15bbe8ae7ddd0a4f
|
||||
0b475ce301b6852aeb4b78b21cbe7df6c4baa365
|
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** File: AppDomainAttributes
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>Microsoft</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: For AppDomain-related custom attributes.
|
||||
|
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Class: AppDomainUnloadedException
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>Microsoft</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Exception class for attempt to access an unloaded AppDomain
|
||||
|
@@ -13,7 +13,7 @@ namespace System {
|
||||
|
||||
// This class will not be marked serializable
|
||||
// Note: This type must have the same layout as the CLR's VARARGS type in CLRVarArgs.h.
|
||||
// It also contains an inline SigPointer data structure - must keep those fields in [....].
|
||||
// It also contains an inline SigPointer data structure - must keep those fields in sync.
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ArgIterator
|
||||
{
|
||||
|
@@ -1 +1 @@
|
||||
7c767692fef9860facfa00e85ad8d5930fb954df
|
||||
3c678360dfc5ead76993bd3253a40779452a4054
|
@@ -12,7 +12,7 @@
|
||||
**
|
||||
**
|
||||
===========================================================*/
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
|
||||
namespace System {
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Class: CannotUnloadAppDomainException
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>Microsoft</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Exception class for failed attempt to unload an AppDomain.
|
||||
|
@@ -7,7 +7,7 @@
|
||||
//
|
||||
// CDSCollectionETWBCLProvider.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// A helper class for firing ETW events related to the Coordination Data Structure
|
||||
// collection types. This provider is used by CDS collections in both mscorlib.dll
|
||||
|
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// ==--==
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
/*============================================================
|
||||
**
|
||||
** Class: ConcurrentDictionary
|
||||
|
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// ConcurrentQueue.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// A lock-free, concurrent queue primitive, and its associated debugger view type.
|
||||
//
|
||||
|
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// ConcurrentStack.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// A lock-free, concurrent stack primitive, and its associated debugger view type.
|
||||
//
|
||||
|
@@ -7,7 +7,7 @@
|
||||
//
|
||||
// IProducerConsumerCollection.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// A common interface for all concurrent collections.
|
||||
//
|
||||
|
@@ -7,7 +7,7 @@
|
||||
//
|
||||
// OrderablePartitioner.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
//
|
||||
//
|
||||
|
@@ -7,7 +7,7 @@
|
||||
//
|
||||
// Partitioner.cs
|
||||
//
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>Microsoft</OWNER>
|
||||
//
|
||||
// Represents a particular way of splitting a collection into multiple partitions.
|
||||
//
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user