Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -0,0 +1,343 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime
{
using System.Diagnostics;
using System.Runtime.Diagnostics;
using System.Security;
using System.Threading;
abstract class ActionItem
{
#if FEATURE_COMPRESSEDSTACK
[Fx.Tag.SecurityNote(Critical = "Stores the security context, used later in binding back into")]
[SecurityCritical]
SecurityContext context;
#endif
bool isScheduled;
bool lowPriority;
protected ActionItem()
{
}
public bool LowPriority
{
get
{
return this.lowPriority;
}
protected set
{
this.lowPriority = value;
}
}
public static void Schedule(Action<object> callback, object state)
{
Schedule(callback, state, false);
}
[Fx.Tag.SecurityNote(Critical = "Calls into critical method ScheduleCallback",
Safe = "Schedule invoke of the given delegate under the current context")]
[SecuritySafeCritical]
public static void Schedule(Action<object> callback, object state, bool lowPriority)
{
Fx.Assert(callback != null, "A null callback was passed for Schedule!");
if (PartialTrustHelpers.ShouldFlowSecurityContext ||
WaitCallbackActionItem.ShouldUseActivity ||
Fx.Trace.IsEnd2EndActivityTracingEnabled)
{
new DefaultActionItem(callback, state, lowPriority).Schedule();
}
else
{
ScheduleCallback(callback, state, lowPriority);
}
}
[Fx.Tag.SecurityNote(Critical = "Called after applying the user context on the stack or (potentially) " +
"without any user context on the stack")]
[SecurityCritical]
protected abstract void Invoke();
[Fx.Tag.SecurityNote(Critical = "Access critical field context and critical property " +
"CallbackHelper.InvokeWithContextCallback, calls into critical method " +
"PartialTrustHelpers.CaptureSecurityContextNoIdentityFlow, calls into critical method ScheduleCallback; " +
"since the invoked method and the capturing of the security contex are de-coupled, can't " +
"be treated as safe")]
[SecurityCritical]
protected void Schedule()
{
if (isScheduled)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.ActionItemIsAlreadyScheduled));
}
this.isScheduled = true;
#if FEATURE_COMPRESSEDSTACK
if (PartialTrustHelpers.ShouldFlowSecurityContext)
{
this.context = PartialTrustHelpers.CaptureSecurityContextNoIdentityFlow();
}
if (this.context != null)
{
ScheduleCallback(CallbackHelper.InvokeWithContextCallback);
}
else
#endif
{
ScheduleCallback(CallbackHelper.InvokeWithoutContextCallback);
}
}
#if FEATURE_COMPRESSEDSTACK
[Fx.Tag.SecurityNote(Critical = "Access critical field context and critical property " +
"CallbackHelper.InvokeWithContextCallback, calls into critical method ScheduleCallback; " +
"since nothing is known about the given context, can't be treated as safe")]
[SecurityCritical]
protected void ScheduleWithContext(SecurityContext context)
{
if (context == null)
{
throw Fx.Exception.ArgumentNull("context");
}
if (isScheduled)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.ActionItemIsAlreadyScheduled));
}
this.isScheduled = true;
this.context = context.CreateCopy();
ScheduleCallback(CallbackHelper.InvokeWithContextCallback);
}
#endif
[Fx.Tag.SecurityNote(Critical = "Access critical property CallbackHelper.InvokeWithoutContextCallback, " +
"Calls into critical method ScheduleCallback; not bound to a security context")]
[SecurityCritical]
protected void ScheduleWithoutContext()
{
if (isScheduled)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.ActionItemIsAlreadyScheduled));
}
this.isScheduled = true;
ScheduleCallback(CallbackHelper.InvokeWithoutContextCallback);
}
[Fx.Tag.SecurityNote(Critical = "Calls into critical methods IOThreadScheduler.ScheduleCallbackNoFlow, " +
"IOThreadScheduler.ScheduleCallbackLowPriNoFlow")]
[SecurityCritical]
static void ScheduleCallback(Action<object> callback, object state, bool lowPriority)
{
Fx.Assert(callback != null, "Cannot schedule a null callback");
if (lowPriority)
{
IOThreadScheduler.ScheduleCallbackLowPriNoFlow(callback, state);
}
else
{
IOThreadScheduler.ScheduleCallbackNoFlow(callback, state);
}
}
#if FEATURE_COMPRESSEDSTACK
[Fx.Tag.SecurityNote(Critical = "Extract the security context stored and reset the critical field")]
[SecurityCritical]
SecurityContext ExtractContext()
{
Fx.Assert(this.context != null, "Cannot bind to a null context; context should have been set by now");
Fx.Assert(this.isScheduled, "Context is extracted only while the object is scheduled");
SecurityContext result = this.context;
this.context = null;
return result;
}
#endif
[Fx.Tag.SecurityNote(Critical = "Calls into critical static method ScheduleCallback")]
[SecurityCritical]
void ScheduleCallback(Action<object> callback)
{
ScheduleCallback(callback, this, this.lowPriority);
}
[SecurityCritical]
static class CallbackHelper
{
#if FEATURE_COMPRESSEDSTACK
[Fx.Tag.SecurityNote(Critical = "Stores a delegate to a critical method")]
static Action<object> invokeWithContextCallback;
#endif
[Fx.Tag.SecurityNote(Critical = "Stores a delegate to a critical method")]
static Action<object> invokeWithoutContextCallback;
[Fx.Tag.SecurityNote(Critical = "Stores a delegate to a critical method")]
static ContextCallback onContextAppliedCallback;
#if FEATURE_COMPRESSEDSTACK
[Fx.Tag.SecurityNote(Critical = "Provides access to a critical field; Initialize it with " +
"a delegate to a critical method")]
public static Action<object> InvokeWithContextCallback
{
get
{
if (invokeWithContextCallback == null)
{
invokeWithContextCallback = new Action<object>(InvokeWithContext);
}
return invokeWithContextCallback;
}
}
#endif
[Fx.Tag.SecurityNote(Critical = "Provides access to a critical field; Initialize it with " +
"a delegate to a critical method")]
public static Action<object> InvokeWithoutContextCallback
{
get
{
if (invokeWithoutContextCallback == null)
{
invokeWithoutContextCallback = new Action<object>(InvokeWithoutContext);
}
return invokeWithoutContextCallback;
}
}
[Fx.Tag.SecurityNote(Critical = "Provides access to a critical field; Initialize it with " +
"a delegate to a critical method")]
public static ContextCallback OnContextAppliedCallback
{
get
{
if (onContextAppliedCallback == null)
{
onContextAppliedCallback = new ContextCallback(OnContextApplied);
}
return onContextAppliedCallback;
}
}
#if FEATURE_COMPRESSEDSTACK
[Fx.Tag.SecurityNote(Critical = "Called by the scheduler without any user context on the stack")]
static void InvokeWithContext(object state)
{
SecurityContext context = ((ActionItem)state).ExtractContext();
SecurityContext.Run(context, OnContextAppliedCallback, state);
}
#endif
[Fx.Tag.SecurityNote(Critical = "Called by the scheduler without any user context on the stack")]
static void InvokeWithoutContext(object state)
{
((ActionItem)state).Invoke();
((ActionItem)state).isScheduled = false;
}
[Fx.Tag.SecurityNote(Critical = "Called after applying the user context on the stack")]
static void OnContextApplied(object o)
{
((ActionItem)o).Invoke();
((ActionItem)o).isScheduled = false;
}
}
class DefaultActionItem : ActionItem
{
[Fx.Tag.SecurityNote(Critical = "Stores a delegate that will be called later, at a particular context")]
[SecurityCritical]
Action<object> callback;
[Fx.Tag.SecurityNote(Critical = "Stores an object that will be passed to the delegate that will be " +
"called later, at a particular context")]
[SecurityCritical]
object state;
bool flowLegacyActivityId;
Guid activityId;
EventTraceActivity eventTraceActivity;
[Fx.Tag.SecurityNote(Critical = "Access critical fields callback and state",
Safe = "Doesn't leak information or resources")]
[SecuritySafeCritical]
public DefaultActionItem(Action<object> callback, object state, bool isLowPriority)
{
Fx.Assert(callback != null, "Shouldn't instantiate an object to wrap a null callback");
base.LowPriority = isLowPriority;
this.callback = callback;
this.state = state;
if (WaitCallbackActionItem.ShouldUseActivity)
{
this.flowLegacyActivityId = true;
this.activityId = EtwDiagnosticTrace.ActivityId;
}
if (Fx.Trace.IsEnd2EndActivityTracingEnabled)
{
this.eventTraceActivity = EventTraceActivity.GetFromThreadOrCreate();
if (TraceCore.ActionItemScheduledIsEnabled(Fx.Trace))
{
TraceCore.ActionItemScheduled(Fx.Trace, this.eventTraceActivity);
}
}
}
[Fx.Tag.SecurityNote(Critical = "Implements a the critical abstract ActionItem.Invoke method, " +
"Access critical fields callback and state")]
[SecurityCritical]
protected override void Invoke()
{
if (this.flowLegacyActivityId || Fx.Trace.IsEnd2EndActivityTracingEnabled)
{
TraceAndInvoke();
}
else
{
this.callback(this.state);
}
}
[Fx.Tag.SecurityNote(Critical = "Implements a the critical abstract Trace method, " +
"Access critical fields callback and state")]
[SecurityCritical]
void TraceAndInvoke()
{
//
if (this.flowLegacyActivityId)
{
Guid currentActivityId = EtwDiagnosticTrace.ActivityId;
try
{
EtwDiagnosticTrace.ActivityId = this.activityId;
this.callback(this.state);
}
finally
{
EtwDiagnosticTrace.ActivityId = currentActivityId;
}
}
else
{
Guid previous = Guid.Empty;
bool restoreActivityId = false;
try
{
if (this.eventTraceActivity != null)
{
previous = Trace.CorrelationManager.ActivityId;
restoreActivityId = true;
Trace.CorrelationManager.ActivityId = this.eventTraceActivity.ActivityId;
if (TraceCore.ActionItemCallbackInvokedIsEnabled(Fx.Trace))
{
TraceCore.ActionItemCallbackInvoked(Fx.Trace, this.eventTraceActivity);
}
}
this.callback(this.state);
}
finally
{
if (restoreActivityId)
{
Trace.CorrelationManager.ActivityId = previous;
}
}
}
}
}
}
}

