summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics')
-rw-r--r--src/mscorlib/src/System/Diagnostics/Assert.cs18
-rw-r--r--src/mscorlib/src/System/Diagnostics/AssertFilter.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs19
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs62
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debugger.cs9
-rw-r--r--src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs20
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs13
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs66
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs465
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs4
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs9
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceActivity.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs7
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs3
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/Statics.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingDataCollector.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs18
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs10
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs6
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs4
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs28
-rw-r--r--src/mscorlib/src/System/Diagnostics/LogSwitch.cs7
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stackframe.cs23
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stacktrace.cs79
-rw-r--r--src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs30
-rw-r--r--src/mscorlib/src/System/Diagnostics/log.cs5
28 files changed, 317 insertions, 597 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/Assert.cs b/src/mscorlib/src/System/Diagnostics/Assert.cs
index 40efe753af..77cc6d8e46 100644
--- a/src/mscorlib/src/System/Diagnostics/Assert.cs
+++ b/src/mscorlib/src/System/Diagnostics/Assert.cs
@@ -59,7 +59,6 @@ namespace System.Diagnostics {
Fail(conditionString, message, null, exitCode, stackTraceFormat, 0);
}
- [System.Security.SecuritySafeCritical] // auto-generated
internal static void Fail(String conditionString, String message, String windowTitle, int exitCode, StackTrace.TraceFormat stackTraceFormat, int numStackFramesToSkip)
{
// get the stacktrace
@@ -82,32 +81,15 @@ namespace System.Diagnostics {
}
else if (iResult == AssertFilters.FailTerminate)
{
-#if FEATURE_CORECLR
// We want to exit the Silverlight application, after displaying a message.
// Our best known way to emulate this is to exit the process with a known
// error code. Jolt may not be prepared for an appdomain to be unloaded.
Environment._Exit(exitCode);
-#else
- // This assert dialog will be common for code contract failures. If a code contract failure
- // occurs on an end user machine, we believe the right experience is to do a FailFast, which
- // will report this error via Watson, so someone could theoretically fix the bug.
- // However, in CLR v4, Environment.FailFast when a debugger is attached gives you an MDA
- // saying you've hit a bug in the runtime or unsafe managed code, and this is most likely caused
- // by heap corruption or a stack imbalance from COM Interop or P/Invoke. That extremely
- // misleading error isn't right, and we can temporarily work around this by using Environment.Exit
- // if a debugger is attached. The right fix is to plumb FailFast correctly through our native
- // Watson code, adding in a TypeOfReportedError for fatal managed errors.
- if (Debugger.IsAttached)
- Environment._Exit(exitCode);
- else
- Environment.FailFast(message, unchecked((uint) exitCode));
-#endif
}
}
// Called when an assert happens.
// windowTitle can be null.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static int ShowDefaultAssertDialog(String conditionString, String message, String stackTrace, String windowTitle);
}
diff --git a/src/mscorlib/src/System/Diagnostics/AssertFilter.cs b/src/mscorlib/src/System/Diagnostics/AssertFilter.cs
index b441fc326b..ab60ee4cff 100644
--- a/src/mscorlib/src/System/Diagnostics/AssertFilter.cs
+++ b/src/mscorlib/src/System/Diagnostics/AssertFilter.cs
@@ -33,7 +33,6 @@ namespace System.Diagnostics {
{
}
- [System.Security.SecuritySafeCritical] // auto-generated
public override AssertFilters AssertFailure(String condition, String message,
StackTrace location, StackTrace.TraceFormat stackTraceFormat,
String windowTitle)
diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs
index e002e6a5c1..27f4f4cdaa 100644
--- a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs
+++ b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs
@@ -32,6 +32,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
@@ -287,7 +288,7 @@ namespace System.Diagnostics.Contracts {
/// </summary>
/// <param name="condition">Expression to assume will always be true.</param>
/// <remarks>
- /// At runtime this is equivalent to an <seealso cref="System.Diagnostics.Contracts.Contract.Assert(bool)"/>.
+ /// At runtime this is equivalent to an <seealso cref="System.Diagnostics.Contracts.Debug.Assert(bool)"/>.
/// </remarks>
[Pure]
[Conditional("DEBUG")]
@@ -308,7 +309,7 @@ namespace System.Diagnostics.Contracts {
/// <param name="condition">Expression to assume will always be true.</param>
/// <param name="userMessage">If it is not a constant string literal, then the contract may not be understood by tools.</param>
/// <remarks>
- /// At runtime this is equivalent to an <seealso cref="System.Diagnostics.Contracts.Contract.Assert(bool)"/>.
+ /// At runtime this is equivalent to an <seealso cref="System.Diagnostics.Contracts.Debug.Assert(bool)"/>.
/// </remarks>
[Pure]
[Conditional("DEBUG")]
@@ -654,7 +655,7 @@ namespace System.Diagnostics.Contracts {
throw new ArgumentException("fromInclusive must be less than or equal to toExclusive.");
#endif
if (predicate == null)
- throw new ArgumentNullException("predicate");
+ throw new ArgumentNullException(nameof(predicate));
Contract.EndContractBlock();
for (int i = fromInclusive; i < toExclusive; i++)
@@ -679,9 +680,9 @@ namespace System.Diagnostics.Contracts {
public static bool ForAll<T>(IEnumerable<T> collection, Predicate<T> predicate)
{
if (collection == null)
- throw new ArgumentNullException("collection");
+ throw new ArgumentNullException(nameof(collection));
if (predicate == null)
- throw new ArgumentNullException("predicate");
+ throw new ArgumentNullException(nameof(predicate));
Contract.EndContractBlock();
foreach (T t in collection)
@@ -716,7 +717,7 @@ namespace System.Diagnostics.Contracts {
throw new ArgumentException("fromInclusive must be less than or equal to toExclusive.");
#endif
if (predicate == null)
- throw new ArgumentNullException("predicate");
+ throw new ArgumentNullException(nameof(predicate));
Contract.EndContractBlock();
for (int i = fromInclusive; i < toExclusive; i++)
@@ -740,9 +741,9 @@ namespace System.Diagnostics.Contracts {
public static bool Exists<T>(IEnumerable<T> collection, Predicate<T> predicate)
{
if (collection == null)
- throw new ArgumentNullException("collection");
+ throw new ArgumentNullException(nameof(collection));
if (predicate == null)
- throw new ArgumentNullException("predicate");
+ throw new ArgumentNullException(nameof(predicate));
Contract.EndContractBlock();
foreach (T t in collection)
@@ -805,7 +806,6 @@ namespace System.Diagnostics.Contracts {
[CLSCompliant(false)]
[Pure]
[ContractRuntimeIgnored]
- [SecurityCritical]
#if FEATURE_RELIABILITY_CONTRACTS
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
@@ -852,7 +852,6 @@ namespace System.Diagnostics.Contracts {
[CLSCompliant(false)]
[Pure]
[ContractRuntimeIgnored]
- [SecurityCritical]
#if FEATURE_RELIABILITY_CONTRACTS
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
index 804318e702..d5e3f29e6c 100644
--- a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
+++ b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
@@ -51,7 +51,6 @@ namespace System.Diagnostics.Contracts {
/// This method is used internally to trigger a failure indicating to the "programmer" that he is using the interface incorrectly.
/// It is NEVER used to indicate failure of actual contracts at runtime.
/// </summary>
- [SecuritySafeCritical]
static partial void AssertMustUseRewriter(ContractFailureKind kind, String contractKind)
{
if (_assertingMustUseRewriter)
@@ -99,7 +98,7 @@ namespace System.Diagnostics.Contracts {
static partial void ReportFailure(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException)
{
if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume)
- throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", failureKind), "failureKind");
+ throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", failureKind), nameof(failureKind));
Contract.EndContractBlock();
// displayMessage == null means: yes we handled it. Otherwise it is the localized failure message
@@ -121,18 +120,14 @@ namespace System.Diagnostics.Contracts {
/// </summary>
public static event EventHandler<ContractFailedEventArgs> ContractFailed {
#if FEATURE_UNTRUSTED_CALLERS
- [SecurityCritical]
#if FEATURE_LINK_DEMAND
- [SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
#endif
add {
System.Runtime.CompilerServices.ContractHelper.InternalContractFailed += value;
}
#if FEATURE_UNTRUSTED_CALLERS
- [SecurityCritical]
#if FEATURE_LINK_DEMAND
- [SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
#endif
remove {
@@ -176,9 +171,7 @@ namespace System.Diagnostics.Contracts {
}
#if FEATURE_UNTRUSTED_CALLERS
- [SecurityCritical]
#if FEATURE_LINK_DEMAND
- [SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
#endif
public void SetHandled()
@@ -191,9 +184,7 @@ namespace System.Diagnostics.Contracts {
}
#if FEATURE_UNTRUSTED_CALLERS
- [SecurityCritical]
#if FEATURE_LINK_DEMAND
- [SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
#endif
public void SetUnwind()
@@ -243,9 +234,7 @@ namespace System.Diagnostics.Contracts {
}
#if FEATURE_UNTRUSTED_CALLERS && FEATURE_SERIALIZATION
- [SecurityCritical]
#if FEATURE_LINK_DEMAND && FEATURE_SERIALIZATION
- [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
#endif // FEATURE_LINK_DEMAND
#endif // FEATURE_UNTRUSTED_CALLERS
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
@@ -284,7 +273,6 @@ namespace System.Runtime.CompilerServices
internal static event EventHandler<ContractFailedEventArgs> InternalContractFailed
{
#if FEATURE_UNTRUSTED_CALLERS
- [SecurityCritical]
#endif
add {
// Eagerly prepare each event handler _marked with a reliability contract_, to
@@ -301,7 +289,6 @@ namespace System.Runtime.CompilerServices
}
}
#if FEATURE_UNTRUSTED_CALLERS
- [SecurityCritical]
#endif
remove {
lock (lockObject)
@@ -326,12 +313,11 @@ namespace System.Runtime.CompilerServices
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
[System.Diagnostics.DebuggerNonUserCode]
#if FEATURE_RELIABILITY_CONTRACTS
- [SecuritySafeCritical]
#endif
static partial void RaiseContractFailedEventImplementation(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException, ref string resultFailureMessage)
{
if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume)
- throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", failureKind), "failureKind");
+ throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", failureKind), nameof(failureKind));
Contract.EndContractBlock();
string returnValue;
@@ -361,10 +347,6 @@ namespace System.Runtime.CompilerServices
}
if (eventArgs.Unwind)
{
-#if !FEATURE_CORECLR
- if (Environment.IsCLRHosted)
- TriggerCodeContractEscalationPolicy(failureKind, displayMessage, conditionText, innerException);
-#endif
// unwind
if (innerException == null) { innerException = eventArgs.thrownDuringHandler; }
throw new ContractException(failureKind, displayMessage, userMessage, conditionText, innerException);
@@ -393,9 +375,6 @@ namespace System.Runtime.CompilerServices
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "kind")]
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "innerException")]
[System.Diagnostics.DebuggerNonUserCode]
-#if FEATURE_UNTRUSTED_CALLERS && !FEATURE_CORECLR
- [SecuritySafeCritical]
-#endif
static partial void TriggerFailureImplementation(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException)
{
// If we're here, our intent is to pop up a dialog box (if we can). For developers
@@ -403,21 +382,12 @@ namespace System.Runtime.CompilerServices
// hosted in Internet Explorer, the assert window is great. If we cannot
// pop up a dialog box, throw an exception (consider a library compiled with
// "Assert On Failure" but used in a process that can't pop up asserts, like an
- // NT Service). For the CLR hosted by server apps like SQL or Exchange, we should
- // trigger escalation policy.
-#if !FEATURE_CORECLR
- if (Environment.IsCLRHosted)
- {
- TriggerCodeContractEscalationPolicy(kind, displayMessage, conditionText, innerException);
- // Hosts like SQL may choose to abort the thread, so we will not get here in all cases.
- // But if the host's chosen action was to throw an exception, we should throw an exception
- // here (which is easier to do in managed code with the right parameters).
- throw new ContractException(kind, displayMessage, userMessage, conditionText, innerException);
- }
-#endif // !FEATURE_CORECLR
+ // NT Service).
+
if (!Environment.UserInteractive) {
throw new ContractException(kind, displayMessage, userMessage, conditionText, innerException);
}
+
// May need to rethink Assert.Fail w/ TaskDialogIndirect as a model. Window title. Main instruction. Content. Expanded info.
// Optional info like string for collapsed text vs. expanded text.
String windowTitle = Environment.GetResourceString(GetResourceNameForFailure(kind));
@@ -494,28 +464,6 @@ namespace System.Runtime.CompilerServices
return failureMessage;
}
}
-
-#if !FEATURE_CORECLR
- // Will trigger escalation policy, if hosted and the host requested us to do something (such as
- // abort the thread or exit the process). Starting in Dev11, for hosted apps the default behavior
- // is to throw an exception.
- // Implementation notes:
- // We implement our default behavior of throwing an exception by simply returning from our native
- // method inside the runtime and falling through to throw an exception.
- // We must call through this method before calling the method on the Environment class
- // because our security team does not yet support SecuritySafeCritical on P/Invoke methods.
- // Note this can be called in the context of throwing another exception (EnsuresOnThrow).
- [SecuritySafeCritical]
- [DebuggerNonUserCode]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- private static void TriggerCodeContractEscalationPolicy(ContractFailureKind failureKind, String message, String conditionText, Exception innerException)
- {
- String exceptionAsString = null;
- if (innerException != null)
- exceptionAsString = innerException.ToString();
- Environment.TriggerCodeContractFailure(failureKind, message, conditionText, exceptionAsString);
- }
-#endif // !FEATURE_CORECLR
}
} // namespace System.Runtime.CompilerServices
diff --git a/src/mscorlib/src/System/Diagnostics/Debugger.cs b/src/mscorlib/src/System/Diagnostics/Debugger.cs
index 339c89eecf..8ebbc0a354 100644
--- a/src/mscorlib/src/System/Diagnostics/Debugger.cs
+++ b/src/mscorlib/src/System/Diagnostics/Debugger.cs
@@ -32,7 +32,6 @@ namespace System.Diagnostics
// Break causes a breakpoint to be signalled to an attached debugger. If no debugger
// is attached, the user is asked if he wants to attach a debugger. If yes, then the
// debugger is launched.
- [System.Security.SecuritySafeCritical] // auto-generated
public static void Break()
{
if (!Debugger.IsAttached)
@@ -61,7 +60,6 @@ namespace System.Diagnostics
BreakInternal();
}
- [System.Security.SecuritySafeCritical] // auto-generated
static void BreakCanThrow()
{
if (!Debugger.IsAttached)
@@ -75,14 +73,12 @@ namespace System.Diagnostics
BreakInternal();
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void BreakInternal();
// Launch launches & attaches a debugger to the process. If a debugger is already attached,
// nothing happens.
//
- [System.Security.SecuritySafeCritical] // auto-generated
public static bool Launch()
{
if (Debugger.IsAttached)
@@ -147,7 +143,6 @@ namespace System.Diagnostics
}
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool LaunchInternal();
@@ -155,7 +150,6 @@ namespace System.Diagnostics
//
public static extern bool IsAttached
{
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
}
@@ -173,20 +167,17 @@ namespace System.Diagnostics
// Posts a message for the attached debugger. If there is no
// debugger attached, has no effect. The debugger may or may not
// report the message depending on its settings.
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void Log(int level, String category, String message);
// Checks to see if an attached debugger has logging enabled
//
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern bool IsLogging();
// Posts a custom notification for the attached debugger. If there is no
// debugger attached, has no effect. The debugger may or may not
// report the notification depending on its settings.
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void CustomNotification(ICustomDebuggerNotification data);
diff --git a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
index 6adcf34eda..e75b653a0b 100644
--- a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
+++ b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
@@ -142,7 +142,7 @@ namespace System.Diagnostics {
public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
{
if( state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
- throw new ArgumentOutOfRangeException("state");
+ throw new ArgumentOutOfRangeException(nameof(state));
Contract.EndContractBlock();
this.state = state;
@@ -166,7 +166,7 @@ namespace System.Diagnostics {
public DebuggerTypeProxyAttribute(Type type)
{
if (type == null) {
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
}
Contract.EndContractBlock();
@@ -186,7 +186,7 @@ namespace System.Diagnostics {
{
set {
if( value == null) {
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
}
Contract.EndContractBlock();
@@ -257,7 +257,7 @@ namespace System.Diagnostics {
{
set {
if( value == null) {
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
}
Contract.EndContractBlock();
@@ -302,7 +302,7 @@ namespace System.Diagnostics {
public DebuggerVisualizerAttribute(string visualizerTypeName, Type visualizerObjectSource)
{
if (visualizerObjectSource == null) {
- throw new ArgumentNullException("visualizerObjectSource");
+ throw new ArgumentNullException(nameof(visualizerObjectSource));
}
Contract.EndContractBlock();
this.visualizerName = visualizerTypeName;
@@ -311,7 +311,7 @@ namespace System.Diagnostics {
public DebuggerVisualizerAttribute(Type visualizer)
{
if (visualizer == null) {
- throw new ArgumentNullException("visualizer");
+ throw new ArgumentNullException(nameof(visualizer));
}
Contract.EndContractBlock();
this.visualizerName = visualizer.AssemblyQualifiedName;
@@ -319,10 +319,10 @@ namespace System.Diagnostics {
public DebuggerVisualizerAttribute(Type visualizer, Type visualizerObjectSource)
{
if (visualizer == null) {
- throw new ArgumentNullException("visualizer");
+ throw new ArgumentNullException(nameof(visualizer));
}
if (visualizerObjectSource == null) {
- throw new ArgumentNullException("visualizerObjectSource");
+ throw new ArgumentNullException(nameof(visualizerObjectSource));
}
Contract.EndContractBlock();
this.visualizerName = visualizer.AssemblyQualifiedName;
@@ -331,7 +331,7 @@ namespace System.Diagnostics {
public DebuggerVisualizerAttribute(Type visualizer, string visualizerObjectSourceTypeName)
{
if (visualizer == null) {
- throw new ArgumentNullException("visualizer");
+ throw new ArgumentNullException(nameof(visualizer));
}
Contract.EndContractBlock();
this.visualizerName = visualizer.AssemblyQualifiedName;
@@ -356,7 +356,7 @@ namespace System.Diagnostics {
{
set {
if( value == null) {
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
}
Contract.EndContractBlock();
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs b/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs
index a7124a26ff..1a1f5fa2c0 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs
@@ -72,7 +72,7 @@ namespace System.Diagnostics.Tracing
}
- Contract.Assert((options & EventActivityOptions.Disable) == 0);
+ Debug.Assert((options & EventActivityOptions.Disable) == 0);
var currentActivity = m_current.Value;
var fullActivityName = NormalizeActivityName(providerName, activityName, task);
@@ -191,7 +191,7 @@ namespace System.Diagnostics.Tracing
else
{
orphan.m_stopped = 1;
- Contract.Assert(orphan.m_stopped != 0);
+ Debug.Assert(orphan.m_stopped != 0);
}
orphan = orphan.m_creator;
}
@@ -221,7 +221,6 @@ namespace System.Diagnostics.Tracing
/// <summary>
/// Turns on activity tracking. It is sticky, once on it stays on (race issues otherwise)
/// </summary>
- [System.Security.SecuritySafeCritical]
public void Enable()
{
if (m_current == null)
@@ -366,7 +365,6 @@ namespace System.Diagnostics.Tracing
/// byte (since the top nibble can't be zero you can determine if this is true by seeing if
/// this byte is nonZero. This offset is needed to efficiently create the ID for child activities.
/// </summary>
- [System.Security.SecuritySafeCritical]
private unsafe void CreateActivityPathGuid(out Guid idRet, out int activityPathGuidOffset)
{
fixed (Guid* outPtr = &idRet)
@@ -403,7 +401,6 @@ namespace System.Diagnostics.Tracing
/// sufficient space for this ID. By doing this, we preserve the fact that this activity
/// is a child (of unknown depth) from that ancestor.
/// </summary>
- [System.Security.SecurityCritical]
private unsafe void CreateOverflowGuid(Guid* outPtr)
{
// Search backwards for an ancestor that has sufficient space to put the ID.
@@ -452,7 +449,6 @@ namespace System.Diagnostics.Tracing
/// is the maximum number of bytes that fit in a GUID) if the path did not fit.
/// If 'overflow' is true, then the number is encoded as an 'overflow number (which has a
/// special (longer prefix) that indicates that this ID is allocated differently
- [System.Security.SecurityCritical]
private static unsafe int AddIdToGuid(Guid* outPtr, int whereToAddId, uint id, bool overflow = false)
{
byte* ptr = (byte*)outPtr;
@@ -526,11 +522,10 @@ namespace System.Diagnostics.Tracing
/// Thus if it is non-zero it adds to the current byte, otherwise it advances and writes
/// the new byte (in the high bits) of the next byte.
/// </summary>
- [System.Security.SecurityCritical]
private static unsafe void WriteNibble(ref byte* ptr, byte* endPtr, uint value)
{
- Contract.Assert(0 <= value && value < 16);
- Contract.Assert(ptr < endPtr);
+ Debug.Assert(0 <= value && value < 16);
+ Debug.Assert(ptr < endPtr);
if (*ptr != 0)
*ptr++ |= (byte)value;
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs
index 6ea8d98d92..ce0fcb6acb 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs
@@ -74,7 +74,6 @@ namespace System.Diagnostics.Tracing
private static bool m_setInformationMissing;
- [SecurityCritical]
UnsafeNativeMethods.ManifestEtw.EtwEnableCallback m_etwCallback; // Trace Callback function
private long m_regHandle; // Trace Registration Handle
private byte m_level; // Tracing Level
@@ -128,7 +127,6 @@ namespace System.Diagnostics.Tracing
// <SatisfiesLinkDemand Name="Win32Exception..ctor(System.Int32)" />
// <ReferencesCritical Name="Method: EtwEnableCallBack(Guid&, Int32, Byte, Int64, Int64, Void*, Void*):Void" Ring="1" />
// </SecurityKernel>
- [System.Security.SecurityCritical]
internal unsafe void Register(Guid providerGuid)
{
m_providerId = providerGuid;
@@ -157,7 +155,6 @@ namespace System.Diagnostics.Tracing
// <SecurityKernel Critical="True" TreatAsSafe="Does not expose critical resource" Ring="1">
// <ReferencesCritical Name="Method: Deregister():Void" Ring="1" />
// </SecurityKernel>
- [System.Security.SecuritySafeCritical]
protected virtual void Dispose(bool disposing)
{
//
@@ -175,16 +172,31 @@ namespace System.Diagnostics.Tracing
// Disable the provider.
m_enabled = false;
- // Do most of the work under a lock to avoid shutdown race.
+ // Do most of the work under a lock to avoid shutdown race.
+
+ long registrationHandle = 0;
lock (EventListener.EventListenersLock)
{
// Double check
if (m_disposed)
return;
- Deregister();
+ registrationHandle = m_regHandle;
+ m_regHandle = 0;
m_disposed = true;
}
+
+ // We do the Unregistration outside the EventListenerLock because there is a lock
+ // inside the ETW routines. This lock is taken before ETW issues commands
+ // Thus the ETW lock gets taken first and then our EventListenersLock gets taken
+ // in SendCommand(), and also here. If we called EventUnregister after taking
+ // the EventListenersLock then the take-lock order is reversed and we can have
+ // deadlocks in race conditions (dispose racing with an ETW command).
+ //
+ // We solve by Unregistering after releasing the EventListenerLock.
+ if (registrationHandle != 0)
+ EventUnregister(registrationHandle);
+
}
/// <summary>
@@ -201,33 +213,10 @@ namespace System.Diagnostics.Tracing
Dispose(false);
}
- /// <summary>
- /// This method un-registers from ETW.
- /// </summary>
- // <SecurityKernel Critical="True" Ring="0">
- // <CallsSuppressUnmanagedCode Name="UnsafeNativeMethods.ManifestEtw.EventUnregister(System.Int64):System.Int32" />
- // </SecurityKernel>
- // TODO Check return code from UnsafeNativeMethods.ManifestEtw.EventUnregister
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.Win32.UnsafeNativeMethods.ManifestEtw.EventUnregister(System.Int64)"), System.Security.SecurityCritical]
- private unsafe void Deregister()
- {
- //
- // Unregister from ETW using the RegHandle saved from
- // the register call.
- //
-
- if (m_regHandle != 0)
- {
- EventUnregister();
- m_regHandle = 0;
- }
- }
-
// <SecurityKernel Critical="True" Ring="0">
// <UsesUnsafeCode Name="Parameter filterData of type: Void*" />
// <UsesUnsafeCode Name="Parameter callbackContext of type: Void*" />
// </SecurityKernel>
- [System.Security.SecurityCritical]
unsafe void EtwEnableCallBack(
[In] ref System.Guid sourceId,
[In] int controlCode,
@@ -348,7 +337,6 @@ namespace System.Diagnostics.Tracing
/// ETW session that was added or remove, and the bool specifies whether the
/// session was added or whether it was removed from the set.
/// </summary>
- [System.Security.SecuritySafeCritical]
private List<Tuple<SessionInfo, bool>> GetSessions()
{
List<SessionInfo> liveSessionList = null;
@@ -424,7 +412,6 @@ namespace System.Diagnostics.Tracing
/// for the current process ID, calling 'action' for each session, and passing it the
/// ETW session and the 'AllKeywords' the session enabled for the current provider.
/// </summary>
- [System.Security.SecurityCritical]
private unsafe void GetSessionInfo(Action<int, long> action)
{
// We wish the EventSource package to be legal for Windows Store applications.
@@ -470,7 +457,7 @@ namespace System.Diagnostics.Tracing
}
if (providerInstance->NextOffset == 0)
break;
- Contract.Assert(0 <= providerInstance->NextOffset && providerInstance->NextOffset < buffSize);
+ Debug.Assert(0 <= providerInstance->NextOffset && providerInstance->NextOffset < buffSize);
var structBase = (byte*)providerInstance;
providerInstance = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO*)&structBase[providerInstance->NextOffset];
}
@@ -552,7 +539,6 @@ namespace System.Diagnostics.Tracing
/// returns an array of bytes representing the data, the index into that byte array where the data
/// starts, and the command being issued associated with that data.
/// </summary>
- [System.Security.SecurityCritical]
private unsafe bool GetDataFromController(int etwSessionId,
UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR* filterData, out ControllerCommand command, out byte[] data, out int dataStart)
{
@@ -685,7 +671,6 @@ namespace System.Diagnostics.Tracing
// <UsesUnsafeCode Name="Parameter dataDescriptor of type: EventData*" />
// <UsesUnsafeCode Name="Parameter dataBuffer of type: Byte*" />
// </SecurityKernel>
- [System.Security.SecurityCritical]
private static unsafe object EncodeObject(ref object data, ref EventData* dataDescriptor, ref byte* dataBuffer, ref uint totalEventSize)
/*++
@@ -934,7 +919,6 @@ namespace System.Diagnostics.Tracing
// </SecurityKernel>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Performance-critical code")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")]
- [System.Security.SecurityCritical]
internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, Guid* activityID, Guid* childActivityID, params object[] eventPayload)
{
int status = 0;
@@ -1131,13 +1115,12 @@ namespace System.Diagnostics.Tracing
// <CallsSuppressUnmanagedCode Name="UnsafeNativeMethods.ManifestEtw.EventWrite(System.Int64,EventDescriptor&,System.UInt32,System.Void*):System.UInt32" />
// </SecurityKernel>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")]
- [System.Security.SecurityCritical]
internal unsafe protected bool WriteEvent(ref EventDescriptor eventDescriptor, Guid* activityID, Guid* childActivityID, int dataCount, IntPtr data)
{
if (childActivityID != null)
{
// activity transfers are supported only for events that specify the Send or Receive opcode
- Contract.Assert((EventOpcode)eventDescriptor.Opcode == EventOpcode.Send ||
+ Debug.Assert((EventOpcode)eventDescriptor.Opcode == EventOpcode.Send ||
(EventOpcode)eventDescriptor.Opcode == EventOpcode.Receive ||
(EventOpcode)eventDescriptor.Opcode == EventOpcode.Start ||
(EventOpcode)eventDescriptor.Opcode == EventOpcode.Stop);
@@ -1154,7 +1137,6 @@ namespace System.Diagnostics.Tracing
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")]
- [System.Security.SecurityCritical]
internal unsafe bool WriteEventRaw(
ref EventDescriptor eventDescriptor,
Guid* activityID,
@@ -1183,7 +1165,6 @@ namespace System.Diagnostics.Tracing
// These are look-alikes to the Manifest based ETW OS APIs that have been shimmed to work
// either with Manifest ETW or Classic ETW (if Manifest based ETW is not available).
- [SecurityCritical]
private unsafe uint EventRegister(ref Guid providerId, UnsafeNativeMethods.ManifestEtw.EtwEnableCallback enableCallback)
{
m_providerId = providerId;
@@ -1191,12 +1172,9 @@ namespace System.Diagnostics.Tracing
return UnsafeNativeMethods.ManifestEtw.EventRegister(ref providerId, enableCallback, null, ref m_regHandle);
}
- [SecurityCritical]
- private uint EventUnregister()
+ private uint EventUnregister(long registrationHandle)
{
- uint status = UnsafeNativeMethods.ManifestEtw.EventUnregister(m_regHandle);
- m_regHandle = 0;
- return status;
+ return UnsafeNativeMethods.ManifestEtw.EventUnregister(registrationHandle);
}
static int[] nibblebits = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
@@ -1209,7 +1187,7 @@ namespace System.Diagnostics.Tracing
}
private static int bitindex(uint n)
{
- Contract.Assert(bitcount(n) == 1);
+ Debug.Assert(bitcount(n) == 1);
int idx = 0;
while ((n & (1 << idx)) == 0)
idx++;
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs
index 8c2edfdec2..aa0d8d72d1 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs
@@ -529,7 +529,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
internal static Guid InternalCurrentThreadActivityId
{
- [System.Security.SecurityCritical]
get
{
Guid retval = CurrentThreadActivityId;
@@ -543,12 +542,11 @@ namespace System.Diagnostics.Tracing
internal static Guid FallbackActivityId
{
- [System.Security.SecurityCritical]
get
{
#pragma warning disable 612, 618
int threadID = AppDomain.GetCurrentThreadId();
-
+
// Managed thread IDs are more aggressively re-used than native thread IDs,
// so we'll use the latter...
return new Guid(unchecked((uint)threadID),
@@ -608,7 +606,7 @@ namespace System.Diagnostics.Tracing
add
{
m_eventCommandExecuted += value;
-
+
// If we have an EventHandler<EventCommandEventArgs> attached to the EventSource before the first command arrives
// It should get a chance to handle the deferred commands.
EventCommandEventArgs deferredCommands = m_deferredCommands;
@@ -706,7 +704,7 @@ namespace System.Diagnostics.Tracing
return;
}
-
+
/// <summary>
/// This method is called when the eventSource is updated by the controller.
/// </summary>
@@ -714,7 +712,6 @@ namespace System.Diagnostics.Tracing
#pragma warning disable 1591
// optimized for common signatures (no args)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId)
{
@@ -722,7 +719,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (ints)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, int arg1)
{
@@ -735,7 +731,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, int arg1, int arg2)
{
@@ -750,7 +745,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3)
{
@@ -768,7 +762,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (longs)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, long arg1)
{
@@ -781,7 +774,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, long arg1, long arg2)
{
@@ -796,7 +788,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, long arg1, long arg2, long arg3)
{
@@ -814,7 +805,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (strings)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, string arg1)
{
@@ -831,7 +821,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, string arg1, string arg2)
{
@@ -852,7 +841,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, string arg1, string arg2, string arg3)
{
@@ -878,7 +866,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (string and ints)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, string arg1, int arg2)
{
@@ -897,7 +884,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3)
{
@@ -919,7 +905,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (string and longs)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, string arg1, long arg2)
{
@@ -939,7 +924,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (long and string)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, long arg1, string arg2)
{
@@ -959,7 +943,6 @@ namespace System.Diagnostics.Tracing
}
// optimized for common signatures (int and string)
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, int arg1, string arg2)
{
@@ -977,70 +960,68 @@ namespace System.Diagnostics.Tracing
}
}
}
-
- [SecuritySafeCritical]
- [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
- protected unsafe void WriteEvent(int eventId, byte[] arg1)
- {
- if (m_eventSourceEnabled)
- {
- EventSource.EventData* descrs = stackalloc EventSource.EventData[2];
- if (arg1 == null || arg1.Length == 0)
- {
- int blobSize = 0;
- descrs[0].DataPointer = (IntPtr)(&blobSize);
- descrs[0].Size = 4;
- descrs[1].DataPointer = (IntPtr)(&blobSize); // valid address instead of empty content
- descrs[1].Size = 0;
- WriteEventCore(eventId, 2, descrs);
- }
- else
- {
- int blobSize = arg1.Length;
- fixed (byte* blob = &arg1[0])
- {
- descrs[0].DataPointer = (IntPtr)(&blobSize);
- descrs[0].Size = 4;
- descrs[1].DataPointer = (IntPtr)blob;
- descrs[1].Size = blobSize;
- WriteEventCore(eventId, 2, descrs);
- }
- }
- }
- }
-
- [SecuritySafeCritical]
- [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
- protected unsafe void WriteEvent(int eventId, long arg1, byte[] arg2)
- {
- if (m_eventSourceEnabled)
- {
- EventSource.EventData* descrs = stackalloc EventSource.EventData[3];
- descrs[0].DataPointer = (IntPtr)(&arg1);
- descrs[0].Size = 8;
- if (arg2 == null || arg2.Length == 0)
- {
- int blobSize = 0;
- descrs[1].DataPointer = (IntPtr)(&blobSize);
- descrs[1].Size = 4;
- descrs[2].DataPointer = (IntPtr)(&blobSize); // valid address instead of empty contents
- descrs[2].Size = 0;
- WriteEventCore(eventId, 3, descrs);
- }
- else
- {
- int blobSize = arg2.Length;
- fixed (byte* blob = &arg2[0])
- {
- descrs[1].DataPointer = (IntPtr)(&blobSize);
- descrs[1].Size = 4;
- descrs[2].DataPointer = (IntPtr)blob;
- descrs[2].Size = blobSize;
- WriteEventCore(eventId, 3, descrs);
- }
- }
- }
- }
+
+ [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
+ protected unsafe void WriteEvent(int eventId, byte[] arg1)
+ {
+ if (m_eventSourceEnabled)
+ {
+ EventSource.EventData* descrs = stackalloc EventSource.EventData[2];
+ if (arg1 == null || arg1.Length == 0)
+ {
+ int blobSize = 0;
+ descrs[0].DataPointer = (IntPtr)(&blobSize);
+ descrs[0].Size = 4;
+ descrs[1].DataPointer = (IntPtr)(&blobSize); // valid address instead of empty content
+ descrs[1].Size = 0;
+ WriteEventCore(eventId, 2, descrs);
+ }
+ else
+ {
+ int blobSize = arg1.Length;
+ fixed (byte* blob = &arg1[0])
+ {
+ descrs[0].DataPointer = (IntPtr)(&blobSize);
+ descrs[0].Size = 4;
+ descrs[1].DataPointer = (IntPtr)blob;
+ descrs[1].Size = blobSize;
+ WriteEventCore(eventId, 2, descrs);
+ }
+ }
+ }
+ }
+
+ [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
+ protected unsafe void WriteEvent(int eventId, long arg1, byte[] arg2)
+ {
+ if (m_eventSourceEnabled)
+ {
+ EventSource.EventData* descrs = stackalloc EventSource.EventData[3];
+ descrs[0].DataPointer = (IntPtr)(&arg1);
+ descrs[0].Size = 8;
+ if (arg2 == null || arg2.Length == 0)
+ {
+ int blobSize = 0;
+ descrs[1].DataPointer = (IntPtr)(&blobSize);
+ descrs[1].Size = 4;
+ descrs[2].DataPointer = (IntPtr)(&blobSize); // valid address instead of empty contents
+ descrs[2].Size = 0;
+ WriteEventCore(eventId, 3, descrs);
+ }
+ else
+ {
+ int blobSize = arg2.Length;
+ fixed (byte* blob = &arg2[0])
+ {
+ descrs[1].DataPointer = (IntPtr)(&blobSize);
+ descrs[1].Size = 4;
+ descrs[2].DataPointer = (IntPtr)blob;
+ descrs[2].Size = blobSize;
+ WriteEventCore(eventId, 3, descrs);
+ }
+ }
+ }
+ }
#pragma warning restore 1591
@@ -1067,7 +1048,6 @@ namespace System.Diagnostics.Tracing
/// <param name="pointer">Pinned tracelogging-compatible metadata blob.</param>
/// <param name="size">The size of the metadata blob.</param>
/// <param name="reserved">Value for reserved: 2 for per-provider metadata, 1 for per-event metadata</param>
- [SecurityCritical]
internal unsafe void SetMetadata(byte* pointer, int size, int reserved)
{
this.m_Ptr = (long)(ulong)(UIntPtr)pointer;
@@ -1109,7 +1089,6 @@ namespace System.Diagnostics.Tracing
/// }
/// </code>
/// </remarks>
- [SecurityCritical]
[CLSCompliant(false)]
protected unsafe void WriteEventCore(int eventId, int eventDataCount, EventSource.EventData* data)
{
@@ -1141,7 +1120,6 @@ namespace System.Diagnostics.Tracing
/// }
/// </code>
/// </remarks>
- [SecurityCritical]
[CLSCompliant(false)]
protected unsafe void WriteEventWithRelatedActivityIdCore(int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
{
@@ -1149,36 +1127,37 @@ namespace System.Diagnostics.Tracing
{
try
{
- Contract.Assert(m_eventData != null); // You must have initialized this if you enabled the source.
+ Debug.Assert(m_eventData != null); // You must have initialized this if you enabled the source.
if (relatedActivityId != null)
ValidateEventOpcodeForTransfer(ref m_eventData[eventId], m_eventData[eventId].Name);
-#if FEATURE_MANAGED_ETW
- if (m_eventData[eventId].EnabledForETW)
+ EventOpcode opcode = (EventOpcode)m_eventData[eventId].Descriptor.Opcode;
+ EventActivityOptions activityOptions = m_eventData[eventId].ActivityOptions;
+ Guid* pActivityId = null;
+ Guid activityId = Guid.Empty;
+ Guid relActivityId = Guid.Empty;
+
+ if (opcode != EventOpcode.Info && relatedActivityId == null &&
+ ((activityOptions & EventActivityOptions.Disable) == 0))
{
- EventOpcode opcode = (EventOpcode)m_eventData[eventId].Descriptor.Opcode;
- EventActivityOptions activityOptions = m_eventData[eventId].ActivityOptions;
- Guid* pActivityId = null;
- Guid activityId = Guid.Empty;
- Guid relActivityId = Guid.Empty;
-
- if (opcode != EventOpcode.Info && relatedActivityId == null &&
- ((activityOptions & EventActivityOptions.Disable) == 0))
+ if (opcode == EventOpcode.Start)
{
- if (opcode == EventOpcode.Start)
- {
- m_activityTracker.OnStart(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId, ref relActivityId, m_eventData[eventId].ActivityOptions);
- }
- else if (opcode == EventOpcode.Stop)
- {
- m_activityTracker.OnStop(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId);
- }
-
- if (activityId != Guid.Empty)
- pActivityId = &activityId;
- if (relActivityId != Guid.Empty)
- relatedActivityId = &relActivityId;
+ m_activityTracker.OnStart(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId, ref relActivityId, m_eventData[eventId].ActivityOptions);
}
+ else if (opcode == EventOpcode.Stop)
+ {
+ m_activityTracker.OnStop(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId);
+ }
+
+ if (activityId != Guid.Empty)
+ pActivityId = &activityId;
+ if (relActivityId != Guid.Empty)
+ relatedActivityId = &relActivityId;
+ }
+
+#if FEATURE_MANAGED_ETW
+ if (m_eventData[eventId].EnabledForETW)
+ {
#if FEATURE_ACTIVITYSAMPLING
// this code should be kept in sync with WriteEventVarargs().
@@ -1298,7 +1277,6 @@ namespace System.Diagnostics.Tracing
/// method signature. Even if you use this for rare events, this call should be guarded by an <see cref="IsEnabled()"/>
/// check so that the varargs call is not made when the EventSource is not active.
/// </summary>
- [SecuritySafeCritical]
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
protected unsafe void WriteEvent(int eventId, params object[] args)
{
@@ -1313,7 +1291,6 @@ namespace System.Diagnostics.Tracing
/// particular method signature. Even if you use this for rare events, this call should be guarded by an <see cref="IsEnabled()"/>
/// check so that the varargs call is not made when the EventSource is not active.
/// </summary>
- [SecuritySafeCritical]
protected unsafe void WriteEventWithRelatedActivityId(int eventId, Guid relatedActivityId, params object[] args)
{
WriteEventVarargs(eventId, &relatedActivityId, args);
@@ -1380,7 +1357,7 @@ namespace System.Diagnostics.Tracing
#if FEATURE_ACTIVITYSAMPLING
internal void WriteStringToListener(EventListener listener, string msg, SessionMask m)
{
- Contract.Assert(listener == null || (uint)m == (uint)SessionMask.FromId(0));
+ Debug.Assert(listener == null || (uint)m == (uint)SessionMask.FromId(0));
if (m_eventSourceEnabled)
{
@@ -1390,18 +1367,18 @@ namespace System.Diagnostics.Tracing
}
else
{
- List<object> arg = new List<object>();
- arg.Add(msg);
EventWrittenEventArgs eventCallbackArgs = new EventWrittenEventArgs(this);
eventCallbackArgs.EventId = 0;
- eventCallbackArgs.Payload = new ReadOnlyCollection<object>(arg);
+ eventCallbackArgs.Message = msg;
+ eventCallbackArgs.Payload = new ReadOnlyCollection<object>(new List<object>() { msg });
+ eventCallbackArgs.PayloadNames = new ReadOnlyCollection<string>(new List<string> { "message" });
+ eventCallbackArgs.EventName = "EventSourceMessage";
listener.OnEventWritten(eventCallbackArgs);
}
}
}
#endif
- [SecurityCritical]
private unsafe void WriteEventRaw(
string eventName,
ref EventDescriptor eventDescriptor,
@@ -1443,7 +1420,6 @@ namespace System.Diagnostics.Tracing
/// member, and any future access to the "Log" would throw the cached exception).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "guid")]
- [SecuritySafeCritical]
private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, string[] traits)
{
try
@@ -1500,7 +1476,7 @@ namespace System.Diagnostics.Tracing
#endif
{
int setInformationResult;
- System.Runtime.InteropServices.GCHandle metadataHandle =
+ System.Runtime.InteropServices.GCHandle metadataHandle =
System.Runtime.InteropServices.GCHandle.Alloc(this.providerMetadata, System.Runtime.InteropServices.GCHandleType.Pinned);
IntPtr providerMetadata = metadataHandle.AddrOfPinnedObject();
@@ -1513,7 +1489,7 @@ namespace System.Diagnostics.Tracing
}
#endif // FEATURE_MANAGED_ETW
- Contract.Assert(!m_eventSourceEnabled); // We can't be enabled until we are completely initted.
+ Debug.Assert(!m_eventSourceEnabled); // We can't be enabled until we are completely initted.
// We are logically completely initialized at this point.
m_completelyInited = true;
}
@@ -1742,7 +1718,6 @@ namespace System.Diagnostics.Tracing
return new Guid(bytes);
}
- [SecurityCritical]
private unsafe object DecodeObject(int eventId, int parameterId, ref EventSource.EventData* data)
{
// TODO FIX : We use reflection which in turn uses EventSource, right now we carefully avoid
@@ -1754,7 +1729,7 @@ namespace System.Diagnostics.Tracing
Type dataType = GetDataType(m_eventData[eventId], parameterId);
- Again:
+ Again:
if (dataType == typeof(IntPtr))
{
return *((IntPtr*)dataPointer);
@@ -1889,14 +1864,13 @@ namespace System.Diagnostics.Tracing
return dispatcher;
}
- [SecurityCritical]
private unsafe void WriteEventVarargs(int eventId, Guid* childActivityID, object[] args)
{
if (m_eventSourceEnabled)
{
try
{
- Contract.Assert(m_eventData != null); // You must have initialized this if you enabled the source.
+ Debug.Assert(m_eventData != null); // You must have initialized this if you enabled the source.
if (childActivityID != null)
{
ValidateEventOpcodeForTransfer(ref m_eventData[eventId], m_eventData[eventId].Name);
@@ -1916,33 +1890,34 @@ namespace System.Diagnostics.Tracing
}
LogEventArgsMismatches(m_eventData[eventId].Parameters, args);
-#if FEATURE_MANAGED_ETW
- if (m_eventData[eventId].EnabledForETW)
+
+ Guid* pActivityId = null;
+ Guid activityId = Guid.Empty;
+ Guid relatedActivityId = Guid.Empty;
+ EventOpcode opcode = (EventOpcode)m_eventData[eventId].Descriptor.Opcode;
+ EventActivityOptions activityOptions = m_eventData[eventId].ActivityOptions;
+
+ if (childActivityID == null &&
+ ((activityOptions & EventActivityOptions.Disable) == 0))
{
- Guid* pActivityId = null;
- Guid activityId = Guid.Empty;
- Guid relatedActivityId = Guid.Empty;
- EventOpcode opcode = (EventOpcode)m_eventData[eventId].Descriptor.Opcode;
- EventActivityOptions activityOptions = m_eventData[eventId].ActivityOptions;
-
- if (childActivityID == null &&
- ((activityOptions & EventActivityOptions.Disable) == 0))
+ if (opcode == EventOpcode.Start)
{
- if (opcode == EventOpcode.Start)
- {
- m_activityTracker.OnStart(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId, ref relatedActivityId, m_eventData[eventId].ActivityOptions);
- }
- else if (opcode == EventOpcode.Stop)
- {
- m_activityTracker.OnStop(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId);
- }
-
- if (activityId != Guid.Empty)
- pActivityId = &activityId;
- if (relatedActivityId != Guid.Empty)
- childActivityID = &relatedActivityId;
+ m_activityTracker.OnStart(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId, ref relatedActivityId, m_eventData[eventId].ActivityOptions);
+ }
+ else if (opcode == EventOpcode.Stop)
+ {
+ m_activityTracker.OnStop(m_name, m_eventData[eventId].Name, m_eventData[eventId].Descriptor.Task, ref activityId);
}
+ if (activityId != Guid.Empty)
+ pActivityId = &activityId;
+ if (relatedActivityId != Guid.Empty)
+ childActivityID = &relatedActivityId;
+ }
+
+#if FEATURE_MANAGED_ETW
+ if (m_eventData[eventId].EnabledForETW)
+ {
#if FEATURE_ACTIVITYSAMPLING
// this code should be kept in sync with WriteEventWithRelatedActivityIdCore().
SessionMask etwSessions = SessionMask.All;
@@ -2059,7 +2034,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecurityCritical]
unsafe private object[] SerializeEventArgs(int eventId, object[] args)
{
TraceLoggingEventTypes eventTypes = m_eventData[eventId].TraceLoggingEventTypes;
@@ -2120,9 +2094,9 @@ namespace System.Diagnostics.Tracing
private int GetParamLenghtIncludingByteArray(ParameterInfo[] parameters)
{
int sum = 0;
- foreach(ParameterInfo info in parameters)
+ foreach (ParameterInfo info in parameters)
{
- if(info.ParameterType == typeof(byte[]))
+ if (info.ParameterType == typeof(byte[]))
{
sum += 2;
}
@@ -2135,7 +2109,6 @@ namespace System.Diagnostics.Tracing
return sum;
}
- [SecurityCritical]
unsafe private void WriteToAllListeners(int eventId, Guid* childActivityID, int eventDataCount, EventSource.EventData* data)
{
// We represent a byte[] as a integer denoting the length and then a blob of bytes in the data pointer. This causes a spurious
@@ -2159,7 +2132,6 @@ namespace System.Diagnostics.Tracing
}
// helper for writing to all EventListeners attached the current eventSource.
- [SecurityCritical]
unsafe private void WriteToAllListeners(int eventId, Guid* childActivityID, params object[] args)
{
EventWrittenEventArgs eventCallbackArgs = new EventWrittenEventArgs(this);
@@ -2173,13 +2145,12 @@ namespace System.Diagnostics.Tracing
DispatchToAllListeners(eventId, childActivityID, eventCallbackArgs);
}
- [SecurityCritical]
private unsafe void DispatchToAllListeners(int eventId, Guid* childActivityID, EventWrittenEventArgs eventCallbackArgs)
{
Exception lastThrownException = null;
for (EventDispatcher dispatcher = m_Dispatchers; dispatcher != null; dispatcher = dispatcher.m_Next)
{
- Contract.Assert(dispatcher.m_EventEnabled != null);
+ Debug.Assert(dispatcher.m_EventEnabled != null);
if (eventId == -1 || dispatcher.m_EventEnabled[eventId])
{
#if FEATURE_ACTIVITYSAMPLING
@@ -2214,8 +2185,7 @@ namespace System.Diagnostics.Tracing
throw new EventSourceException(lastThrownException);
}
}
-
- [SecuritySafeCritical]
+
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")]
private unsafe void WriteEventString(EventLevel level, long keywords, string msgString)
{
@@ -2310,7 +2280,6 @@ namespace System.Diagnostics.Tracing
}
#if FEATURE_ACTIVITYSAMPLING
- [SecurityCritical]
unsafe private SessionMask GetEtwSessionMask(int eventId, Guid* childActivityID)
{
SessionMask etwSessions = new SessionMask();
@@ -2429,9 +2398,9 @@ namespace System.Diagnostics.Tracing
try
{
m_EventSourceExceptionRecurenceCount++;
-
+
string errorPrefix = "EventSourceException";
- if(eventName != null)
+ if (eventName != null)
{
errorPrefix += " while processing event \"" + eventName + "\"";
}
@@ -2473,7 +2442,7 @@ namespace System.Diagnostics.Tracing
private void ValidateEventOpcodeForTransfer(ref EventMetadata eventData, string eventName)
{
if ((EventOpcode)eventData.Descriptor.Opcode != EventOpcode.Send &&
- (EventOpcode)eventData.Descriptor.Opcode != EventOpcode.Receive &&
+ (EventOpcode)eventData.Descriptor.Opcode != EventOpcode.Receive &&
(EventOpcode)eventData.Descriptor.Opcode != EventOpcode.Start)
{
ThrowEventSourceException(eventName);
@@ -2545,7 +2514,7 @@ namespace System.Diagnostics.Tracing
public TraceLoggingEventTypes TraceLoggingEventTypes;
public EventActivityOptions ActivityOptions;
-
+
#if PROJECTN
public EventParameterType[] ParameterTypes;
#endif
@@ -2611,7 +2580,7 @@ namespace System.Diagnostics.Tracing
{
// PRECONDITION: We should be holding the EventListener.EventListenersLock
// We defer commands until we are completely inited. This allows error messages to be sent.
- Contract.Assert(m_completelyInited);
+ Debug.Assert(m_completelyInited);
#if FEATURE_MANAGED_ETW
if (m_provider == null) // If we failed to construct
@@ -2623,7 +2592,7 @@ namespace System.Diagnostics.Tracing
try
{
EnsureDescriptorsInitialized();
- Contract.Assert(m_eventData != null);
+ Debug.Assert(m_eventData != null);
// Find the per-EventSource dispatcher corresponding to registered dispatcher
commandArgs.dispatcher = GetDispatcher(commandArgs.listener);
@@ -2682,7 +2651,7 @@ namespace System.Diagnostics.Tracing
// hasn't changed.
// sesisonId = SessionMask.MAX when one of the legacy ETW sessions changed
// 0 <= perEventSourceSessionId < SessionMask.MAX for activity-tracing aware sessions
- Contract.Assert(commandArgs.perEventSourceSessionId >= -1 && commandArgs.perEventSourceSessionId <= SessionMask.MAX);
+ Debug.Assert(commandArgs.perEventSourceSessionId >= -1 && commandArgs.perEventSourceSessionId <= SessionMask.MAX);
// Send the manifest if we are enabling an ETW session
if (bSessionEnable && commandArgs.dispatcher == null)
@@ -2737,7 +2706,7 @@ namespace System.Diagnostics.Tracing
// things like log messages, or test if keywords are enabled in the callback.
if (commandArgs.enable)
{
- Contract.Assert(m_eventData != null);
+ Debug.Assert(m_eventData != null);
m_eventSourceEnabled = true;
}
@@ -2825,9 +2794,9 @@ namespace System.Diagnostics.Tracing
}
// These are not used for non-update commands and thus should always be 'default' values
- // Contract.Assert(enable == true);
- // Contract.Assert(level == EventLevel.LogAlways);
- // Contract.Assert(matchAnyKeyword == EventKeywords.None);
+ // Debug.Assert(enable == true);
+ // Debug.Assert(level == EventLevel.LogAlways);
+ // Debug.Assert(matchAnyKeyword == EventKeywords.None);
this.OnEventCommand(commandArgs);
var eventCommandCallback = m_eventCommandExecuted;
@@ -3017,16 +2986,15 @@ namespace System.Diagnostics.Tracing
return false;
}
- private bool IsDisposed
+ private bool IsDisposed
{
get { return m_eventSourceDisposed; }
}
- [SecuritySafeCritical]
private void EnsureDescriptorsInitialized()
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
+ Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
#endif
if (m_eventData == null)
{
@@ -3042,9 +3010,9 @@ namespace System.Diagnostics.Tracing
if (eventSourceGuid.Equals(Guid.Empty) || eventSourceName == null || eventData == null || manifest == null)
{
// GetMetadata failed, so we have to set it via reflection.
- Contract.Assert(m_rawManifest == null);
+ Debug.Assert(m_rawManifest == null);
m_rawManifest = CreateManifestAndDescriptors(this.GetType(), Name, this);
- Contract.Assert(m_eventData != null);
+ Debug.Assert(m_eventData != null);
}
else
@@ -3089,7 +3057,6 @@ namespace System.Diagnostics.Tracing
// Send out the ETW manifest XML out to ETW
// Today, we only send the manifest to ETW, custom listeners don't get it.
- [SecuritySafeCritical]
private unsafe bool SendManifest(byte[] rawManifest)
{
bool success = true;
@@ -3097,7 +3064,7 @@ namespace System.Diagnostics.Tracing
if (rawManifest == null)
return false;
- Contract.Assert(!SelfDescribingEvents);
+ Debug.Assert(!SelfDescribingEvents);
#if FEATURE_MANAGED_ETW
fixed (byte* dataPtr = rawManifest)
@@ -3124,7 +3091,7 @@ namespace System.Diagnostics.Tracing
dataDescrs[1].Reserved = 0;
int chunkSize = ManifestEnvelope.MaxChunkSize;
- TRY_AGAIN_WITH_SMALLER_CHUNK_SIZE:
+ TRY_AGAIN_WITH_SMALLER_CHUNK_SIZE:
envelope.TotalChunks = (ushort)((dataLeft + (chunkSize - 1)) / chunkSize);
while (dataLeft > 0)
{
@@ -3153,10 +3120,10 @@ namespace System.Diagnostics.Tracing
dataLeft -= chunkSize;
dataDescrs[1].Ptr += (uint)chunkSize;
envelope.ChunkNumber++;
-
+
// For large manifests we want to not overflow any receiver's buffer. Most manifests will fit within
// 5 chunks, so only the largest manifests will hit the pause.
- if((envelope.ChunkNumber % 5) == 0)
+ if ((envelope.ChunkNumber % 5) == 0)
Thread.Sleep(15);
}
}
@@ -3201,7 +3168,7 @@ namespace System.Diagnostics.Tracing
{
Attribute attr = null;
- Contract.Assert(data.ConstructorArguments.Count <= 1);
+ Debug.Assert(data.ConstructorArguments.Count <= 1);
if (data.ConstructorArguments.Count == 1)
{
@@ -3236,7 +3203,7 @@ namespace System.Diagnostics.Tracing
return null;
#else // ES_BUILD_PCL && PROJECTN
- throw new ArgumentException(Resources.GetResourceString("EventSource", "EventSource_PCLPlatformNotSupportedReflection"));
+ throw new ArgumentException(Resources.GetResourceString("EventSource", nameof(EventSource_PCLPlatformNotSupportedReflection)));
#endif
}
@@ -3256,8 +3223,8 @@ namespace System.Diagnostics.Tracing
attributeType == reflectedAttributeType ||
// are the full typenames equal?
string.Equals(attributeType.FullName, reflectedAttributeType.FullName, StringComparison.Ordinal) ||
- // are the typenames equal and the namespaces under "Diagnostics.Tracing" (typically
- // either Microsoft.Diagnostics.Tracing or System.Diagnostics.Tracing)?
+ // are the typenames equal and the namespaces under "Diagnostics.Tracing" (typically
+ // either Microsoft.Diagnostics.Tracing or System.Diagnostics.Tracing)?
string.Equals(attributeType.Name, reflectedAttributeType.Name, StringComparison.Ordinal) &&
attributeType.Namespace.EndsWith("Diagnostics.Tracing", StringComparison.Ordinal) &&
(reflectedAttributeType.Namespace.EndsWith("Diagnostics.Tracing", StringComparison.Ordinal)
@@ -3488,7 +3455,7 @@ namespace System.Diagnostics.Tracing
int startEventId = eventAttribute.EventId - 1;
if (eventData != null && startEventId < eventData.Length)
{
- Contract.Assert(0 <= startEventId); // Since we reserve id 0, we know that id-1 is <= 0
+ Debug.Assert(0 <= startEventId); // Since we reserve id 0, we know that id-1 is <= 0
EventMetadata startEventMetadata = eventData[startEventId];
// If you remove the Stop and add a Start does that name match the Start Event's Name?
@@ -3535,7 +3502,7 @@ namespace System.Diagnostics.Tracing
{
unchecked
{
- eventAttribute.Keywords |= (EventKeywords)manifest.GetChannelKeyword(eventAttribute.Channel, (ulong) eventAttribute.Keywords);
+ eventAttribute.Keywords |= (EventKeywords)manifest.GetChannelKeyword(eventAttribute.Channel, (ulong)eventAttribute.Keywords);
}
}
#endif
@@ -3658,7 +3625,7 @@ namespace System.Diagnostics.Tracing
}
#endif
return;
- Error:
+ Error:
manifest.ManifestError(Resources.GetResourceString("EventSource_EnumKindMismatch", staticField.Name, staticField.FieldType.Name, providerEnumKind));
}
@@ -3751,7 +3718,7 @@ namespace System.Diagnostics.Tracing
// We give a task to things if they don't have one.
// TODO this is moderately expensive (N*N). We probably should not even bother....
- Contract.Assert(eventAttribute.Task != EventTask.None || eventAttribute.Opcode != EventOpcode.Info);
+ Debug.Assert(eventAttribute.Task != EventTask.None || eventAttribute.Opcode != EventOpcode.Info);
for (int idx = 0; idx < eventData.Length; ++idx)
{
// skip unused Event IDs.
@@ -3821,7 +3788,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
/// <param name="method">The method to probe.</param>
/// <returns>The literal value or -1 if the value could not be determined. </returns>
- [SecuritySafeCritical]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Switch statement is clearer than alternatives")]
static private int GetHelperCallFirstArg(MethodInfo method)
{
@@ -3840,7 +3806,7 @@ namespace System.Diagnostics.Tracing
(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)).Assert();
byte[] instrs = method.GetMethodBody().GetILAsByteArray();
int retVal = -1;
- for (int idx = 0; idx < instrs.Length; )
+ for (int idx = 0; idx < instrs.Length;)
{
switch (instrs[idx])
{
@@ -3934,7 +3900,7 @@ namespace System.Diagnostics.Tracing
goto default;
break;
default:
- /* Contract.Assert(false, "Warning: User validation code sub-optimial: Unsuported opcode " + instrs[idx] +
+ /* Debug.Assert(false, "Warning: User validation code sub-optimial: Unsuported opcode " + instrs[idx] +
" at " + idx + " in method " + method.Name); */
return -1;
}
@@ -3968,7 +3934,7 @@ namespace System.Diagnostics.Tracing
{
#if (!ES_BUILD_PCL && !PROJECTN)
// send message to debugger without delay
- System.Diagnostics.Debugger.Log(0, null, String.Format("EventSource Error: {0}{1}", msg , Environment.NewLine));
+ System.Diagnostics.Debugger.Log(0, null, String.Format("EventSource Error: {0}{1}", msg, Environment.NewLine));
#endif
// Send it to all listeners.
@@ -4017,7 +3983,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- Contract.Assert(((m_config & EventSourceSettings.EtwManifestEventFormat) != 0) !=
+ Debug.Assert(((m_config & EventSourceSettings.EtwManifestEventFormat) != 0) !=
((m_config & EventSourceSettings.EtwSelfDescribingEventFormat) != 0));
return (m_config & EventSourceSettings.EtwSelfDescribingEventFormat) != 0;
}
@@ -4039,7 +4005,7 @@ namespace System.Diagnostics.Tracing
#if FEATURE_ACTIVITYSAMPLING
private void ReportActivitySamplingInfo(EventListener listener, SessionMask sessions)
{
- Contract.Assert(listener == null || (uint)sessions == (uint)SessionMask.FromId(0));
+ Debug.Assert(listener == null || (uint)sessions == (uint)SessionMask.FromId(0));
for (int perEventSourceSessionId = 0; perEventSourceSessionId < SessionMask.MAX; ++perEventSourceSessionId)
{
@@ -4050,7 +4016,7 @@ namespace System.Diagnostics.Tracing
if (listener == null)
{
EtwSession etwSession = m_etwSessionIdMap[perEventSourceSessionId];
- Contract.Assert(etwSession != null);
+ Debug.Assert(etwSession != null);
af = etwSession.m_activityFilter;
}
else
@@ -4090,7 +4056,7 @@ namespace System.Diagnostics.Tracing
private EventSourceSettings m_config; // configuration information
private bool m_eventSourceDisposed; // has Dispose been called.
-
+
// Enabling bits
private bool m_eventSourceEnabled; // am I enabled (any of my events are enabled for any dispatcher)
internal EventLevel m_level; // highest level enabled by any output dispatcher
@@ -4229,7 +4195,7 @@ namespace System.Diagnostics.Tracing
/// events for a particular eventSource to occur BEFORE the EventSourceCreatedCallback is issued.
/// </summary>
public event EventHandler<EventSourceCreatedEventArgs> EventSourceCreated
- {
+ {
add
{
CallBackForExistingEventSources(false, value);
@@ -4255,7 +4221,7 @@ namespace System.Diagnostics.Tracing
public EventListener()
{
// This will cause the OnEventSourceCreated callback to fire.
- CallBackForExistingEventSources(true, (obj, args) => args.EventSource.AddListener(this) );
+ CallBackForExistingEventSources(true, (obj, args) => args.EventSource.AddListener(this));
}
/// <summary>
@@ -4283,7 +4249,7 @@ namespace System.Diagnostics.Tracing
{
// Find 'this' from the s_Listeners linked list.
EventListener prev = s_Listeners;
- for (; ; )
+ for (;;)
{
EventListener cur = prev.m_Next;
if (cur == null)
@@ -4397,7 +4363,7 @@ namespace System.Diagnostics.Tracing
internal protected virtual void OnEventSourceCreated(EventSource eventSource)
{
EventHandler<EventSourceCreatedEventArgs> callBack = this._EventSourceCreated;
- if(callBack != null)
+ if (callBack != null)
{
EventSourceCreatedEventArgs args = new EventSourceCreatedEventArgs();
args.EventSource = eventSource;
@@ -4443,10 +4409,6 @@ namespace System.Diagnostics.Tracing
if (!s_EventSourceShutdownRegistered)
{
s_EventSourceShutdownRegistered = true;
-#if (!ES_BUILD_PCL && !FEATURE_CORECLR && !PROJECTN)
- AppDomain.CurrentDomain.ProcessExit += DisposeOnShutdown;
- AppDomain.CurrentDomain.DomainUnload += DisposeOnShutdown;
-#endif
}
@@ -4492,7 +4454,7 @@ namespace System.Diagnostics.Tracing
// See bug 724140 for more
private static void DisposeOnShutdown(object sender, EventArgs e)
{
- lock(EventListenersLock)
+ lock (EventListenersLock)
{
foreach (var esRef in s_EventSources)
{
@@ -4512,7 +4474,7 @@ namespace System.Diagnostics.Tracing
private static void RemoveReferencesToListenerInEventSources(EventListener listenerToRemove)
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
+ Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
#endif
// Foreach existing EventSource in the appdomain
foreach (WeakReference eventSourceRef in s_EventSources)
@@ -4527,12 +4489,12 @@ namespace System.Diagnostics.Tracing
{
// Remove 'listenerToRemove' from the eventSource.m_Dispatchers linked list.
EventDispatcher prev = eventSource.m_Dispatchers;
- for (; ; )
+ for (;;)
{
EventDispatcher cur = prev.m_Next;
if (cur == null)
{
- Contract.Assert(false, "EventSource did not have a registered EventListener!");
+ Debug.Assert(false, "EventSource did not have a registered EventListener!");
break;
}
if (cur.m_Listener == listenerToRemove)
@@ -4572,13 +4534,13 @@ namespace System.Diagnostics.Tracing
EventSource eventSource = eventSourceRef.Target as EventSource;
if (eventSource == null)
continue;
- Contract.Assert(eventSource.m_id == id, "Unexpected event source ID.");
+ Debug.Assert(eventSource.m_id == id, "Unexpected event source ID.");
// None listeners on eventSources exist in the dispatcher list.
EventDispatcher dispatcher = eventSource.m_Dispatchers;
while (dispatcher != null)
{
- Contract.Assert(allListeners.ContainsKey(dispatcher.m_Listener), "EventSource has a listener not on the global list.");
+ Debug.Assert(allListeners.ContainsKey(dispatcher.m_Listener), "EventSource has a listener not on the global list.");
dispatcher = dispatcher.m_Next;
}
@@ -4586,9 +4548,9 @@ namespace System.Diagnostics.Tracing
foreach (EventListener listener in allListeners.Keys)
{
dispatcher = eventSource.m_Dispatchers;
- for (; ; )
+ for (;;)
{
- Contract.Assert(dispatcher != null, "Listener is not on all eventSources.");
+ Debug.Assert(dispatcher != null, "Listener is not on all eventSources.");
if (dispatcher.m_Listener == listener)
break;
dispatcher = dispatcher.m_Next;
@@ -4818,7 +4780,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
public Guid ActivityId
{
- [System.Security.SecurityCritical]
get { return EventSource.CurrentThreadActivityId; }
}
@@ -4827,7 +4788,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
public Guid RelatedActivityId
{
- [System.Security.SecurityCritical]
get;
internal set;
}
@@ -4848,7 +4808,7 @@ namespace System.Diagnostics.Tracing
if (m_payloadNames == null)
{
// Self described events are identified by id -1.
- Contract.Assert(EventId != -1);
+ Debug.Assert(EventId != -1);
var names = new List<string>();
foreach (var parameter in m_eventSource.m_eventData[EventId].Parameters)
@@ -4893,7 +4853,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return m_opcode;
return (EventOpcode)m_eventSource.m_eventData[EventId].Descriptor.Opcode;
}
@@ -4906,7 +4866,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return EventTask.None;
return (EventTask)m_eventSource.m_eventData[EventId].Descriptor.Task;
@@ -4920,20 +4880,20 @@ namespace System.Diagnostics.Tracing
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return m_tags;
return m_eventSource.m_eventData[EventId].Tags;
}
}
/// <summary>
- /// Gets the message for the event.
+ /// Gets the message for the event. If the message has {N} parameters they are NOT substituted.
/// </summary>
public string Message
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return m_message;
else
return m_eventSource.m_eventData[EventId].Message;
@@ -4953,7 +4913,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return EventChannel.None;
return (EventChannel)m_eventSource.m_eventData[EventId].Descriptor.Channel;
}
@@ -4967,7 +4927,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return 0;
return m_eventSource.m_eventData[EventId].Descriptor.Version;
}
@@ -4980,7 +4940,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- if (EventId < 0) // TraceLogging convention EventID == -1
+ if (EventId <= 0) // TraceLogging convention EventID == -1
return m_level;
return (EventLevel)m_eventSource.m_eventData[EventId].Descriptor.Level;
}
@@ -5277,7 +5237,7 @@ namespace System.Diagnostics.Tracing
public static void DisableFilter(ref ActivityFilter filterList, EventSource source)
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
+ Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
#endif
if (filterList == null)
@@ -5345,7 +5305,7 @@ namespace System.Diagnostics.Tracing
string startEvents)
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
+ Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
#endif
// first remove all filters associated with 'source'
@@ -5432,7 +5392,6 @@ namespace System.Diagnostics.Tracing
/// If 'childActivityID' is present, it will be added to the active set if the
/// current activity is active.
/// </summary>
- [SecurityCritical]
unsafe public static bool PassesActivityFilter(
ActivityFilter filterList,
Guid* childActivityID,
@@ -5440,7 +5399,7 @@ namespace System.Diagnostics.Tracing
EventSource source,
int eventId)
{
- Contract.Assert(filterList != null && filterList.m_activeActivities != null);
+ Debug.Assert(filterList != null && filterList.m_activeActivities != null);
bool shouldBeLogged = false;
if (triggeringEvent)
{
@@ -5513,7 +5472,6 @@ namespace System.Diagnostics.Tracing
return shouldBeLogged;
}
- [System.Security.SecuritySafeCritical]
public static bool IsCurrentActivityActive(ActivityFilter filterList)
{
var activeActivities = GetActiveActivities(filterList);
@@ -5530,13 +5488,12 @@ namespace System.Diagnostics.Tracing
/// value for 'currentActivityid' is an indication tha caller has already verified
/// that the current activity is active.
/// </summary>
- [SecurityCritical]
unsafe public static void FlowActivityIfNeeded(ActivityFilter filterList, Guid* currentActivityId, Guid* childActivityID)
{
- Contract.Assert(childActivityID != null);
+ Debug.Assert(childActivityID != null);
var activeActivities = GetActiveActivities(filterList);
- Contract.Assert(activeActivities != null);
+ Debug.Assert(activeActivities != null);
// take currentActivityId == null to mean we *know* the current activity is "active"
if (currentActivityId != null && !activeActivities.ContainsKey(*currentActivityId))
@@ -5593,7 +5550,7 @@ namespace System.Diagnostics.Tracing
public void Dispose()
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
+ Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
#endif
// m_myActivityDelegate is still alive (held by the static EventSource.s_activityDying).
// Therefore we are ok to take a dependency on m_myActivityDelegate being valid even
@@ -5620,7 +5577,7 @@ namespace System.Diagnostics.Tracing
m_samplingFreq = samplingFreq;
m_next = existingFilter;
- Contract.Assert(existingFilter == null ||
+ Debug.Assert(existingFilter == null ||
(existingFilter.m_activeActivities == null) == (existingFilter.m_rootActiveActivities == null));
// if this is the first filter we add for this session, we need to create a new
@@ -5694,10 +5651,10 @@ namespace System.Diagnostics.Tracing
private static bool EnableFilter(ref ActivityFilter filterList, EventSource source, int perEventSourceSessionId, int eventId, int samplingFreq)
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
+ Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
#endif
- Contract.Assert(samplingFreq > 0);
- Contract.Assert(eventId >= 0);
+ Debug.Assert(samplingFreq > 0);
+ Debug.Assert(eventId >= 0);
filterList = new ActivityFilter(source, perEventSourceSessionId, eventId, samplingFreq, filterList);
@@ -5828,7 +5785,7 @@ namespace System.Diagnostics.Tracing
public static void RemoveEtwSession(EtwSession etwSession)
{
- Contract.Assert(etwSession != null);
+ Debug.Assert(etwSession != null);
if (s_etwSessions == null || etwSession == null)
return;
@@ -5909,7 +5866,7 @@ namespace System.Diagnostics.Tracing
public static SessionMask FromId(int perEventSourceSessionId)
{
- Contract.Assert(perEventSourceSessionId < MAX);
+ Debug.Assert(perEventSourceSessionId < MAX);
return new SessionMask((uint)1 << perEventSourceSessionId);
}
@@ -5927,12 +5884,12 @@ namespace System.Diagnostics.Tracing
{
get
{
- Contract.Assert(perEventSourceSessionId < MAX);
+ Debug.Assert(perEventSourceSessionId < MAX);
return (m_mask & (1 << perEventSourceSessionId)) != 0;
}
set
{
- Contract.Assert(perEventSourceSessionId < MAX);
+ Debug.Assert(perEventSourceSessionId < MAX);
if (value) m_mask |= ((uint)1 << perEventSourceSessionId);
else m_mask &= ~((uint)1 << perEventSourceSessionId);
}
@@ -6163,7 +6120,7 @@ namespace System.Diagnostics.Tracing
private EventChannelType EventChannelToChannelType(EventChannel channel)
{
#if !ES_BUILD_STANDALONE
- Contract.Assert(channel >= EventChannel.Admin && channel <= EventChannel.Debug);
+ Debug.Assert(channel >= EventChannel.Admin && channel <= EventChannel.Debug);
#endif
return (EventChannelType)((int)channel - (int)EventChannel.Admin + (int)EventChannelType.Admin);
}
@@ -6206,8 +6163,8 @@ namespace System.Diagnostics.Tracing
#endif
public void StartEvent(string eventName, EventAttribute eventAttribute)
{
- Contract.Assert(numParams == 0);
- Contract.Assert(this.eventName == null);
+ Debug.Assert(numParams == 0);
+ Debug.Assert(this.eventName == null);
this.eventName = eventName;
numParams = 0;
byteArrArgIndices = null;
@@ -6311,7 +6268,7 @@ namespace System.Diagnostics.Tracing
// otherwise we allocate a channel bit for the channel.
// explicit channel bits are only used by WCF to mimic an existing manifest,
// so we don't dont do error checking.
- public ulong GetChannelKeyword(EventChannel channel, ulong channelKeyword=0)
+ public ulong GetChannelKeyword(EventChannel channel, ulong channelKeyword = 0)
{
// strip off any non-channel keywords, since we are only interested in channels here.
channelKeyword &= ValidPredefinedChannelKeywords;
@@ -6560,7 +6517,7 @@ namespace System.Diagnostics.Tracing
// very early in the app domain creation, when _FusionStore is not set up yet, resulting in a failure to run the static constructory
// for BinaryCompatibility. This failure is then cached and a TypeInitializationException is thrown every time some code attampts to
// access BinaryCompatibility.
- ArraySortHelper<string>.IntrospectiveSort(sortedStrings, 0, sortedStrings.Length, Comparer<string>.Default);
+ ArraySortHelper<string>.IntrospectiveSort(sortedStrings, 0, sortedStrings.Length, string.Compare);
#endif
foreach (var ci in cultures)
{
@@ -6642,13 +6599,7 @@ namespace System.Diagnostics.Tracing
private static List<CultureInfo> GetSupportedCultures(ResourceManager resources)
{
var cultures = new List<CultureInfo>();
-#if !ES_BUILD_PCL && !FEATURE_CORECLR && !PROJECTN
- foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures /*| CultureTypes.NeutralCultures*/))
- {
- if (resources.GetResourceSet(ci, true, false) != null)
- cultures.Add(ci);
- }
-#endif // !ES_BUILD_PCL && !FEATURE_CORECLR
+
if (!cultures.Contains(CultureInfo.CurrentUICulture))
cultures.Insert(0, CultureInfo.CurrentUICulture);
return cultures;
@@ -6701,7 +6652,7 @@ namespace System.Diagnostics.Tracing
ret = taskTab[(int)task] = eventName;
return ret;
}
-
+
private string GetOpcodeName(EventOpcode opcode, string eventName)
{
switch (opcode)
@@ -6738,12 +6689,12 @@ namespace System.Diagnostics.Tracing
}
return ret;
}
-
+
private string GetKeywords(ulong keywords, string eventName)
{
// ignore keywords associate with channels
// See ValidPredefinedChannelKeywords def for more.
- keywords &= ~ValidPredefinedChannelKeywords;
+ keywords &= ~ValidPredefinedChannelKeywords;
string ret = "";
for (ulong bit = 1; bit != 0; bit <<= 1)
@@ -6770,7 +6721,7 @@ namespace System.Diagnostics.Tracing
}
return ret;
}
-
+
private string GetTypeName(Type type)
{
if (type.IsEnum())
@@ -6779,7 +6730,7 @@ namespace System.Diagnostics.Tracing
var typeName = GetTypeName(fields[0].FieldType);
return typeName.Replace("win:Int", "win:UInt"); // ETW requires enums to be unsigned.
}
-
+
return GetTypeNameHelper(type);
}
@@ -6797,7 +6748,7 @@ namespace System.Diagnostics.Tracing
StringBuilder stringBuilder = null; // We lazily create this
int writtenSoFar = 0;
int chIdx = -1;
- for (int i = 0; ; )
+ for (int i = 0; ;)
{
if (i >= eventMessage.Length)
{
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs
index 00bd0b7caa..0a689efe92 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs
@@ -29,7 +29,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
/// <param name="activityId">A Guid that represents the new activity with which to mark
/// the current thread</param>
- [System.Security.SecuritySafeCritical]
public static void SetCurrentThreadActivityId(Guid activityId)
{
if (TplEtwProvider.Log != null)
@@ -80,7 +79,6 @@ namespace System.Diagnostics.Tracing
/// the current thread</param>
/// <param name="oldActivityThatWillContinue">The Guid that represents the current activity
/// which will continue at some point in the future, on the current thread</param>
- [System.Security.SecuritySafeCritical]
public static void SetCurrentThreadActivityId(Guid activityId, out Guid oldActivityThatWillContinue)
{
oldActivityThatWillContinue = activityId;
@@ -104,7 +102,6 @@ namespace System.Diagnostics.Tracing
/// </summary>
public static Guid CurrentThreadActivityId
{
- [System.Security.SecuritySafeCritical]
get
{
// We ignore errors to keep with the convention that EventSources do not throw
@@ -186,7 +183,6 @@ namespace System.Diagnostics.Tracing
internal partial class EventProvider
{
- [System.Security.SecurityCritical]
internal unsafe int SetInformation(
UnsafeNativeMethods.ManifestEtw.EVENT_INFO_CLASS eventInfoClass,
IntPtr data,
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs
index d0d687e8d8..079d7f480b 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs
@@ -22,7 +22,6 @@ namespace System.Diagnostics.Tracing
/// EventWrite. The instance must be Disabled before the arrays referenced
/// by the pointers are freed or unpinned.
/// </summary>
- [SecurityCritical]
internal unsafe struct DataCollector
{
[ThreadStatic]
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs
index be97447301..5967ad6ab5 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Collections;
+using System.Diagnostics;
#if !ES_BUILD_AGAINST_DOTNET_V35
using Contract = System.Diagnostics.Contracts.Contract;
@@ -26,7 +27,7 @@ namespace System.Diagnostics.Tracing
{
internal EventPayload(List<string> payloadNames, List<object> payloadValues)
{
- Contract.Assert(payloadNames.Count == payloadValues.Count);
+ Debug.Assert(payloadNames.Count == payloadValues.Count);
m_names = payloadNames;
m_values = payloadValues;
@@ -40,7 +41,7 @@ namespace System.Diagnostics.Tracing
get
{
if (key == null)
- throw new System.ArgumentNullException("key");
+ throw new System.ArgumentNullException(nameof(key));
int position = 0;
foreach(var name in m_names)
@@ -83,7 +84,7 @@ namespace System.Diagnostics.Tracing
public bool ContainsKey(string key)
{
if (key == null)
- throw new System.ArgumentNullException("key");
+ throw new System.ArgumentNullException(nameof(key));
foreach (var item in m_names)
{
@@ -129,7 +130,7 @@ namespace System.Diagnostics.Tracing
public bool TryGetValue(string key, out object value)
{
if (key == null)
- throw new System.ArgumentNullException("key");
+ throw new System.ArgumentNullException(nameof(key));
int position = 0;
foreach (var name in m_names)
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceActivity.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceActivity.cs
index fccfd48721..38c1767462 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceActivity.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceActivity.cs
@@ -35,7 +35,7 @@ namespace System.Diagnostics.Tracing
public EventSourceActivity(EventSource eventSource)
{
if (eventSource == null)
- throw new ArgumentNullException("eventSource");
+ throw new ArgumentNullException(nameof(eventSource));
Contract.EndContractBlock();
this.eventSource = eventSource;
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs
index 45673f7ab5..309226b84d 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs
@@ -108,7 +108,7 @@ namespace System.Diagnostics.Tracing
if (name == null)
{
throw new ArgumentNullException(
- "name",
+ nameof(name),
"This usually means that the object passed to Write is of a type that"
+ " does not support being used as the top-level object in an event,"
+ " e.g. a primitive or built-in type.");
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs
index 0f34d95648..3ea781252f 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs
@@ -1,5 +1,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Diagnostics;
#if !ES_BUILD_AGAINST_DOTNET_V35
using Contract = System.Diagnostics.Contracts.Contract;
@@ -132,7 +133,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- Contract.Assert(_scalarLength == 0, "This ReflectedValue refers to an unboxed value type, not a reference type or boxed value type.");
+ Debug.Assert(_scalarLength == 0, "This ReflectedValue refers to an unboxed value type, not a reference type or boxed value type.");
return _reference;
}
}
@@ -141,7 +142,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- Contract.Assert(_scalarLength > 0, "This ReflectedValue refers to a reference type or boxed value type, not an unboxed value type");
+ Debug.Assert(_scalarLength > 0, "This ReflectedValue refers to a reference type or boxed value type, not an unboxed value type");
return _scalar;
}
}
@@ -150,7 +151,7 @@ namespace System.Diagnostics.Tracing
{
get
{
- Contract.Assert(_scalarLength > 0, "This ReflectedValue refers to a reference type or boxed value type, not an unboxed value type");
+ Debug.Assert(_scalarLength > 0, "This ReflectedValue refers to a reference type or boxed value type, not an unboxed value type");
return _scalarLength;
}
}
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs
index e51aff0380..901a0ed1a2 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Diagnostics;
#if !ES_BUILD_AGAINST_DOTNET_V35
using Contract = System.Diagnostics.Contracts.Contract;
@@ -269,7 +270,7 @@ namespace System.Diagnostics.Tracing
: base(type)
{
var typeArgs = type.GenericTypeArguments;
- Contract.Assert(typeArgs.Length == 1);
+ Debug.Assert(typeArgs.Length == 1);
this.valueInfo = TraceLoggingTypeInfo.GetInstance(typeArgs[0], recursionCheck);
this.hasValueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("HasValue"));
this.valueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("Value"));
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/Statics.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/Statics.cs
index fa0f79f58f..516c8ba19a 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/Statics.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/Statics.cs
@@ -175,7 +175,7 @@ namespace System.Diagnostics.Tracing
{
if (name != null && 0 <= name.IndexOf('\0'))
{
- throw new ArgumentOutOfRangeException("name");
+ throw new ArgumentOutOfRangeException(nameof(name));
}
}
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingDataCollector.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingDataCollector.cs
index 4b6e633487..04a047fb35 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingDataCollector.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingDataCollector.cs
@@ -21,7 +21,6 @@ namespace System.Diagnostics.Tracing
/// full-trust code, this abstraction is unnecessary (though it probably
/// doesn't hurt anything).
/// </summary>
- [SecuritySafeCritical]
internal unsafe class TraceLoggingDataCollector
{
internal static readonly TraceLoggingDataCollector Instance = new TraceLoggingDataCollector();
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs
index 963c492419..07a56751ea 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs
@@ -100,7 +100,7 @@ namespace System.Diagnostics.Tracing
{
if (eventSourceName == null)
{
- throw new ArgumentNullException("eventSourceName");
+ throw new ArgumentNullException(nameof(eventSourceName));
}
Contract.EndContractBlock();
}
@@ -110,12 +110,11 @@ namespace System.Diagnostics.Tracing
/// (Native API: EventWriteTransfer)
/// </summary>
/// <param name="eventName">The name of the event. Must not be null.</param>
- [SecuritySafeCritical]
public unsafe void Write(string eventName)
{
if (eventName == null)
{
- throw new ArgumentNullException("eventName");
+ throw new ArgumentNullException(nameof(eventName));
}
Contract.EndContractBlock();
@@ -138,12 +137,11 @@ namespace System.Diagnostics.Tracing
/// Options for the event, such as the level, keywords, and opcode. Unset
/// options will be set to default values.
/// </param>
- [SecuritySafeCritical]
public unsafe void Write(string eventName, EventSourceOptions options)
{
if (eventName == null)
{
- throw new ArgumentNullException("eventName");
+ throw new ArgumentNullException(nameof(eventName));
}
Contract.EndContractBlock();
@@ -175,7 +173,6 @@ namespace System.Diagnostics.Tracing
/// public instance properties of data will be written recursively to
/// create the fields of the event.
/// </param>
- [SecuritySafeCritical]
public unsafe void Write<T>(
string eventName,
T data)
@@ -212,7 +209,6 @@ namespace System.Diagnostics.Tracing
/// public instance properties of data will be written recursively to
/// create the fields of the event.
/// </param>
- [SecuritySafeCritical]
public unsafe void Write<T>(
string eventName,
EventSourceOptions options,
@@ -251,7 +247,6 @@ namespace System.Diagnostics.Tracing
/// public instance properties of data will be written recursively to
/// create the fields of the event.
/// </param>
- [SecuritySafeCritical]
public unsafe void Write<T>(
string eventName,
ref EventSourceOptions options,
@@ -297,7 +292,6 @@ namespace System.Diagnostics.Tracing
/// public instance properties of data will be written recursively to
/// create the fields of the event.
/// </param>
- [SecuritySafeCritical]
public unsafe void Write<T>(
string eventName,
ref EventSourceOptions options,
@@ -354,7 +348,6 @@ namespace System.Diagnostics.Tracing
/// the values must match the number and types of the fields described by the
/// eventTypes parameter.
/// </param>
- [SecuritySafeCritical]
private unsafe void WriteMultiMerge(
string eventName,
ref EventSourceOptions options,
@@ -415,7 +408,6 @@ namespace System.Diagnostics.Tracing
/// the values must match the number and types of the fields described by the
/// eventTypes parameter.
/// </param>
- [SecuritySafeCritical]
private unsafe void WriteMultiMergeInner(
string eventName,
ref EventSourceOptions options,
@@ -526,7 +518,6 @@ namespace System.Diagnostics.Tracing
/// The number and types of the values must match the number and types of the
/// fields described by the eventTypes parameter.
/// </param>
- [SecuritySafeCritical]
internal unsafe void WriteMultiMerge(
string eventName,
ref EventSourceOptions options,
@@ -604,7 +595,6 @@ namespace System.Diagnostics.Tracing
#endif // FEATURE_MANAGED_ETW
}
- [SecuritySafeCritical]
private unsafe void WriteImpl(
string eventName,
ref EventSourceOptions options,
@@ -721,7 +711,6 @@ namespace System.Diagnostics.Tracing
}
}
- [SecurityCritical]
private unsafe void WriteToAllListeners(string eventName, ref EventDescriptor eventDescriptor, EventTags tags, Guid* pActivityId, EventPayload payload)
{
EventWrittenEventArgs eventCallbackArgs = new EventWrittenEventArgs(this);
@@ -750,7 +739,6 @@ namespace System.Diagnostics.Tracing
System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState,
System.Runtime.ConstrainedExecution.Cer.Success)]
#endif
- [SecurityCritical]
[NonEvent]
private unsafe void WriteCleanup(GCHandle* pPins, int cPins)
{
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs
index 4e33e58a82..c2239671bb 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs
@@ -94,7 +94,7 @@ namespace System.Diagnostics.Tracing
{
if (name == null)
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
Contract.EndContractBlock();
@@ -132,7 +132,7 @@ namespace System.Diagnostics.Tracing
{
if (defaultName == null)
{
- throw new ArgumentNullException("defaultName");
+ throw new ArgumentNullException(nameof(defaultName));
}
Contract.EndContractBlock();
@@ -212,7 +212,7 @@ namespace System.Diagnostics.Tracing
{
if (paramInfos == null)
{
- throw new ArgumentNullException("paramInfos");
+ throw new ArgumentNullException(nameof(paramInfos));
}
Contract.EndContractBlock();
@@ -231,7 +231,7 @@ namespace System.Diagnostics.Tracing
{
if (types == null)
{
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
}
Contract.EndContractBlock();
@@ -251,7 +251,7 @@ namespace System.Diagnostics.Tracing
{
if (typeInfos == null)
{
- throw new ArgumentNullException("typeInfos");
+ throw new ArgumentNullException(nameof(typeInfos));
}
Contract.EndContractBlock();
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs
index 0467ec43e5..41225c8626 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs
@@ -156,7 +156,7 @@ namespace System.Diagnostics.Tracing
size = 16;
break;
default:
- throw new ArgumentOutOfRangeException("type");
+ throw new ArgumentOutOfRangeException(nameof(type));
}
this.impl.AddScalar(size);
@@ -183,7 +183,7 @@ namespace System.Diagnostics.Tracing
case TraceLoggingDataType.CountedUtf16String:
break;
default:
- throw new ArgumentOutOfRangeException("type");
+ throw new ArgumentOutOfRangeException(nameof(type));
}
this.impl.AddScalar(2);
@@ -227,7 +227,7 @@ namespace System.Diagnostics.Tracing
case TraceLoggingDataType.Char8:
break;
default:
- throw new ArgumentOutOfRangeException("type");
+ throw new ArgumentOutOfRangeException(nameof(type));
}
if (this.BeginningBufferedArray)
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs
index 5815d12fb0..0cc17e02f3 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs
@@ -36,7 +36,7 @@ namespace System.Diagnostics.Tracing
{
if (dataType == null)
{
- throw new ArgumentNullException("dataType");
+ throw new ArgumentNullException(nameof(dataType));
}
Contract.EndContractBlock();
@@ -56,7 +56,7 @@ namespace System.Diagnostics.Tracing
{
if (dataType == null)
{
- throw new ArgumentNullException("dataType");
+ throw new ArgumentNullException(nameof(dataType));
}
if (name == null)
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs b/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs
index d7112fc81b..c96d2129f0 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs
@@ -73,9 +73,8 @@ namespace System.Diagnostics.Tracing
}
}
- private static string Serialize(ReadOnlyCollection<string> payloadName, ReadOnlyCollection<object> payload, string sep = ", ")
+ private static string Serialize(ReadOnlyCollection<string> payloadName, ReadOnlyCollection<object> payload, string eventMessage)
{
-
if (payloadName == null || payload == null )
return String.Empty;
@@ -92,8 +91,22 @@ namespace System.Diagnostics.Tracing
var sb = StringBuilderCache.Acquire();
sb.Append('{');
+
+ // If the event has a message, send that as well as a pseudo-field
+ if (!string.IsNullOrEmpty(eventMessage))
+ {
+ sb.Append("\\\"EventSource_Message\\\":\\\"");
+ minimalJsonserializer(eventMessage,sb);
+ sb.Append("\\\"");
+ if (eventDataCount != 0)
+ sb.Append(", ");
+ }
+
for (int i = 0; i < eventDataCount; i++)
{
+ if (i != 0)
+ sb.Append(", ");
+
var fieldstr = payloadName[i].ToString();
sb.Append("\\\"");
@@ -114,14 +127,9 @@ namespace System.Diagnostics.Tracing
sb.Append(payload[i].ToString());
}
- sb.Append(sep);
-
}
-
- sb.Length -= sep.Length;
- sb.Append('}');
-
- return StringBuilderCache.GetStringAndRelease(sb);
+ sb.Append('}');
+ return StringBuilderCache.GetStringAndRelease(sb);
}
internal protected override void OnEventSourceCreated(EventSource eventSource)
@@ -149,7 +157,7 @@ namespace System.Diagnostics.Tracing
if (eventData.Payload != null)
{
try{
- payload = Serialize(eventData.PayloadNames, eventData.Payload);
+ payload = Serialize(eventData.PayloadNames, eventData.Payload, eventData.Message);
}
catch (Exception ex)
{
diff --git a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
index e3e2b867c4..84f6b91f65 100644
--- a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
+++ b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
@@ -33,11 +33,10 @@ namespace System.Diagnostics {
//
// All switches (except for the global LogSwitch) have a parent LogSwitch.
//
- [System.Security.SecuritySafeCritical] // auto-generated
public LogSwitch(String name, String description, LogSwitch parent)
{
if (name != null && name.Length == 0)
- throw new ArgumentOutOfRangeException("Name", Environment.GetResourceString("Argument_StringZeroLength"));
+ throw new ArgumentOutOfRangeException(nameof(Name), Environment.GetResourceString("Argument_StringZeroLength"));
Contract.EndContractBlock();
if ((name != null) && (parent != null))
@@ -55,10 +54,9 @@ namespace System.Diagnostics {
Log.AddLogSwitch (this);
}
else
- throw new ArgumentNullException ((name==null ? "name" : "parent"));
+ throw new ArgumentNullException ((name==null ? nameof(name) : nameof(parent)));
}
- [System.Security.SecuritySafeCritical] // auto-generated
internal LogSwitch(String name, String description)
{
strName = name;
@@ -100,7 +98,6 @@ namespace System.Diagnostics {
public virtual LoggingLevels MinimumLevel
{
get { return iLevel; }
- [System.Security.SecuritySafeCritical] // auto-generated
set
{
iLevel = value;
diff --git a/src/mscorlib/src/System/Diagnostics/Stackframe.cs b/src/mscorlib/src/System/Diagnostics/Stackframe.cs
index 397c3e12e6..06d675ea08 100644
--- a/src/mscorlib/src/System/Diagnostics/Stackframe.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stackframe.cs
@@ -11,13 +11,7 @@ namespace System.Diagnostics {
using System.Security.Permissions;
using System.Diagnostics.Contracts;
- // There is no good reason for the methods of this class to be virtual.
- // In order to ensure trusted code can trust the data it gets from a
- // StackTrace, we use an InheritanceDemand to prevent partially-trusted
- // subclasses.
-#if !FEATURE_CORECLR
- [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)]
-#endif
+ // There is no good reason for the methods of this class to be virtual.
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class StackFrame
@@ -49,9 +43,6 @@ namespace System.Diagnostics {
}
// Constructs a StackFrame corresponding to the active stack frame.
-#if FEATURE_CORECLR
- [System.Security.SecuritySafeCritical]
-#endif
public StackFrame()
{
InitMembers();
@@ -59,9 +50,6 @@ namespace System.Diagnostics {
}
// Constructs a StackFrame corresponding to the active stack frame.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
public StackFrame(bool fNeedFileInfo)
{
InitMembers();
@@ -78,9 +66,6 @@ namespace System.Diagnostics {
// Constructs a StackFrame corresponding to a calling stack frame.
//
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
public StackFrame(int skipFrames, bool fNeedFileInfo)
{
InitMembers();
@@ -200,11 +185,6 @@ namespace System.Diagnostics {
// information is normally extracted from the debugging symbols
// for the executable.
//
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #else
- [System.Security.SecuritySafeCritical]
- #endif
public virtual String GetFileName()
{
if (strFileName != null)
@@ -242,7 +222,6 @@ namespace System.Diagnostics {
// Builds a readable representation of the stack frame
//
- [System.Security.SecuritySafeCritical] // auto-generated
public override String ToString()
{
StringBuilder sb = new StringBuilder(255);
diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
index 047a60f328..7dc5d9df09 100644
--- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
@@ -61,14 +61,12 @@ namespace System.Diagnostics {
IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset,
out string sourceFile, out int sourceLine, out int sourceColumn);
-#if FEATURE_CORECLR
private static Type s_symbolsType = null;
private static MethodInfo s_symbolsMethodInfo = null;
[ThreadStatic]
private static int t_reentrancy = 0;
-#endif
-
+
public StackFrameHelper(Thread target)
{
targetThread = target;
@@ -111,7 +109,6 @@ namespace System.Diagnostics {
{
StackTrace.GetStackFramesInternal(this, iSkip, fNeedFileInfo, exception);
-#if FEATURE_CORECLR
if (!fNeedFileInfo)
return;
@@ -164,12 +161,10 @@ namespace System.Diagnostics {
{
t_reentrancy--;
}
-#endif
}
void IDisposable.Dispose()
{
-#if FEATURE_CORECLR
if (getSourceLineInfo != null)
{
IDisposable disposable = getSourceLineInfo.Target as IDisposable;
@@ -178,10 +173,8 @@ namespace System.Diagnostics {
disposable.Dispose();
}
}
-#endif
}
- [System.Security.SecuritySafeCritical]
public virtual MethodBase GetMethodBase(int i)
{
// There may be a better way to do this.
@@ -219,7 +212,6 @@ namespace System.Diagnostics {
// serialization implementation
//
[OnSerializing]
- [SecuritySafeCritical]
void OnSerializing(StreamingContext context)
{
// this is called in the process of serializing this object.
@@ -244,7 +236,6 @@ namespace System.Diagnostics {
}
[OnDeserialized]
- [SecuritySafeCritical]
void OnDeserialized(StreamingContext context)
{
// after we are done deserializing we need to transform the rgMethodBase in rgMethodHandle
@@ -267,9 +258,6 @@ namespace System.Diagnostics {
// In order to ensure trusted code can trust the data it gets from a
// StackTrace, we use an InheritanceDemand to prevent partially-trusted
// subclasses.
-#if !FEATURE_CORECLR
- [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)]
-#endif
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class StackTrace
@@ -280,9 +268,6 @@ namespace System.Diagnostics {
private int m_iMethodsToSkip;
// Constructs a stack trace from the current location.
-#if FEATURE_CORECLR
- [System.Security.SecuritySafeCritical]
-#endif
public StackTrace()
{
m_iNumOfFrames = 0;
@@ -292,9 +277,6 @@ namespace System.Diagnostics {
// Constructs a stack trace from the current location.
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
public StackTrace(bool fNeedFileInfo)
{
m_iNumOfFrames = 0;
@@ -305,14 +287,11 @@ namespace System.Diagnostics {
// Constructs a stack trace from the current location, in a caller's
// frame
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
public StackTrace(int skipFrames)
{
if (skipFrames < 0)
- throw new ArgumentOutOfRangeException("skipFrames",
+ throw new ArgumentOutOfRangeException(nameof(skipFrames),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -325,14 +304,11 @@ namespace System.Diagnostics {
// Constructs a stack trace from the current location, in a caller's
// frame
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
public StackTrace(int skipFrames, bool fNeedFileInfo)
{
if (skipFrames < 0)
- throw new ArgumentOutOfRangeException("skipFrames",
+ throw new ArgumentOutOfRangeException(nameof(skipFrames),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -347,7 +323,7 @@ namespace System.Diagnostics {
public StackTrace(Exception e)
{
if (e == null)
- throw new ArgumentNullException("e");
+ throw new ArgumentNullException(nameof(e));
Contract.EndContractBlock();
m_iNumOfFrames = 0;
@@ -357,13 +333,10 @@ namespace System.Diagnostics {
// Constructs a stack trace from the current location.
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
public StackTrace(Exception e, bool fNeedFileInfo)
{
if (e == null)
- throw new ArgumentNullException("e");
+ throw new ArgumentNullException(nameof(e));
Contract.EndContractBlock();
m_iNumOfFrames = 0;
@@ -374,16 +347,13 @@ namespace System.Diagnostics {
// Constructs a stack trace from the current location, in a caller's
// frame
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
public StackTrace(Exception e, int skipFrames)
{
if (e == null)
- throw new ArgumentNullException("e");
+ throw new ArgumentNullException(nameof(e));
if (skipFrames < 0)
- throw new ArgumentOutOfRangeException("skipFrames",
+ throw new ArgumentOutOfRangeException(nameof(skipFrames),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -396,16 +366,13 @@ namespace System.Diagnostics {
// Constructs a stack trace from the current location, in a caller's
// frame
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
public StackTrace(Exception e, int skipFrames, bool fNeedFileInfo)
{
if (e == null)
- throw new ArgumentNullException("e");
+ throw new ArgumentNullException(nameof(e));
if (skipFrames < 0)
- throw new ArgumentOutOfRangeException("skipFrames",
+ throw new ArgumentOutOfRangeException(nameof(skipFrames),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -430,9 +397,6 @@ namespace System.Diagnostics {
// Constructs a stack trace for the given thread
//
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
[Obsolete("This constructor has been deprecated. Please use a constructor that does not require a Thread parameter. http://go.microsoft.com/fwlink/?linkid=14202")]
public StackTrace(Thread targetThread, bool needFileInfo)
{
@@ -443,7 +407,6 @@ namespace System.Diagnostics {
}
- [System.Security.SecuritySafeCritical]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void GetStackFramesInternal(StackFrameHelper sfh, int iSkip, bool fNeedFileInfo, Exception e);
@@ -576,9 +539,6 @@ namespace System.Diagnostics {
// Builds a readable representation of the stack trace
//
-#if FEATURE_CORECLR
- [System.Security.SecuritySafeCritical]
-#endif
public override String ToString()
{
// Include a trailing newline for backwards compatibility
@@ -596,9 +556,6 @@ namespace System.Diagnostics {
// Builds a readable representation of the stack trace, specifying
// the format for backwards compatibility.
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
internal String ToString(TraceFormat traceFormat)
{
bool displayFilenames = true; // we'll try, but demand may fail
@@ -656,26 +613,22 @@ namespace System.Diagnostics {
else
fFirstTyParam = false;
- sb.Append(typars[k].Name);
+ sb.Append(typars[k].Name);
k++;
}
sb.Append(']');
}
ParameterInfo[] pi = null;
-#if FEATURE_CORECLR
try
{
-#endif
pi = mb.GetParameters();
-#if FEATURE_CORECLR
}
catch
{
// The parameter info cannot be loaded, so we don't
// append the parameter list.
}
-#endif
if (pi != null)
{
// arguments printing
@@ -712,15 +665,6 @@ namespace System.Diagnostics {
{
fileName = sf.GetFileName();
}
-#if FEATURE_CAS_POLICY
- catch (NotSupportedException)
- {
- // Having a deprecated stack modifier on the callstack (such as Deny) will cause
- // a NotSupportedException to be thrown. Since we don't know if the app can
- // access the file names, we'll conservatively hide them.
- displayFilenames = false;
- }
-#endif // FEATURE_CAS_POLICY
catch (SecurityException)
{
// If the demand for displaying filenames fails, then it won't
@@ -754,9 +698,6 @@ namespace System.Diagnostics {
// This helper is called from within the EE to construct a string representation
// of the current stack trace.
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
private static String GetManagedStackTraceStringHelper(bool fNeedFileInfo)
{
// Note all the frames in System.Diagnostics will be skipped when capturing
diff --git a/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs b/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs
index b6177be2aa..a0d3640c2c 100644
--- a/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs
+++ b/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs
@@ -31,9 +31,6 @@ namespace System.Diagnostics.SymbolStore {
// Define a source document. Guid's will be provided for the
// languages, vendors, and document types that we currently know
// about.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
ISymbolDocumentWriter DefineDocument(String url,
Guid language,
Guid languageVendor,
@@ -42,9 +39,6 @@ namespace System.Diagnostics.SymbolStore {
// Define the method that the user has defined as their entrypoint
// for this module. This would be, perhaps, the user's main method
// rather than compiler generated stubs before main.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void SetUserEntryPoint(SymbolToken entryMethod);
// Open a method to emit symbol information into. The given method
@@ -55,25 +49,16 @@ namespace System.Diagnostics.SymbolStore {
// defined symbols for that method.
//
// There can be only one open method at a time.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void OpenMethod(SymbolToken method);
// Close the current method. Once a method is closed, no more
// symbols can be defined within it.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void CloseMethod();
// Define a group of sequence points within the current method.
// Each line/column defines the start of a statement within a
// method. The arrays should be sorted by offset. The offset is
// always the offset from the start of the method, in bytes.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void DefineSequencePoints(ISymbolDocumentWriter document,
int[] offsets,
int[] lines,
@@ -96,17 +81,11 @@ namespace System.Diagnostics.SymbolStore {
// Note: scope id's are only valid in the current method.
//
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
int OpenScope(int startOffset);
// Close the current lexical scope. Once a scope is closed no more
// variables can be defined within it. endOffset points past the
// last instruction in the scope.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void CloseScope(int endOffset);
// Define the offset range for a given lexical scope.
@@ -120,9 +99,6 @@ namespace System.Diagnostics.SymbolStore {
// variable of the same name that has multiple homes throughout a
// scope. (Note: start/end offsets must not overlap in such a
// case.)
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void DefineLocalVariable(String name,
FieldAttributes attributes,
byte[] signature,
@@ -178,9 +154,6 @@ namespace System.Diagnostics.SymbolStore {
// Defines a custom attribute based upon its name. Not to be
// confused with Metadata custom attributes, these attributes are
// held in the symbol store.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void SetSymAttribute(SymbolToken parent, String name, byte[] data);
// Opens a new namespace. Call this before defining methods or
@@ -195,9 +168,6 @@ namespace System.Diagnostics.SymbolStore {
// current scope will also stop using the namespace, and the
// namespace will be in use in all scopes that inherit from the
// currently open scope.
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
void UsingNamespace(String fullName);
// Specifies the true start and end of a method within a source
diff --git a/src/mscorlib/src/System/Diagnostics/log.cs b/src/mscorlib/src/System/Diagnostics/log.cs
index 1c68aad161..6916ce3a0a 100644
--- a/src/mscorlib/src/System/Diagnostics/log.cs
+++ b/src/mscorlib/src/System/Diagnostics/log.cs
@@ -22,7 +22,6 @@ namespace System.Diagnostics {
// programatically, by registry (specifics....) or environment
// variables.
[Serializable]
- [HostProtection(Synchronization=true, ExternalThreading=true)]
internal delegate void LogMessageEventHandler(LoggingLevels level, LogSwitch category,
String message,
StackTrace location);
@@ -140,7 +139,7 @@ namespace System.Diagnostics {
throw new ArgumentNullException ("LogSwitch");
if (level < 0)
- throw new ArgumentOutOfRangeException("level", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(level), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
// Is logging for this level for this switch enabled?
@@ -240,10 +239,8 @@ namespace System.Diagnostics {
// Native method to inform the EE about the creation of a new LogSwitch
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void AddLogSwitch(LogSwitch logSwitch);
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void ModifyLogSwitch (int iNewLevel, String strSwitchName, String strParentName);
}