View File

@@ -0,0 +1,99 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
// This class needs to function even if it was built retail. That is, a debug caller calling against a retail
// build of this assembly should still have asserts fire. To achieve that, we need to define DEBUG here.
// We do not do the registry override in retail because that would require shipping a test hook. We
// do not generally ship test hooks today.
#if DEBUG
#define DEBUG_FOR_REALS
#else
#define DEBUG
#endif
namespace System.Runtime
{
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.Interop;
using System.Security;
using System.Runtime.Versioning;
static class AssertHelper
{
[SuppressMessage(FxCop.Category.ReliabilityBasic, FxCop.Rule.InvariantAssertRule, Justification = "Assert implementation")]
[ResourceConsumption(ResourceScope.Process)]
internal static void FireAssert(string message)
{
try
{
#if DEBUG_FOR_REALS
InternalFireAssert(ref message);
#endif
}
finally
{
Debug.Assert(false, message);
}
}
#if DEBUG_FOR_REALS
[SuppressMessage(FxCop.Category.Globalization, FxCop.Rule.DoNotPassLiteralsAsLocalizedParameters, Justification = "Debug Only")]
[Fx.Tag.SecurityNote(Critical = "Calls into various critical methods",
Safe = "Exists only on debug versions")]
[SecuritySafeCritical]
static void InternalFireAssert(ref string message)
{
try
{
string debugMessage = "Assert fired! --> " + message + "\r\n";
if (Debugger.IsAttached)
{
Debugger.Log(0, Debugger.DefaultCategory, debugMessage);
Debugger.Break();
}
if (UnsafeNativeMethods.IsDebuggerPresent())
{
UnsafeNativeMethods.OutputDebugString(debugMessage);
UnsafeNativeMethods.DebugBreak();
}
if (Fx.AssertsFailFast)
{
try
{
Fx.Exception.TraceFailFast(message);
}
finally
{
Environment.FailFast(message);
}
}
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
string newMessage = "Exception during FireAssert!";
try
{
newMessage = string.Concat(newMessage, " [", exception.GetType().Name, ": ", exception.Message, "] --> ", message);
}
finally
{
message = newMessage;
}
throw;
}
}
#endif
}
}

View File

@@ -0,0 +1,19 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
namespace System.Runtime
{
enum AsyncCompletionResult
{
/// <summary>
/// Inidicates that the operation has been queued for completion.
/// </summary>
Queued,
/// <summary>
/// Indicates the operation has completed.
/// </summary>
Completed,
}
}

View File

@@ -0,0 +1,129 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
namespace System.Runtime
{
using System.Diagnostics;
[Fx.Tag.SynchronizationPrimitive(Fx.Tag.BlocksUsing.NonBlocking, SupportsAsync = true, ReleaseMethod = "Complete")]
abstract class AsyncEventArgs : IAsyncEventArgs
{
#if DEBUG
StackTrace startStack;
StackTrace completeStack;
#endif
OperationState state;
object asyncState;
AsyncEventArgsCallback callback;
Exception exception;
public Exception Exception
{
get { return this.exception; }
}
public object AsyncState
{
get { return this.asyncState; }
}
OperationState State
{
set
{
switch (value)
{
case OperationState.PendingCompletion:
if (this.state == OperationState.PendingCompletion)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.AsyncEventArgsCompletionPending(GetType())));
}
#if DEBUG
if (!Fx.FastDebug)
{
this.startStack = new StackTrace();
}
#endif
break;
case OperationState.CompletedAsynchronously:
case OperationState.CompletedSynchronously:
if (this.state != OperationState.PendingCompletion)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.AsyncEventArgsCompletedTwice(GetType())));
}
#if DEBUG
if (!Fx.FastDebug)
{
this.completeStack = new StackTrace();
}
#endif
break;
}
this.state = value;
}
}
public void Complete(bool completedSynchronously)
{
this.Complete(completedSynchronously, null);
}
public virtual void Complete(bool completedSynchronously, Exception exception)
{
// The callback will be invoked only if completedSynchronously is false.
// It is the responsibility of the caller or callback to throw the exception.
this.exception = exception;
if (completedSynchronously)
{
this.State = OperationState.CompletedSynchronously;
}
else
{
this.State = OperationState.CompletedAsynchronously;
this.callback(this);
}
}
protected void SetAsyncState(AsyncEventArgsCallback callback, object state)
{
if (callback == null)
{
throw Fx.Exception.ArgumentNull("callback");
}
this.State = OperationState.PendingCompletion;
this.asyncState = state;
this.callback = callback;
}
enum OperationState
{
Created,
PendingCompletion,
CompletedSynchronously,
CompletedAsynchronously,
}
}
class AsyncEventArgs<TArgument> : AsyncEventArgs
{
public TArgument Arguments
{
get;
private set;
}
public virtual void Set(AsyncEventArgsCallback callback, TArgument arguments, object state)
{
this.SetAsyncState(callback, state);
this.Arguments = arguments;
}
}
class AsyncEventArgs<TArgument, TResult> : AsyncEventArgs<TArgument>
{
public TResult Result { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
namespace System.Runtime
{
delegate void AsyncEventArgsCallback(IAsyncEventArgs eventArgs);
}

View File

@@ -0,0 +1,425 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
// AsyncResult starts acquired; Complete releases.
[Fx.Tag.SynchronizationPrimitive(Fx.Tag.BlocksUsing.ManualResetEvent, SupportsAsync = true, ReleaseMethod = "Complete")]
abstract class AsyncResult : IAsyncResult
{
static AsyncCallback asyncCompletionWrapperCallback;
AsyncCallback callback;
bool completedSynchronously;
bool endCalled;
Exception exception;
bool isCompleted;
AsyncCompletion nextAsyncCompletion;
object state;
Action beforePrepareAsyncCompletionAction;
Func<IAsyncResult, bool> checkSyncValidationFunc;
[Fx.Tag.SynchronizationObject]
ManualResetEvent manualResetEvent;
[Fx.Tag.SynchronizationObject(Blocking = false)]
object thisLock;
#if DEBUG
StackTrace endStack;
StackTrace completeStack;
UncompletedAsyncResultMarker marker;
#endif
protected AsyncResult(AsyncCallback callback, object state)
{
this.callback = callback;
this.state = state;
this.thisLock = new object();
#if DEBUG
this.marker = new UncompletedAsyncResultMarker(this);
#endif
}
public object AsyncState
{
get
{
return state;
}
}
public WaitHandle AsyncWaitHandle
{
get
{
if (manualResetEvent != null)
{
return manualResetEvent;
}
lock (ThisLock)
{
if (manualResetEvent == null)
{
manualResetEvent = new ManualResetEvent(isCompleted);
}
}
return manualResetEvent;
}
}
public bool CompletedSynchronously
{
get
{
return completedSynchronously;
}
}
public bool HasCallback
{
get
{
return this.callback != null;
}
}
public bool IsCompleted
{
get
{
return isCompleted;
}
}
// used in conjunction with PrepareAsyncCompletion to allow for finally blocks
protected Action<AsyncResult, Exception> OnCompleting { get; set; }
object ThisLock
{
get
{
return this.thisLock;
}
}
// subclasses like TraceAsyncResult can use this to wrap the callback functionality in a scope
protected Action<AsyncCallback, IAsyncResult> VirtualCallback
{
get;
set;
}
protected void Complete(bool completedSynchronously)
{
if (this.isCompleted)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.AsyncResultCompletedTwice(GetType())));
}
#if DEBUG
this.marker.AsyncResult = null;
this.marker = null;
if (!Fx.FastDebug && completeStack == null)
{
completeStack = new StackTrace();
}
#endif
this.completedSynchronously = completedSynchronously;
if (OnCompleting != null)
{
// Allow exception replacement, like a catch/throw pattern.
try
{
OnCompleting(this, this.exception);
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
this.exception = exception;
}
}
if (completedSynchronously)
{
// If we completedSynchronously, then there's no chance that the manualResetEvent was created so
// we don't need to worry about a ----
Fx.Assert(this.manualResetEvent == null, "No ManualResetEvent should be created for a synchronous AsyncResult.");
this.isCompleted = true;
}
else
{
lock (ThisLock)
{
this.isCompleted = true;
if (this.manualResetEvent != null)
{
this.manualResetEvent.Set();
}
}
}
if (this.callback != null)
{
try
{
if (VirtualCallback != null)
{
VirtualCallback(this.callback, this);
}
else
{
this.callback(this);
}
}
#pragma warning disable 1634
#pragma warning suppress 56500 // transferring exception to another thread
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
throw Fx.Exception.AsError(new CallbackException(InternalSR.AsyncCallbackThrewException, e));
}
#pragma warning restore 1634
}
}
protected void Complete(bool completedSynchronously, Exception exception)
{
this.exception = exception;
Complete(completedSynchronously);
}
static void AsyncCompletionWrapperCallback(IAsyncResult result)
{
if (result == null)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.InvalidNullAsyncResult));
}
if (result.CompletedSynchronously)
{
return;
}
AsyncResult thisPtr = (AsyncResult)result.AsyncState;
if (!thisPtr.OnContinueAsyncCompletion(result))
{
return;
}
AsyncCompletion callback = thisPtr.GetNextCompletion();
if (callback == null)
{
ThrowInvalidAsyncResult(result);
}
bool completeSelf = false;
Exception completionException = null;
try
{
completeSelf = callback(result);
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
completeSelf = true;
completionException = e;
}
if (completeSelf)
{
thisPtr.Complete(false, completionException);
}
}
// Note: this should be only derived by the TransactedAsyncResult
protected virtual bool OnContinueAsyncCompletion(IAsyncResult result)
{
return true;
}
// Note: this should be used only by the TransactedAsyncResult
protected void SetBeforePrepareAsyncCompletionAction(Action beforePrepareAsyncCompletionAction)
{
this.beforePrepareAsyncCompletionAction = beforePrepareAsyncCompletionAction;
}
// Note: this should be used only by the TransactedAsyncResult
protected void SetCheckSyncValidationFunc(Func<IAsyncResult, bool> checkSyncValidationFunc)
{
this.checkSyncValidationFunc = checkSyncValidationFunc;
}
protected AsyncCallback PrepareAsyncCompletion(AsyncCompletion callback)
{
if (this.beforePrepareAsyncCompletionAction != null)
{
this.beforePrepareAsyncCompletionAction();
}
this.nextAsyncCompletion = callback;
if (AsyncResult.asyncCompletionWrapperCallback == null)
{
AsyncResult.asyncCompletionWrapperCallback = Fx.ThunkCallback(new AsyncCallback(AsyncCompletionWrapperCallback));
}
return AsyncResult.asyncCompletionWrapperCallback;
}
protected bool CheckSyncContinue(IAsyncResult result)
{
AsyncCompletion dummy;
return TryContinueHelper(result, out dummy);
}
protected bool SyncContinue(IAsyncResult result)
{
AsyncCompletion callback;
if (TryContinueHelper(result, out callback))
{
return callback(result);
}
else
{
return false;
}
}
bool TryContinueHelper(IAsyncResult result, out AsyncCompletion callback)
{
if (result == null)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.InvalidNullAsyncResult));
}
callback = null;
if (this.checkSyncValidationFunc != null)
{
if (!this.checkSyncValidationFunc(result))
{
return false;
}
}
else if (!result.CompletedSynchronously)
{
return false;
}
callback = GetNextCompletion();
if (callback == null)
{
ThrowInvalidAsyncResult("Only call Check/SyncContinue once per async operation (once per PrepareAsyncCompletion).");
}
return true;
}
AsyncCompletion GetNextCompletion()
{
AsyncCompletion result = this.nextAsyncCompletion;
this.nextAsyncCompletion = null;
return result;
}
protected static void ThrowInvalidAsyncResult(IAsyncResult result)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.InvalidAsyncResultImplementation(result.GetType())));
}
protected static void ThrowInvalidAsyncResult(string debugText)
{
string message = InternalSR.InvalidAsyncResultImplementationGeneric;
if (debugText != null)
{
#if DEBUG
message += " " + debugText;
#endif
}
throw Fx.Exception.AsError(new InvalidOperationException(message));
}
[Fx.Tag.Blocking(Conditional = "!asyncResult.isCompleted")]
protected static TAsyncResult End<TAsyncResult>(IAsyncResult result)
where TAsyncResult : AsyncResult
{
if (result == null)
{
throw Fx.Exception.ArgumentNull("result");
}
TAsyncResult asyncResult = result as TAsyncResult;
if (asyncResult == null)
{
throw Fx.Exception.Argument("result", InternalSR.InvalidAsyncResult);
}
if (asyncResult.endCalled)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.AsyncResultAlreadyEnded));
}
#if DEBUG
if (!Fx.FastDebug && asyncResult.endStack == null)
{
asyncResult.endStack = new StackTrace();
}
#endif
asyncResult.endCalled = true;
if (!asyncResult.isCompleted)
{
asyncResult.AsyncWaitHandle.WaitOne();
}
if (asyncResult.manualResetEvent != null)
{
asyncResult.manualResetEvent.Close();
}
if (asyncResult.exception != null)
{
throw Fx.Exception.AsError(asyncResult.exception);
}
return asyncResult;
}
// can be utilized by subclasses to write core completion code for both the [....] and async paths
// in one location, signalling chainable synchronous completion with the boolean result,
// and leveraging PrepareAsyncCompletion for conversion to an AsyncCallback.
// NOTE: requires that "this" is passed in as the state object to the asynchronous sub-call being used with a completion routine.
protected delegate bool AsyncCompletion(IAsyncResult result);
#if DEBUG
class UncompletedAsyncResultMarker
{
public UncompletedAsyncResultMarker(AsyncResult result)
{
AsyncResult = result;
}
[SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode,
Justification = "Debug-only facility")]
public AsyncResult AsyncResult { get; set; }
}
#endif
}
}

View File

@@ -0,0 +1,283 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Collections.Generic;
using System.Security;
using System.Threading;
[Fx.Tag.SynchronizationPrimitive(Fx.Tag.BlocksUsing.MonitorWait, SupportsAsync = true, ReleaseMethod = "Set")]
class AsyncWaitHandle
{
static Action<object> timerCompleteCallback;
List<AsyncWaiter> asyncWaiters;
bool isSignaled;
EventResetMode resetMode;
[Fx.Tag.SynchronizationObject(Kind = Fx.Tag.SynchronizationKind.MonitorWait)]
object syncObject;
int syncWaiterCount;
public AsyncWaitHandle()
: this(EventResetMode.AutoReset)
{
}
public AsyncWaitHandle(EventResetMode resetMode)
{
this.resetMode = resetMode;
this.syncObject = new object();
}
public bool WaitAsync(Action<object, TimeoutException> callback, object state, TimeSpan timeout)
{
if (!this.isSignaled || (this.isSignaled && this.resetMode == EventResetMode.AutoReset))
{
lock (syncObject)
{
if (this.isSignaled && this.resetMode == EventResetMode.AutoReset)
{
this.isSignaled = false;
}
else if (!this.isSignaled)
{
AsyncWaiter waiter = new AsyncWaiter(this, callback, state);
if (this.asyncWaiters == null)
{
this.asyncWaiters = new List<AsyncWaiter>();
}
this.asyncWaiters.Add(waiter);
if (timeout != TimeSpan.MaxValue)
{
if (timerCompleteCallback == null)
{
timerCompleteCallback = new Action<object>(OnTimerComplete);
}
waiter.SetTimer(timerCompleteCallback, waiter, timeout);
}
return false;
}
}
}
return true;
}
static void OnTimerComplete(object state)
{
AsyncWaiter waiter = (AsyncWaiter)state;
AsyncWaitHandle thisPtr = waiter.Parent;
bool callWaiter = false;
lock (thisPtr.syncObject)
{
// If still in the waiting list (that means it hasn't been signaled)
if (thisPtr.asyncWaiters != null && thisPtr.asyncWaiters.Remove(waiter))
{
waiter.TimedOut = true;
callWaiter = true;
}
}
waiter.CancelTimer();
if (callWaiter)
{
waiter.Call();
}
}
[Fx.Tag.Blocking]
public bool Wait(TimeSpan timeout)
{
if (!this.isSignaled || (this.isSignaled && this.resetMode == EventResetMode.AutoReset))
{
lock (syncObject)
{
if (this.isSignaled && this.resetMode == EventResetMode.AutoReset)
{
this.isSignaled = false;
}
else if (!this.isSignaled)
{
bool decrementRequired = false;
try
{
try
{
}
finally
{
this.syncWaiterCount++;
decrementRequired = true;
}
if (timeout == TimeSpan.MaxValue)
{
if (!Monitor.Wait(syncObject, Timeout.Infinite))
{
return false;
}
}
else
{
if (!Monitor.Wait(syncObject, timeout))
{
return false;
}
}
}
finally
{
if (decrementRequired)
{
this.syncWaiterCount--;
}
}
}
}
}
return true;
}
public void Set()
{
List<AsyncWaiter> toCallList = null;
AsyncWaiter toCall = null;
if (!this.isSignaled)
{
lock (syncObject)
{
if (!this.isSignaled)
{
if (this.resetMode == EventResetMode.ManualReset)
{
this.isSignaled = true;
Monitor.PulseAll(syncObject);
toCallList = this.asyncWaiters;
this.asyncWaiters = null;
}
else
{
if (this.syncWaiterCount > 0)
{
Monitor.Pulse(syncObject);
}
else if (this.asyncWaiters != null && this.asyncWaiters.Count > 0)
{
toCall = this.asyncWaiters[0];
this.asyncWaiters.RemoveAt(0);
}
else
{
this.isSignaled = true;
}
}
}
}
}
if (toCallList != null)
{
foreach (AsyncWaiter waiter in toCallList)
{
waiter.CancelTimer();
waiter.Call();
}
}
if (toCall != null)
{
toCall.CancelTimer();
toCall.Call();
}
}
public void Reset()
{
// Doesn't matter if this changes during processing of another method
this.isSignaled = false;
}
class AsyncWaiter : ActionItem
{
[Fx.Tag.SecurityNote(Critical = "Store the delegate to be invoked")]
[SecurityCritical]
Action<object, TimeoutException> callback;
[Fx.Tag.SecurityNote(Critical = "Stores the state object to be passed to the callback")]
[SecurityCritical]
object state;
IOThreadTimer timer;
TimeSpan originalTimeout;
[Fx.Tag.SecurityNote(Critical = "Access critical members", Safe = "Doesn't leak information")]
[SecuritySafeCritical]
public AsyncWaiter(AsyncWaitHandle parent, Action<object, TimeoutException> callback, object state)
{
this.Parent = parent;
this.callback = callback;
this.state = state;
}
public AsyncWaitHandle Parent
{
get;
private set;
}
public bool TimedOut
{
get;
set;
}
[Fx.Tag.SecurityNote(Critical = "Calls into critical method Schedule", Safe = "Invokes the given delegate under the current context")]
[SecuritySafeCritical]
public void Call()
{
Schedule();
}
[Fx.Tag.SecurityNote(Critical = "Overriding an inherited critical method, access critical members")]
[SecurityCritical]
protected override void Invoke()
{
this.callback(this.state,
this.TimedOut ? new TimeoutException(InternalSR.TimeoutOnOperation(this.originalTimeout)) : null);
}
public void SetTimer(Action<object> callback, object state, TimeSpan timeout)
{
if (this.timer != null)
{
throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.MustCancelOldTimer));
}
this.originalTimeout = timeout;
this.timer = new IOThreadTimer(callback, state, false);
this.timer.Set(timeout);
}
public void CancelTimer()
{
if (this.timer != null)
{
this.timer.Cancel();
this.timer = null;
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Threading;
sealed class BackoffTimeoutHelper
{
readonly static int maxSkewMilliseconds = (int)(IOThreadTimer.SystemTimeResolutionTicks / TimeSpan.TicksPerMillisecond);
readonly static long maxDriftTicks = IOThreadTimer.SystemTimeResolutionTicks * 2;
readonly static TimeSpan defaultInitialWaitTime = TimeSpan.FromMilliseconds(1);
readonly static TimeSpan defaultMaxWaitTime = TimeSpan.FromMinutes(1);
DateTime deadline;
TimeSpan maxWaitTime;
TimeSpan waitTime;
IOThreadTimer backoffTimer;
Action<object> backoffCallback;
object backoffState;
Random random;
TimeSpan originalTimeout;
internal BackoffTimeoutHelper(TimeSpan timeout)
: this(timeout, BackoffTimeoutHelper.defaultMaxWaitTime)
{
}
internal BackoffTimeoutHelper(TimeSpan timeout, TimeSpan maxWaitTime)
: this(timeout, maxWaitTime, BackoffTimeoutHelper.defaultInitialWaitTime)
{
}
internal BackoffTimeoutHelper(TimeSpan timeout, TimeSpan maxWaitTime, TimeSpan initialWaitTime)
{
this.random = new Random(GetHashCode());
this.maxWaitTime = maxWaitTime;
this.originalTimeout = timeout;
Reset(timeout, initialWaitTime);
}
public TimeSpan OriginalTimeout
{
get
{
return this.originalTimeout;
}
}
void Reset(TimeSpan timeout, TimeSpan initialWaitTime)
{
if (timeout == TimeSpan.MaxValue)
{
this.deadline = DateTime.MaxValue;
}
else
{
this.deadline = DateTime.UtcNow + timeout;
}
this.waitTime = initialWaitTime;
}
public bool IsExpired()
{
if (this.deadline == DateTime.MaxValue)
{
return false;
}
else
{
return (DateTime.UtcNow >= this.deadline);
}
}
public void WaitAndBackoff(Action<object> callback, object state)
{
if (this.backoffCallback != callback || this.backoffState != state)
{
if (this.backoffTimer != null)
{
this.backoffTimer.Cancel();
}
this.backoffCallback = callback;
this.backoffState = state;
this.backoffTimer = new IOThreadTimer(callback, state, false, BackoffTimeoutHelper.maxSkewMilliseconds);
}
TimeSpan backoffTime = WaitTimeWithDrift();
Backoff();
this.backoffTimer.Set(backoffTime);
}
public void WaitAndBackoff()
{
Thread.Sleep(WaitTimeWithDrift());
Backoff();
}
TimeSpan WaitTimeWithDrift()
{
return Ticks.ToTimeSpan(Math.Max(
Ticks.FromTimeSpan(BackoffTimeoutHelper.defaultInitialWaitTime),
Ticks.Add(Ticks.FromTimeSpan(this.waitTime),
(long)(uint)this.random.Next() % (2 * BackoffTimeoutHelper.maxDriftTicks + 1) - BackoffTimeoutHelper.maxDriftTicks)));
}
void Backoff()
{
if (waitTime.Ticks >= (maxWaitTime.Ticks / 2))
{
waitTime = maxWaitTime;
}
else
{
waitTime = TimeSpan.FromTicks(waitTime.Ticks * 2);
}
if (this.deadline != DateTime.MaxValue)
{
TimeSpan remainingTime = this.deadline - DateTime.UtcNow;
if (this.waitTime > remainingTime)
{
this.waitTime = remainingTime;
if (this.waitTime < TimeSpan.Zero)
{
this.waitTime = TimeSpan.Zero;
}
}
}
}
}
}

View File

@@ -0,0 +1,319 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Globalization;
using System.IO;
class BufferedOutputStream : Stream
{
[Fx.Tag.Cache(typeof(byte), Fx.Tag.CacheAttrition.None, Scope = Fx.Tag.Strings.ExternallyManaged,
SizeLimit = Fx.Tag.Strings.ExternallyManaged)]
InternalBufferManager bufferManager;
[Fx.Tag.Queue(typeof(byte), SizeLimit = "BufferedOutputStream(maxSize)",
StaleElementsRemovedImmediately = true, EnqueueThrowsIfFull = true)]
byte[][] chunks;
int chunkCount;
byte[] currentChunk;
int currentChunkSize;
int maxSize;
int maxSizeQuota;
int totalSize;
bool callerReturnsBuffer;
bool bufferReturned;
bool initialized;
// requires an explicit call to Init() by the caller
public BufferedOutputStream()
{
this.chunks = new byte[4][];
}
public BufferedOutputStream(int initialSize, int maxSize, InternalBufferManager bufferManager)
: this()
{
Reinitialize(initialSize, maxSize, bufferManager);
}
public BufferedOutputStream(int maxSize)
: this(0, maxSize, InternalBufferManager.Create(0, int.MaxValue))
{
}
public override bool CanRead
{
get
{
return false;
}
}
public override bool CanSeek
{
get
{
return false;
}
}
public override bool CanWrite
{
get
{
return true;
}
}
public override long Length
{
get
{
return this.totalSize;
}
}
public override long Position
{
get
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.SeekNotSupported));
}
set
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.SeekNotSupported));
}
}
public void Reinitialize(int initialSize, int maxSizeQuota, InternalBufferManager bufferManager)
{
Reinitialize(initialSize, maxSizeQuota, maxSizeQuota, bufferManager);
}
public void Reinitialize(int initialSize, int maxSizeQuota, int effectiveMaxSize, InternalBufferManager bufferManager)
{
Fx.Assert(!this.initialized, "Clear must be called before re-initializing stream");
this.maxSizeQuota = maxSizeQuota;
this.maxSize = effectiveMaxSize;
this.bufferManager = bufferManager;
this.currentChunk = bufferManager.TakeBuffer(initialSize);
this.currentChunkSize = 0;
this.totalSize = 0;
this.chunkCount = 1;
this.chunks[0] = this.currentChunk;
this.initialized = true;
}
void AllocNextChunk(int minimumChunkSize)
{
int newChunkSize;
if (this.currentChunk.Length > (int.MaxValue / 2))
{
newChunkSize = int.MaxValue;
}
else
{
newChunkSize = this.currentChunk.Length * 2;
}
if (minimumChunkSize > newChunkSize)
{
newChunkSize = minimumChunkSize;
}
byte[] newChunk = this.bufferManager.TakeBuffer(newChunkSize);
if (this.chunkCount == this.chunks.Length)
{
byte[][] newChunks = new byte[this.chunks.Length * 2][];
Array.Copy(this.chunks, newChunks, this.chunks.Length);
this.chunks = newChunks;
}
this.chunks[this.chunkCount++] = newChunk;
this.currentChunk = newChunk;
this.currentChunkSize = 0;
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ReadNotSupported));
}
public override int EndRead(IAsyncResult result)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ReadNotSupported));
}
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
{
Write(buffer, offset, size);
return new CompletedAsyncResult(callback, state);
}
public override void EndWrite(IAsyncResult result)
{
CompletedAsyncResult.End(result);
}
public void Clear()
{
if (!this.callerReturnsBuffer)
{
for (int i = 0; i < this.chunkCount; i++)
{
this.bufferManager.ReturnBuffer(this.chunks[i]);
this.chunks[i] = null;
}
}
this.callerReturnsBuffer = false;
this.initialized = false;
this.bufferReturned = false;
this.chunkCount = 0;
this.currentChunk = null;
}
public override void Close()
{
}
public override void Flush()
{
}
public override int Read(byte[] buffer, int offset, int size)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ReadNotSupported));
}
public override int ReadByte()
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ReadNotSupported));
}
public override long Seek(long offset, SeekOrigin origin)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.SeekNotSupported));
}
public override void SetLength(long value)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.SeekNotSupported));
}
public MemoryStream ToMemoryStream()
{
int bufferSize;
byte[] buffer = ToArray(out bufferSize);
return new MemoryStream(buffer, 0, bufferSize);
}
public byte[] ToArray(out int bufferSize)
{
Fx.Assert(this.initialized, "No data to return from uninitialized stream");
Fx.Assert(!this.bufferReturned, "ToArray cannot be called more than once");
byte[] buffer;
if (this.chunkCount == 1)
{
buffer = this.currentChunk;
bufferSize = this.currentChunkSize;
this.callerReturnsBuffer = true;
}
else
{
buffer = this.bufferManager.TakeBuffer(this.totalSize);
int offset = 0;
int count = this.chunkCount - 1;
for (int i = 0; i < count; i++)
{
byte[] chunk = this.chunks[i];
Buffer.BlockCopy(chunk, 0, buffer, offset, chunk.Length);
offset += chunk.Length;
}
Buffer.BlockCopy(this.currentChunk, 0, buffer, offset, this.currentChunkSize);
bufferSize = this.totalSize;
}
this.bufferReturned = true;
return buffer;
}
public void Skip(int size)
{
WriteCore(null, 0, size);
}
public override void Write(byte[] buffer, int offset, int size)
{
WriteCore(buffer, offset, size);
}
protected virtual Exception CreateQuotaExceededException(int maxSizeQuota)
{
return new InvalidOperationException(InternalSR.BufferedOutputStreamQuotaExceeded(maxSizeQuota));
}
void WriteCore(byte[] buffer, int offset, int size)
{
Fx.Assert(this.initialized, "Cannot write to uninitialized stream");
Fx.Assert(!this.bufferReturned, "Cannot write to stream once ToArray has been called.");
if (size < 0)
{
throw Fx.Exception.ArgumentOutOfRange("size", size, InternalSR.ValueMustBeNonNegative);
}
if ((int.MaxValue - size) < this.totalSize)
{
throw Fx.Exception.AsError(CreateQuotaExceededException(this.maxSizeQuota));
}
int newTotalSize = this.totalSize + size;
if (newTotalSize > this.maxSize)
{
throw Fx.Exception.AsError(CreateQuotaExceededException(this.maxSizeQuota));
}
int remainingSizeInChunk = this.currentChunk.Length - this.currentChunkSize;
if (size > remainingSizeInChunk)
{
if (remainingSizeInChunk > 0)
{
if (buffer != null)
{
Buffer.BlockCopy(buffer, offset, this.currentChunk, this.currentChunkSize, remainingSizeInChunk);
}
this.currentChunkSize = this.currentChunk.Length;
offset += remainingSizeInChunk;
size -= remainingSizeInChunk;
}
AllocNextChunk(size);
}
if (buffer != null)
{
Buffer.BlockCopy(buffer, offset, this.currentChunk, this.currentChunkSize, size);
}
this.totalSize = newTotalSize;
this.currentChunkSize += size;
}
public override void WriteByte(byte value)
{
Fx.Assert(this.initialized, "Cannot write to uninitialized stream");
Fx.Assert(!this.bufferReturned, "Cannot write to stream once ToArray has been called.");
if (this.totalSize == this.maxSize)
{
throw Fx.Exception.AsError(CreateQuotaExceededException(this.maxSize));
}
if (this.currentChunkSize == this.currentChunk.Length)
{
AllocNextChunk(1);
}
this.currentChunk[this.currentChunkSize++] = value;
}
}
}

View File

@@ -0,0 +1,28 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Runtime.Serialization;
[Serializable]
class CallbackException : FatalException
{
public CallbackException()
{
}
public CallbackException(string message, Exception innerException) : base(message, innerException)
{
// This can't throw something like ArgumentException because that would be worse than
// throwing the callback exception that was requested.
Fx.Assert(innerException != null, "CallbackException requires an inner exception.");
Fx.Assert(!Fx.IsFatal(innerException), "CallbackException can't be used to wrap fatal exceptions.");
}
protected CallbackException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

View File

@@ -0,0 +1,247 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.Collections
{
using System;
using System.Collections;
using System.Threading;
using System.Diagnostics;
// This cache works like a MruCache, but operates loosely and without locks in the mainline path.
//
// It consists of three 'hoppers', which are Hashtables (chosen for their nice threading characteristics - reading
// doesn't require a lock). Items enter the cache in the second hopper. On lookups, cache hits result in the
// cache entry being promoted to the first hopper. When the first hopper is full, the third hopper is dropped,
// and the first and second hoppers are shifted down, leaving an empty first hopper. If the second hopper is
// full when a new cache entry is added, the third hopper is dropped, the second hopper is shifted down, and a
// new second hopper is slotted in to become the new item entrypoint.
//
// Items can only be added and looked up. There's no way to remove an item besides through attrition.
//
// This cache has a built-in concept of weakly-referenced items (which can be enabled or disabled in the
// constructor). It needs this concept since the caller of the cache can't remove dead cache items itself.
// A weak HopperCache will simply ignore dead entries.
//
// This structure allows cache lookups to be almost lock-free. The only time the first hopper is written to
// is when a cache entry is promoted. Promoting a cache entry is not critical - it's ok to skip a promotion.
// Only one promotion is allowed at a time. If a second is attempted, it is skipped. This allows promotions
// to be synchronized with just an Interlocked call.
//
// New cache entries go into the second hopper, which requires a lock, as does shifting the hoppers down.
//
// The hopperSize parameter determines the size of the first hopper. When it reaches this size, the hoppers
// are shifted. The second hopper is allowed to grow to twice this size. This is because it needs room to get
// new cache entries into the system, and the second hopper typically starts out 'full'. Entries are never added
// directly to the third hopper.
//
// It's a error on the part of the caller to add the same key to the cache again if it's already in the cache
// with a different value. The new value will not necessarily overwrite the old value.
//
// If a cache entry is about to be promoted from the third hopper, and in the mean time the third hopper has been
// shifted away, an intervening GetValue for the same key might return null, even though the item is still in
// the cache and a later GetValue might find it. So it's very important never to add the same key to the cache
// with two different values, even if GetValue returns null for the key in-between the first add and the second.
// (If this particular behavior is a problem, it may be possible to tighten up, but it's not necessary for the
// current use of HopperCache - UriPrefixTable.)
class HopperCache
{
readonly int hopperSize;
readonly bool weak;
Hashtable outstandingHopper;
Hashtable strongHopper;
Hashtable limitedHopper;
int promoting;
LastHolder mruEntry;
public HopperCache(int hopperSize, bool weak)
{
Fx.Assert(hopperSize > 0, "HopperCache hopperSize must be positive.");
this.hopperSize = hopperSize;
this.weak = weak;
this.outstandingHopper = new Hashtable(hopperSize * 2);
this.strongHopper = new Hashtable(hopperSize * 2);
this.limitedHopper = new Hashtable(hopperSize * 2);
}
// Calls to Add must be synchronized.
public void Add(object key, object value)
{
Fx.Assert(key != null, "HopperCache key cannot be null.");
Fx.Assert(value != null, "HopperCache value cannot be null.");
// Special-case DBNull since it can never be collected.
if (this.weak && !object.ReferenceEquals(value, DBNull.Value))
{
value = new WeakReference(value);
}
Fx.Assert(this.strongHopper.Count <= this.hopperSize * 2,
"HopperCache strongHopper is bigger than it's allowed to get.");
if (this.strongHopper.Count >= this.hopperSize * 2)
{
Hashtable recycled = this.limitedHopper;
recycled.Clear();
recycled.Add(key, value);
// The try/finally is here to make sure these happen without interruption.
try { } finally
{
this.limitedHopper = this.strongHopper;
this.strongHopper = recycled;
}
}
else
{
// We do nothing to prevent things from getting added multiple times. Also may be writing over
// a dead weak entry.
this.strongHopper[key] = value;
}
}
// Calls to GetValue do not need to be synchronized, but the object used to synchronize the Add calls
// must be passed in. It's sometimes used.
public object GetValue(object syncObject, object key)
{
Fx.Assert(key != null, "Can't look up a null key.");
WeakReference weakRef;
object value;
// The MruCache does this so we have to too.
LastHolder last = this.mruEntry;
if (last != null && key.Equals(last.Key))
{
if (this.weak && (weakRef = last.Value as WeakReference) != null)
{
value = weakRef.Target;
if (value != null)
{
return value;
}
this.mruEntry = null;
}
else
{
return last.Value;
}
}
// Try the first hopper.
object origValue = this.outstandingHopper[key];
value = this.weak && (weakRef = origValue as WeakReference) != null ? weakRef.Target : origValue;
if (value != null)
{
this.mruEntry = new LastHolder(key, origValue);
return value;
}
// Try the subsequent hoppers.
origValue = this.strongHopper[key];
value = this.weak && (weakRef = origValue as WeakReference) != null ? weakRef.Target : origValue;
if (value == null)
{
origValue = this.limitedHopper[key];
value = this.weak && (weakRef = origValue as WeakReference) != null ? weakRef.Target : origValue;
if (value == null)
{
// Still no value? It's not here.
return null;
}
}
this.mruEntry = new LastHolder(key, origValue);
// If we can get the promoting semaphore, move up to the outstanding hopper.
int wasPromoting = 1;
try
{
try { } finally
{
// This is effectively a lock, which is why it uses lock semantics. If the Interlocked call
// were 'lost', the cache wouldn't deadlock, but it would be permanently broken.
wasPromoting = Interlocked.CompareExchange(ref this.promoting, 1, 0);
}
// Only one thread can be inside this 'if' at a time.
if (wasPromoting == 0)
{
Fx.Assert(this.outstandingHopper.Count <= this.hopperSize,
"HopperCache outstandingHopper is bigger than it's allowed to get.");
if (this.outstandingHopper.Count >= this.hopperSize)
{
lock (syncObject)
{
Hashtable recycled = this.limitedHopper;
recycled.Clear();
recycled.Add(key, origValue);
// The try/finally is here to make sure these happen without interruption.
try { } finally
{
this.limitedHopper = this.strongHopper;
this.strongHopper = this.outstandingHopper;
this.outstandingHopper = recycled;
}
}
}
else
{
// It's easy for this to happen twice with the same key.
//
// It's important that no one else can be shifting the current oustandingHopper
// during this operation. We are only allowed to modify the *current* outstandingHopper
// while holding the pseudo-lock, which would be violated if it could be shifted out from
// under us (and potentially added to by Add in a ----).
this.outstandingHopper[key] = origValue;
}
}
}
finally
{
if (wasPromoting == 0)
{
this.promoting = 0;
}
}
return value;
}
class LastHolder
{
readonly object key;
readonly object value;
internal LastHolder(object key, object value)
{
this.key = key;
this.value = value;
}
internal object Key
{
get
{
return this.key;
}
}
internal object Value
{
get
{
return this.value;
}
}
}
}
}

View File

@@ -0,0 +1,372 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.Collections
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime;
class NullableKeyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{
bool isNullKeyPresent;
TValue nullKeyValue;
IDictionary<TKey, TValue> innerDictionary;
public NullableKeyDictionary()
: base()
{
this.innerDictionary = new Dictionary<TKey, TValue>();
}
public int Count
{
get { return this.innerDictionary.Count + (this.isNullKeyPresent ? 1 : 0); }
}
public bool IsReadOnly
{
get { return false; }
}
public ICollection<TKey> Keys
{
get
{
return new NullKeyDictionaryKeyCollection<TKey, TValue>(this);
}
}
public ICollection<TValue> Values
{
get { return new NullKeyDictionaryValueCollection<TKey, TValue>(this); }
}
public TValue this[TKey key]
{
get
{
if (key == null)
{
if (this.isNullKeyPresent)
{
return this.nullKeyValue;
}
else
{
throw Fx.Exception.AsError(new KeyNotFoundException());
}
}
else
{
return this.innerDictionary[key];
}
}
set
{
if (key == null)
{
this.isNullKeyPresent = true;
this.nullKeyValue = value;
}
else
{
this.innerDictionary[key] = value;
}
}
}
public void Add(TKey key, TValue value)
{
if (key == null)
{
if (this.isNullKeyPresent)
{
throw Fx.Exception.Argument("key", InternalSR.NullKeyAlreadyPresent);
}
this.isNullKeyPresent = true;
this.nullKeyValue = value;
}
else
{
this.innerDictionary.Add(key, value);
}
}
public bool ContainsKey(TKey key)
{
return key == null ? this.isNullKeyPresent : this.innerDictionary.ContainsKey(key);
}
public bool Remove(TKey key)
{
if (key == null)
{
bool result = this.isNullKeyPresent;
this.isNullKeyPresent = false;
this.nullKeyValue = default(TValue);
return result;
}
else
{
return this.innerDictionary.Remove(key);
}
}
public bool TryGetValue(TKey key, out TValue value)
{
if (key == null)
{
if (this.isNullKeyPresent)
{
value = this.nullKeyValue;
return true;
}
else
{
value = default(TValue);
return false;
}
}
else
{
return this.innerDictionary.TryGetValue(key, out value);
}
}
public void Add(KeyValuePair<TKey, TValue> item)
{
Add(item.Key, item.Value);
}
public void Clear()
{
this.isNullKeyPresent = false;
this.nullKeyValue = default(TValue);
this.innerDictionary.Clear();
}
public bool Contains(KeyValuePair<TKey, TValue> item)
{
if (item.Key == null)
{
if (this.isNullKeyPresent)
{
return item.Value == null ? this.nullKeyValue == null : item.Value.Equals(this.nullKeyValue);
}
else
{
return false;
}
}
else
{
return this.innerDictionary.Contains(item);
}
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
this.innerDictionary.CopyTo(array, arrayIndex);
if (this.isNullKeyPresent)
{
array[arrayIndex + this.innerDictionary.Count] = new KeyValuePair<TKey, TValue>(default(TKey), this.nullKeyValue);
}
}
public bool Remove(KeyValuePair<TKey, TValue> item)
{
if (item.Key == null)
{
if (this.Contains(item))
{
this.isNullKeyPresent = false;
this.nullKeyValue = default(TValue);
return true;
}
else
{
return false;
}
}
else
{
return this.innerDictionary.Remove(item);
}
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
IEnumerator<KeyValuePair<TKey, TValue>> innerEnumerator = this.innerDictionary.GetEnumerator() as IEnumerator<KeyValuePair<TKey, TValue>>;
while (innerEnumerator.MoveNext())
{
yield return innerEnumerator.Current;
}
if (this.isNullKeyPresent)
{
yield return new KeyValuePair<TKey, TValue>(default(TKey), this.nullKeyValue);
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<KeyValuePair<TKey, TValue>>)this).GetEnumerator();
}
class NullKeyDictionaryKeyCollection<TypeKey, TypeValue> : ICollection<TypeKey>
{
NullableKeyDictionary<TypeKey, TypeValue> nullKeyDictionary;
public NullKeyDictionaryKeyCollection(NullableKeyDictionary<TypeKey, TypeValue> nullKeyDictionary)
{
this.nullKeyDictionary = nullKeyDictionary;
}
public int Count
{
get
{
int count = this.nullKeyDictionary.innerDictionary.Keys.Count;
if (this.nullKeyDictionary.isNullKeyPresent)
{
count++;
}
return count;
}
}
public bool IsReadOnly
{
get { return true; }
}
public void Add(TypeKey item)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.KeyCollectionUpdatesNotAllowed));
}
public void Clear()
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.KeyCollectionUpdatesNotAllowed));
}
public bool Contains(TypeKey item)
{
return item == null ? this.nullKeyDictionary.isNullKeyPresent : this.nullKeyDictionary.innerDictionary.Keys.Contains(item);
}
public void CopyTo(TypeKey[] array, int arrayIndex)
{
this.nullKeyDictionary.innerDictionary.Keys.CopyTo(array, arrayIndex);
if (this.nullKeyDictionary.isNullKeyPresent)
{
array[arrayIndex + this.nullKeyDictionary.innerDictionary.Keys.Count] = default(TypeKey);
}
}
public bool Remove(TypeKey item)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.KeyCollectionUpdatesNotAllowed));
}
public IEnumerator<TypeKey> GetEnumerator()
{
foreach (TypeKey item in this.nullKeyDictionary.innerDictionary.Keys)
{
yield return item;
}
if (this.nullKeyDictionary.isNullKeyPresent)
{
yield return default(TypeKey);
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<TypeKey>)this).GetEnumerator();
}
}
class NullKeyDictionaryValueCollection<TypeKey, TypeValue> : ICollection<TypeValue>
{
NullableKeyDictionary<TypeKey, TypeValue> nullKeyDictionary;
public NullKeyDictionaryValueCollection(NullableKeyDictionary<TypeKey, TypeValue> nullKeyDictionary)
{
this.nullKeyDictionary = nullKeyDictionary;
}
public int Count
{
get
{
int count = this.nullKeyDictionary.innerDictionary.Values.Count;
if (this.nullKeyDictionary.isNullKeyPresent)
{
count++;
}
return count;
}
}
public bool IsReadOnly
{
get { return true; }
}
public void Add(TypeValue item)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ValueCollectionUpdatesNotAllowed));
}
public void Clear()
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ValueCollectionUpdatesNotAllowed));
}
public bool Contains(TypeValue item)
{
return this.nullKeyDictionary.innerDictionary.Values.Contains(item) ||
(this.nullKeyDictionary.isNullKeyPresent && this.nullKeyDictionary.nullKeyValue.Equals(item));
}
public void CopyTo(TypeValue[] array, int arrayIndex)
{
this.nullKeyDictionary.innerDictionary.Values.CopyTo(array, arrayIndex);
if (this.nullKeyDictionary.isNullKeyPresent)
{
array[arrayIndex + this.nullKeyDictionary.innerDictionary.Values.Count] = this.nullKeyDictionary.nullKeyValue;
}
}
public bool Remove(TypeValue item)
{
throw Fx.Exception.AsError(new NotSupportedException(InternalSR.ValueCollectionUpdatesNotAllowed));
}
public IEnumerator<TypeValue> GetEnumerator()
{
foreach (TypeValue item in this.nullKeyDictionary.innerDictionary.Values)
{
yield return item;
}
if (this.nullKeyDictionary.isNullKeyPresent)
{
yield return this.nullKeyDictionary.nullKeyValue;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<TypeValue>)this).GetEnumerator();
}
}
}
}

View File

@@ -0,0 +1,15 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.Collections
{
abstract class ObjectCacheItem<T>
where T : class
{
// only valid when you've called TryAddReference successfully
public abstract T Value { get; }
public abstract bool TryAddReference();
public abstract void ReleaseReference();
}
}

View File

@@ -0,0 +1,93 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.Collections
{
class ObjectCacheSettings
{
int cacheLimit;
TimeSpan idleTimeout;
TimeSpan leaseTimeout;
int purgeFrequency;
const int DefaultCacheLimit = 64;
const int DefaultPurgeFrequency = 32;
static TimeSpan DefaultIdleTimeout = TimeSpan.FromMinutes(2);
static TimeSpan DefaultLeaseTimeout = TimeSpan.FromMinutes(5);
public ObjectCacheSettings()
{
this.CacheLimit = DefaultCacheLimit;
this.IdleTimeout = DefaultIdleTimeout;
this.LeaseTimeout = DefaultLeaseTimeout;
this.PurgeFrequency = DefaultPurgeFrequency;
}
ObjectCacheSettings(ObjectCacheSettings other)
{
this.CacheLimit = other.CacheLimit;
this.IdleTimeout = other.IdleTimeout;
this.LeaseTimeout = other.LeaseTimeout;
this.PurgeFrequency = other.PurgeFrequency;
}
internal ObjectCacheSettings Clone()
{
return new ObjectCacheSettings(this);
}
public int CacheLimit
{
get
{
return this.cacheLimit;
}
set
{
Fx.Assert(value >= 0, "caller should validate cache limit is non-negative");
this.cacheLimit = value;
}
}
public TimeSpan IdleTimeout
{
get
{
return this.idleTimeout;
}
set
{
Fx.Assert(value >= TimeSpan.Zero, "caller should validate cache limit is non-negative");
this.idleTimeout = value;
}
}
public TimeSpan LeaseTimeout
{
get
{
return this.leaseTimeout;
}
set
{
Fx.Assert(value >= TimeSpan.Zero, "caller should validate cache limit is non-negative");
this.leaseTimeout = value;
}
}
public int PurgeFrequency
{
get
{
return this.purgeFrequency;
}
set
{
Fx.Assert(value >= 0, "caller should validate purge frequency is non-negative");
this.purgeFrequency = value;
}
}
}
}

View File

@@ -0,0 +1,342 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.Collections
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
// System.Collections.Specialized.OrderedDictionary is NOT generic.
// This class is essentially a generic wrapper for OrderedDictionary.
class OrderedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary
{
OrderedDictionary privateDictionary;
public OrderedDictionary()
{
this.privateDictionary = new OrderedDictionary();
}
public OrderedDictionary(IDictionary<TKey, TValue> dictionary)
{
if (dictionary != null)
{
this.privateDictionary = new OrderedDictionary();
foreach (KeyValuePair<TKey, TValue> pair in dictionary)
{
this.privateDictionary.Add(pair.Key, pair.Value);
}
}
}
public int Count
{
get
{
return this.privateDictionary.Count;
}
}
public bool IsReadOnly
{
get
{
return false;
}
}
public TValue this[TKey key]
{
get
{
if (key == null)
{
throw Fx.Exception.ArgumentNull("key");
}
if (this.privateDictionary.Contains(key))
{
return (TValue)this.privateDictionary[(object)key];
}
else
{
throw Fx.Exception.AsError(new KeyNotFoundException(InternalSR.KeyNotFoundInDictionary));
}
}
set
{
if (key == null)
{
throw Fx.Exception.ArgumentNull("key");
}
this.privateDictionary[(object)key] = value;
}
}
public ICollection<TKey> Keys
{
get
{
List<TKey> keys = new List<TKey>(this.privateDictionary.Count);
foreach (TKey key in this.privateDictionary.Keys)
{
keys.Add(key);
}
// Keys should be put in a ReadOnlyCollection,
// but since this is an internal class, for performance reasons,
// we choose to avoid creating yet another collection.
return keys;
}
}
public ICollection<TValue> Values
{
get
{
List<TValue> values = new List<TValue>(this.privateDictionary.Count);
foreach (TValue value in this.privateDictionary.Values)
{
values.Add(value);
}
// Values should be put in a ReadOnlyCollection,
// but since this is an internal class, for performance reasons,
// we choose to avoid creating yet another collection.
return values;
}
}
public void Add(KeyValuePair<TKey, TValue> item)
{
Add(item.Key, item.Value);
}
public void Add(TKey key, TValue value)
{
if (key == null)
{
throw Fx.Exception.ArgumentNull("key");
}
this.privateDictionary.Add(key, value);
}
public void Clear()
{
this.privateDictionary.Clear();
}
public bool Contains(KeyValuePair<TKey, TValue> item)
{
if (item.Key == null || !this.privateDictionary.Contains(item.Key))
{
return false;
}
else
{
return this.privateDictionary[(object)item.Key].Equals(item.Value);
}
}
public bool ContainsKey(TKey key)
{
if (key == null)
{
throw Fx.Exception.ArgumentNull("key");
}
return this.privateDictionary.Contains(key);
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
if (array == null)
{
throw Fx.Exception.ArgumentNull("array");
}
if (arrayIndex < 0)
{
throw Fx.Exception.AsError(new ArgumentOutOfRangeException("arrayIndex"));
}
if (array.Rank > 1 || arrayIndex >= array.Length || array.Length - arrayIndex < this.privateDictionary.Count)
{
throw Fx.Exception.Argument("array", InternalSR.BadCopyToArray);
}
int index = arrayIndex;
foreach (DictionaryEntry entry in this.privateDictionary)
{
array[index] = new KeyValuePair<TKey, TValue>((TKey)entry.Key, (TValue)entry.Value);
index++;
}
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
foreach (DictionaryEntry entry in this.privateDictionary)
{
yield return new KeyValuePair<TKey, TValue>((TKey)entry.Key, (TValue)entry.Value);
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public bool Remove(KeyValuePair<TKey, TValue> item)
{
if (Contains(item))
{
this.privateDictionary.Remove(item.Key);
return true;
}
else
{
return false;
}
}
public bool Remove(TKey key)
{
if (key == null)
{
throw Fx.Exception.ArgumentNull("key");
}
if (this.privateDictionary.Contains(key))
{
this.privateDictionary.Remove(key);
return true;
}
else
{
return false;
}
}
public bool TryGetValue(TKey key, out TValue value)
{
if (key == null)
{
throw Fx.Exception.ArgumentNull("key");
}
bool keyExists = this.privateDictionary.Contains(key);
value = keyExists ? (TValue)this.privateDictionary[(object)key] : default(TValue);
return keyExists;
}
void IDictionary.Add(object key, object value)
{
this.privateDictionary.Add(key, value);
}
void IDictionary.Clear()
{
this.privateDictionary.Clear();
}
bool IDictionary.Contains(object key)
{
return this.privateDictionary.Contains(key);
}
IDictionaryEnumerator IDictionary.GetEnumerator()
{
return this.privateDictionary.GetEnumerator();
}
bool IDictionary.IsFixedSize
{
get
{
return ((IDictionary)this.privateDictionary).IsFixedSize;
}
}
bool IDictionary.IsReadOnly
{
get
{
return this.privateDictionary.IsReadOnly;
}
}
ICollection IDictionary.Keys
{
get
{
return this.privateDictionary.Keys;
}
}
void IDictionary.Remove(object key)
{
this.privateDictionary.Remove(key);
}
ICollection IDictionary.Values
{
get
{
return this.privateDictionary.Values;
}
}
object IDictionary.this[object key]
{
get
{
return this.privateDictionary[key];
}
set
{
this.privateDictionary[key] = value;
}
}
void ICollection.CopyTo(Array array, int index)
{
this.privateDictionary.CopyTo(array, index);
}
int ICollection.Count
{
get
{
return this.privateDictionary.Count;
}
}
bool ICollection.IsSynchronized
{
get
{
return ((ICollection)this.privateDictionary).IsSynchronized;
}
}
object ICollection.SyncRoot
{
get
{
return ((ICollection)this.privateDictionary).SyncRoot;
}
}
}
}

View File

@@ -0,0 +1,61 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.Collections
{
using System.Collections.ObjectModel;
// simple helper class to allow passing in a func that performs validations of
// acceptible values
class ValidatingCollection<T> : Collection<T>
{
public ValidatingCollection()
{
}
public Action<T> OnAddValidationCallback { get; set; }
public Action OnMutateValidationCallback { get; set; }
void OnAdd(T item)
{
if (OnAddValidationCallback != null)
{
OnAddValidationCallback(item);
}
}
void OnMutate()
{
if (OnMutateValidationCallback != null)
{
OnMutateValidationCallback();
}
}
protected override void ClearItems()
{
OnMutate();
base.ClearItems();
}
protected override void InsertItem(int index, T item)
{
OnAdd(item);
base.InsertItem(index, item);
}
protected override void RemoveItem(int index)
{
OnMutate();
base.RemoveItem(index);
}
protected override void SetItem(int index, T item)
{
OnAdd(item);
OnMutate();
base.SetItem(index, item);
}
}
}

View File

@@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Threading;
//An AsyncResult that completes as soon as it is instantiated.
class CompletedAsyncResult : AsyncResult
{
public CompletedAsyncResult(AsyncCallback callback, object state)
: base(callback, state)
{
Complete(true);
}
[Fx.Tag.GuaranteeNonBlocking]
public static void End(IAsyncResult result)
{
Fx.AssertAndThrowFatal(result.IsCompleted, "CompletedAsyncResult was not completed!");
AsyncResult.End<CompletedAsyncResult>(result);
}
}
class CompletedAsyncResult<T> : AsyncResult
{
T data;
public CompletedAsyncResult(T data, AsyncCallback callback, object state)
: base(callback, state)
{
this.data = data;
Complete(true);
}
[Fx.Tag.GuaranteeNonBlocking]
public static T End(IAsyncResult result)
{
Fx.AssertAndThrowFatal(result.IsCompleted, "CompletedAsyncResult<T> was not completed!");
CompletedAsyncResult<T> completedResult = AsyncResult.End<CompletedAsyncResult<T>>(result);
return completedResult.data;
}
}
class CompletedAsyncResult<TResult, TParameter> : AsyncResult
{
TResult resultData;
TParameter parameter;
public CompletedAsyncResult(TResult resultData, TParameter parameter, AsyncCallback callback, object state)
: base(callback, state)
{
this.resultData = resultData;
this.parameter = parameter;
Complete(true);
}
[Fx.Tag.GuaranteeNonBlocking]
public static TResult End(IAsyncResult result, out TParameter parameter)
{
Fx.AssertAndThrowFatal(result.IsCompleted, "CompletedAsyncResult<T> was not completed!");
CompletedAsyncResult<TResult, TParameter> completedResult = AsyncResult.End<CompletedAsyncResult<TResult, TParameter>>(result);
parameter = completedResult.parameter;
return completedResult.resultData;
}
}
}

View File

@@ -0,0 +1,19 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime
{
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/computer_name_format_str.asp
enum ComputerNameFormat
{
NetBIOS,
DnsHostName,
Dns,
DnsFullyQualified,
PhysicalNetBIOS,
PhysicalDnsHostName,
PhysicalDnsDomain,
PhysicalDnsFullyQualified
}
}

View File

@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Collections.Generic;
using System.Text;
static class DiagnosticStrings
{
internal const string AppDomain = "AppDomain";
internal const string ChannelTag = "Channel";
internal const string Description = "Description";
internal const string DataTag = "Data";
internal const string DataItemsTag = "DataItems";
internal const string DescriptionTag = "Description";
internal const string ExceptionTag = "Exception";
internal const string ExceptionTypeTag = "ExceptionType";
internal const string ExceptionStringTag = "ExceptionString";
internal const string ExtendedDataTag = "ExtendedData";
internal const string InnerExceptionTag = "InnerException";
internal const string KeyTag = "Key";
internal const string MessageTag = "Message";
internal const string NamespaceTag = "xmlns";
internal const string NativeErrorCodeTag = "NativeErrorCode";
internal const string Separator = ":";
internal const string SeverityTag = "Severity";
internal const string SourceTag = "Source";
internal const string StackTraceTag = "StackTrace";
internal const string Task = "Task";
internal const string TraceCodeTag = "TraceIdentifier";
internal const string TraceRecordTag = "TraceRecord";
internal const string ValueTag = "Value";
}
}

Some files were not shown because too many files have changed in this diff Show More