diff options
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics')
44 files changed, 961 insertions, 876 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/Assert.cs b/src/mscorlib/src/System/Diagnostics/Assert.cs index 9f4b86b7e4..c0b4e4c229 100644 --- a/src/mscorlib/src/System/Diagnostics/Assert.cs +++ b/src/mscorlib/src/System/Diagnostics/Assert.cs @@ -2,36 +2,37 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - using System; - using System.IO; - using System.Reflection; - using System.Runtime.CompilerServices; - using System.Runtime.Versioning; - using System.Diagnostics.Contracts; - using System.Diagnostics.CodeAnalysis; +using System; +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Diagnostics.Contracts; +using System.Diagnostics.CodeAnalysis; +namespace System.Diagnostics +{ // Class which handles code asserts. Asserts are used to explicitly protect // assumptions made in the code. In general if an assert fails, it indicates // a program bug so is immediately called to the attention of the user. // Only static data members, does not need to be marked with the serializable attribute internal static class Assert { - internal const int COR_E_FAILFAST = unchecked((int) 0x80131623); + internal const int COR_E_FAILFAST = unchecked((int)0x80131623); private static AssertFilter Filter; static Assert() { Filter = new DefaultFilter(); } - + // Called when an assertion is being made. // internal static void Check(bool condition, String conditionString, String message) { if (!condition) { - Fail (conditionString, message, null, COR_E_FAILFAST); + Fail(conditionString, message, null, COR_E_FAILFAST); } } @@ -54,9 +55,9 @@ namespace System.Diagnostics { { // get the stacktrace StackTrace st = new StackTrace(numStackFramesToSkip, true); - - AssertFilters iResult = Filter.AssertFailure (conditionString, message, st, stackTraceFormat, windowTitle); - + + AssertFilters iResult = Filter.AssertFailure(conditionString, message, st, stackTraceFormat, windowTitle); + if (iResult == AssertFilters.FailDebug) { if (Debugger.IsAttached == true) @@ -67,8 +68,8 @@ namespace System.Diagnostics { { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); - } - } + } + } } else if (iResult == AssertFilters.FailTerminate) { @@ -78,10 +79,10 @@ namespace System.Diagnostics { Environment._Exit(exitCode); } } - - // Called when an assert happens. - // windowTitle can be null. - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal extern static int ShowDefaultAssertDialog(String conditionString, String message, String stackTrace, String windowTitle); + + // Called when an assert happens. + // windowTitle can be null. + [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 ab60ee4cff..7c861de58e 100644 --- a/src/mscorlib/src/System/Diagnostics/AssertFilter.cs +++ b/src/mscorlib/src/System/Diagnostics/AssertFilter.cs @@ -2,29 +2,29 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - - - using System; - using System.Runtime.Versioning; - // A Filter is used to decide whether an assert failure - // should terminate the program (or invoke the debugger). - // Typically this is done by popping up a dialog & asking the user. - // - // The default filter brings up a simple Win32 dialog with 3 buttons. - + + +using System; +using System.Runtime.Versioning; + +namespace System.Diagnostics +{ + // A Filter is used to decide whether an assert failure + // should terminate the program (or invoke the debugger). + // Typically this is done by popping up a dialog & asking the user. + // + // The default filter brings up a simple Win32 dialog with 3 buttons. + [Serializable] abstract internal class AssertFilter { - // Called when an assert fails. This should be overridden with logic which // determines whether the program should terminate or not. Typically this // is done by asking the user. // // The windowTitle can be null. - abstract public AssertFilters AssertFailure(String condition, String message, + abstract public AssertFilters AssertFailure(String condition, String message, StackTrace location, StackTrace.TraceFormat stackTraceFormat, String windowTitle); - } // No data, does not need to be marked with the serializable attribute internal class DefaultFilter : AssertFilter @@ -32,14 +32,13 @@ namespace System.Diagnostics { internal DefaultFilter() { } - - public override AssertFilters AssertFailure(String condition, String message, + + public override AssertFilters AssertFailure(String condition, String message, StackTrace location, StackTrace.TraceFormat stackTraceFormat, String windowTitle) - + { - return (AssertFilters) Assert.ShowDefaultAssertDialog (condition, message, location.ToString(stackTraceFormat), windowTitle); + return (AssertFilters)Assert.ShowDefaultAssertDialog(condition, message, location.ToString(stackTraceFormat), windowTitle); } } - } diff --git a/src/mscorlib/src/System/Diagnostics/AssertFilters.cs b/src/mscorlib/src/System/Diagnostics/AssertFilters.cs index 13131d4819..0f34b41dba 100644 --- a/src/mscorlib/src/System/Diagnostics/AssertFilters.cs +++ b/src/mscorlib/src/System/Diagnostics/AssertFilters.cs @@ -2,23 +2,26 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - - /* - * FailDebug indicates the debugger should be invoked - * FailIgnore indicates the failure should be ignored & the - * program continued - * FailTerminate indicates that the program should be terminated - * FailContinue indicates that no decision is made - - * the previous Filter should be invoked - */ - using System; + +/* + * FailDebug indicates the debugger should be invoked + * FailIgnore indicates the failure should be ignored & the + * program continued + * FailTerminate indicates that the program should be terminated + * FailContinue indicates that no decision is made - + * the previous Filter should be invoked + */ + +using System; + +namespace System.Diagnostics +{ [Serializable] internal enum AssertFilters { - FailDebug = 0, - FailIgnore = 1, - FailTerminate = 2, - FailContinueFilter = 3, + FailDebug = 0, + FailIgnore = 1, + FailTerminate = 2, + FailContinueFilter = 3, } } diff --git a/src/mscorlib/src/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs b/src/mscorlib/src/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs index fb26fcc4ab..59125dd074 100644 --- a/src/mscorlib/src/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs +++ b/src/mscorlib/src/System/Diagnostics/CodeAnalysis/SuppressMessageAttribute.cs @@ -16,7 +16,6 @@ using System; namespace System.Diagnostics.CodeAnalysis { - [AttributeUsage( AttributeTargets.All, Inherited = false, @@ -32,41 +31,41 @@ namespace System.Diagnostics.CodeAnalysis private string scope; private string target; private string messageId; - + public SuppressMessageAttribute(string category, string checkId) { - this.category = category; + this.category = category; this.checkId = checkId; } - + public string Category { get { return category; } } - + public string CheckId { get { return checkId; } } - + public string Scope { get { return scope; } set { scope = value; } } - + public string Target { get { return target; } set { target = value; } } - + public string MessageId { get { return messageId; } set { messageId = value; } } - + public string Justification { get { return justification; } diff --git a/src/mscorlib/src/System/Diagnostics/ConditionalAttribute.cs b/src/mscorlib/src/System/Diagnostics/ConditionalAttribute.cs index c57fb59319..5212db8599 100644 --- a/src/mscorlib/src/System/Diagnostics/ConditionalAttribute.cs +++ b/src/mscorlib/src/System/Diagnostics/ConditionalAttribute.cs @@ -4,9 +4,10 @@ using System; -namespace System.Diagnostics { +namespace System.Diagnostics +{ [Serializable] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple=true)] + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public sealed class ConditionalAttribute : Attribute { public ConditionalAttribute(String conditionString) @@ -14,8 +15,10 @@ namespace System.Diagnostics { m_conditionString = conditionString; } - public String ConditionString { - get { + public String ConditionString + { + get + { return m_conditionString; } } diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs index 4469bffb9c..b768e4d3dd 100644 --- a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs +++ b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs @@ -42,8 +42,8 @@ using System.Runtime.ConstrainedExecution; using System.Security; #endif -namespace System.Diagnostics.Contracts { - +namespace System.Diagnostics.Contracts +{ #region Attributes /// <summary> @@ -70,7 +70,8 @@ namespace System.Diagnostics.Contracts { _typeWithContracts = typeContainingContracts; } - public Type TypeContainingContracts { + public Type TypeContainingContracts + { get { return _typeWithContracts; } } } @@ -89,7 +90,8 @@ namespace System.Diagnostics.Contracts { _typeIAmAContractFor = typeContractsAreFor; } - public Type TypeContractsAreFor { + public Type TypeContractsAreFor + { get { return _typeIAmAContractFor; } } } @@ -175,7 +177,8 @@ namespace System.Diagnostics.Contracts { public ContractVerificationAttribute(bool value) { _value = value; } - public bool Value { + public bool Value + { get { return _value; } } } @@ -196,7 +199,8 @@ namespace System.Diagnostics.Contracts { _publicName = name; } - public String Name { + public String Name + { get { return _publicName; } } } @@ -246,19 +250,23 @@ namespace System.Diagnostics.Contracts { _value = value; } - public String Category { + public String Category + { get { return _category; } } - public String Setting { + public String Setting + { get { return _setting; } } - public bool Enabled { + public bool Enabled + { get { return _enabled; } } - public String Value { + public String Value + { get { return _value; } } } @@ -295,7 +303,8 @@ namespace System.Diagnostics.Contracts { #endif public static void Assume(bool condition) { - if (!condition) { + if (!condition) + { ReportFailure(ContractFailureKind.Assume, null, null, null); } } @@ -315,7 +324,8 @@ namespace System.Diagnostics.Contracts { #endif public static void Assume(bool condition, String userMessage) { - if (!condition) { + if (!condition) + { ReportFailure(ContractFailureKind.Assume, userMessage, null, null); } } @@ -768,7 +778,8 @@ namespace System.Diagnostics.Contracts { #endregion } - public enum ContractFailureKind { + public enum ContractFailureKind + { Precondition, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Postcondition")] Postcondition, @@ -778,8 +789,6 @@ namespace System.Diagnostics.Contracts { Assert, Assume, } - - } // Note: In .NET FX 4.5, we duplicated the ContractHelper class in the System.Runtime.CompilerServices diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs index 00c9c35027..1e86b914e6 100644 --- a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs +++ b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs @@ -36,8 +36,8 @@ using System.Runtime.ConstrainedExecution; using System.Security; #endif -namespace System.Diagnostics.Contracts { - +namespace System.Diagnostics.Contracts +{ public static partial class Contract { #region Private Methods @@ -115,15 +115,18 @@ namespace System.Diagnostics.Contracts { /// full trust, because it will inform you of bugs in the appdomain and because the event handler /// could allow you to continue execution. /// </summary> - public static event EventHandler<ContractFailedEventArgs> ContractFailed { + public static event EventHandler<ContractFailedEventArgs> ContractFailed + { #if FEATURE_UNTRUSTED_CALLERS #endif - add { + add + { System.Runtime.CompilerServices.ContractHelper.InternalContractFailed += value; } #if FEATURE_UNTRUSTED_CALLERS #endif - remove { + remove + { System.Runtime.CompilerServices.ContractHelper.InternalContractFailed -= value; } } @@ -158,7 +161,8 @@ namespace System.Diagnostics.Contracts { public Exception OriginalException { get { return _originalException; } } // Whether the event handler "handles" this contract failure, or to fail via escalation policy. - public bool Handled { + public bool Handled + { get { return _handled; } } @@ -169,7 +173,8 @@ namespace System.Diagnostics.Contracts { _handled = true; } - public bool Unwind { + public bool Unwind + { get { return _unwind; } } @@ -185,9 +190,9 @@ namespace System.Diagnostics.Contracts { [SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic")] internal sealed class ContractException : Exception { - readonly ContractFailureKind _Kind; - readonly string _UserMessage; - readonly string _Condition; + private readonly ContractFailureKind _Kind; + private readonly string _UserMessage; + private readonly string _Condition; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] public ContractFailureKind Kind { get { return _Kind; } } @@ -208,9 +213,9 @@ namespace System.Diagnostics.Contracts { : base(failure, innerException) { HResult = System.Runtime.CompilerServices.ContractHelper.COR_E_CODECONTRACTFAILED; - this._Kind = kind; - this._UserMessage = userMessage; - this._Condition = condition; + _Kind = kind; + _UserMessage = userMessage; + _Condition = condition; } private ContractException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) @@ -258,7 +263,8 @@ namespace System.Runtime.CompilerServices { #if FEATURE_UNTRUSTED_CALLERS #endif - add { + add + { // Eagerly prepare each event handler _marked with a reliability contract_, to // attempt to reduce out of memory exceptions while reporting contract violations. // This only works if the new handler obeys the constraints placed on @@ -274,7 +280,8 @@ namespace System.Runtime.CompilerServices } #if FEATURE_UNTRUSTED_CALLERS #endif - remove { + remove + { lock (lockObject) { contractFailedEvent -= value; @@ -368,7 +375,8 @@ namespace System.Runtime.CompilerServices // "Assert On Failure" but used in a process that can't pop up asserts, like an // NT Service). - if (!Environment.UserInteractive) { + if (!Environment.UserInteractive) + { throw new ContractException(kind, displayMessage, userMessage, conditionText, innerException); } @@ -429,11 +437,13 @@ namespace System.Runtime.CompilerServices // on Silverlight we may not be able to look up a friendly string for the // error message. Let's leverage Silverlight's default error message there. String failureMessage; - if (!String.IsNullOrEmpty(conditionText)) { + if (!String.IsNullOrEmpty(conditionText)) + { resourceName += "_Cnd"; failureMessage = Environment.GetResourceString(resourceName, conditionText); } - else { + else + { failureMessage = Environment.GetResourceString(resourceName); } diff --git a/src/mscorlib/src/System/Diagnostics/Debugger.cs b/src/mscorlib/src/System/Diagnostics/Debugger.cs index 21c57dbfaf..aad67bc197 100644 --- a/src/mscorlib/src/System/Diagnostics/Debugger.cs +++ b/src/mscorlib/src/System/Diagnostics/Debugger.cs @@ -5,16 +5,16 @@ // The Debugger class is a part of the System.Diagnostics package // and is used for communicating with a debugger. +using System; +using System.IO; +using System.Collections; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security; +using System.Runtime.Versioning; + namespace System.Diagnostics { - using System; - using System.IO; - using System.Collections; - using System.Reflection; - using System.Runtime.CompilerServices; - using System.Security; - using System.Runtime.Versioning; - // No data, does not need to be marked with the serializable attribute public sealed class Debugger { @@ -36,7 +36,7 @@ namespace System.Diagnostics BreakInternal(); } - static void BreakCanThrow() + private static void BreakCanThrow() { BreakInternal(); } @@ -128,7 +128,5 @@ namespace System.Diagnostics // report the notification depending on its settings. [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 ce9987b9e2..5e1dfd82a5 100644 --- a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs +++ b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs @@ -10,32 +10,33 @@ ** ** ===========================================================*/ - - -namespace System.Diagnostics { - using System; - using System.Runtime.InteropServices; - using System.Diagnostics.Contracts; - -[Serializable] -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)] + + +using System; +using System.Runtime.InteropServices; +using System.Diagnostics.Contracts; + +namespace System.Diagnostics +{ + [Serializable] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)] public sealed class DebuggerStepThroughAttribute : Attribute { - public DebuggerStepThroughAttribute () {} - } + public DebuggerStepThroughAttribute() { } + } -[Serializable] -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)] + [Serializable] + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)] public sealed class DebuggerHiddenAttribute : Attribute { - public DebuggerHiddenAttribute () {} + public DebuggerHiddenAttribute() { } } -[Serializable] -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor |AttributeTargets.Struct, Inherited = false)] + [Serializable] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)] public sealed class DebuggerNonUserCodeAttribute : Attribute { - public DebuggerNonUserCodeAttribute () {} + public DebuggerNonUserCodeAttribute() { } } // Attribute class used by the compiler to mark modules. @@ -46,11 +47,11 @@ namespace System.Diagnostics { // or may not have included debugging information, and the Runtime // won't preserve the debugging info, which will make debugging after // a JIT attach difficult. - [AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Module, AllowMultiple = false)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module, AllowMultiple = false)] public sealed class DebuggableAttribute : Attribute { [Flags] - public enum DebuggingModes + public enum DebuggingModes { None = 0x0, Default = 0x1, @@ -58,7 +59,7 @@ namespace System.Diagnostics { IgnoreSymbolStoreSequencePoints = 0x2, EnableEditAndContinue = 0x4 } - + private DebuggingModes m_debuggingModes; public DebuggableAttribute(bool isJITTrackingEnabled, @@ -66,12 +67,12 @@ namespace System.Diagnostics { { m_debuggingModes = 0; - if (isJITTrackingEnabled) + if (isJITTrackingEnabled) { m_debuggingModes |= DebuggingModes.Default; } - if (isJITOptimizerDisabled) + if (isJITOptimizerDisabled) { m_debuggingModes |= DebuggingModes.DisableOptimizations; } @@ -91,7 +92,7 @@ namespace System.Diagnostics { { get { return ((m_debuggingModes & DebuggingModes.DisableOptimizations) != 0); } } - + public DebuggingModes DebuggingFlags { get { return m_debuggingModes; } @@ -108,25 +109,25 @@ namespace System.Diagnostics { // Please also change the code which validates DebuggerBrowsableState variable (in this file) // if you change this enum. - public enum DebuggerBrowsableState - { - Never = 0, + public enum DebuggerBrowsableState + { + Never = 0, //Expanded is not supported in this release //Expanded = 1, - Collapsed = 2, + Collapsed = 2, RootHidden = 3 } - - + + // the one currently supported with the csee.dat // (mcee.dat, autoexp.dat) file. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] - public sealed class DebuggerBrowsableAttribute: Attribute + public sealed class DebuggerBrowsableAttribute : Attribute { private DebuggerBrowsableState state; public DebuggerBrowsableAttribute(DebuggerBrowsableState state) { - if( state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden) + if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden) throw new ArgumentOutOfRangeException(nameof(state)); Contract.EndContractBlock(); @@ -141,7 +142,7 @@ namespace System.Diagnostics { // DebuggerTypeProxyAttribute [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class DebuggerTypeProxyAttribute: Attribute + public sealed class DebuggerTypeProxyAttribute : Attribute { private string typeName; private string targetName; @@ -149,14 +150,15 @@ namespace System.Diagnostics { public DebuggerTypeProxyAttribute(Type type) { - if (type == null) { + if (type == null) + { throw new ArgumentNullException(nameof(type)); } Contract.EndContractBlock(); - this.typeName = type.AssemblyQualifiedName; + typeName = type.AssemblyQualifiedName; } - + public DebuggerTypeProxyAttribute(string typeName) { this.typeName = typeName; @@ -168,16 +170,18 @@ namespace System.Diagnostics { public Type Target { - set { - if( value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); - - targetName = value.AssemblyQualifiedName; - target = value; + + targetName = value.AssemblyQualifiedName; + target = value; } - + get { return target; } } @@ -185,10 +189,9 @@ namespace System.Diagnostics { { get { return targetName; } set { targetName = value; } - } } - + // This attribute is used to control what is displayed for the given class or field // in the data windows in the debugger. The single argument to this attribute is // the string that will be displayed in the value column for instances of the type. @@ -209,19 +212,21 @@ namespace System.Diagnostics { public DebuggerDisplayAttribute(string value) { - if( value == null ) { + if (value == null) + { this.value = ""; } - else { + else + { this.value = value; } name = ""; type = ""; - } + } public string Value { - get { return this.value; } + get { return value; } } public string Name @@ -238,13 +243,15 @@ namespace System.Diagnostics { public Type Target { - set { - if( value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); - - targetName = value.AssemblyQualifiedName; + + targetName = value.AssemblyQualifiedName; target = value; } get { return target; } @@ -254,7 +261,6 @@ namespace System.Diagnostics { { get { return targetName; } set { targetName = value; } - } } } diff --git a/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs b/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs index 32d7a98a50..8ad4fec082 100644 --- a/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs +++ b/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs @@ -11,12 +11,13 @@ ** =============================================================================*/ -namespace System.Diagnostics { - - using System; - + +using System; + +namespace System.Diagnostics +{ [Serializable] - internal sealed class EditAndContinueHelper + internal sealed class EditAndContinueHelper { #pragma warning disable 169 #pragma warning disable 414 // Field is not used from managed. diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs b/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs index 1a1f5fa2c0..f605179490 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs @@ -15,6 +15,7 @@ using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract; namespace Microsoft.Diagnostics.Tracing #else using System.Threading.Tasks; + namespace System.Diagnostics.Tracing #endif { @@ -43,7 +44,6 @@ namespace System.Diagnostics.Tracing /// </summary> internal class ActivityTracker { - /// <summary> /// Called on work item begins. The activity name = providerName + activityName without 'Start' suffix. /// It updates CurrentActivityId to track. @@ -123,7 +123,7 @@ namespace System.Diagnostics.Tracing // Remember the current ID so we can log it activityId = newActivity.ActivityId; - + if (etwLog.Debug) { etwLog.DebugFacilityMessage("OnStartRetActivityState", ActivityInfo.LiveActivities(newActivity)); @@ -143,7 +143,7 @@ namespace System.Diagnostics.Tracing return; var fullActivityName = NormalizeActivityName(providerName, activityName, task); - + var etwLog = TplEtwProvider.Log; if (etwLog.Debug) { @@ -151,7 +151,7 @@ namespace System.Diagnostics.Tracing etwLog.DebugFacilityMessage("OnStopEnterActivityState", ActivityInfo.LiveActivities(m_current.Value)); } - for (; ; ) // This is a retry loop. + for (;;) // This is a retry loop. { ActivityInfo currentActivity = m_current.Value; ActivityInfo newCurrentActivity = null; // if we have seen any live activities (orphans), at he first one we have seen. @@ -230,12 +230,13 @@ namespace System.Diagnostics.Tracing { m_current = new AsyncLocal<ActivityInfo>(ActivityChanging); } - catch (NotImplementedException) { + catch (NotImplementedException) + { #if (!ES_BUILD_PCL && ! PROJECTN) // send message to debugger without delay System.Diagnostics.Debugger.Log(0, null, "Activity Enabled() called but AsyncLocals Not Supported (pre V4.6). Ignoring Enable"); #endif - } + } } } @@ -427,7 +428,7 @@ namespace System.Diagnostics.Tracing /// the value is either encoded into nibble itself or it can spill over into the /// bytes that follow. /// </summary> - enum NumberListCodes : byte + private enum NumberListCodes : byte { End = 0x0, // ends the list. No valid value has this prefix. LastImmediateValue = 0xA, @@ -536,7 +537,7 @@ namespace System.Diagnostics.Tracing #endregion // CreateGuidForActivityPath readonly internal string m_name; // The name used in the 'start' and 'stop' APIs to help match up - readonly long m_uniqueId; // a small number that makes this activity unique among its siblings + private readonly long m_uniqueId; // a small number that makes this activity unique among its siblings internal readonly Guid m_guid; // Activity Guid, it is basically an encoding of the Path() (see CreateActivityPathGuid) internal readonly int m_activityPathGuidOffset; // Keeps track of where in m_guid the causality path stops (used to generated child GUIDs) internal readonly int m_level; // current depth of the Path() of the activity (used to keep recursion under control) @@ -551,7 +552,7 @@ namespace System.Diagnostics.Tracing // This callback is used to initialize the m_current AsyncLocal Variable. // Its job is to keep the ETW Activity ID (part of thread local storage) in sync // with m_current.ActivityID - void ActivityChanging(AsyncLocalValueChangedArgs<ActivityInfo> args) + private void ActivityChanging(AsyncLocalValueChangedArgs<ActivityInfo> args) { ActivityInfo cur = args.CurrentValue; ActivityInfo prev = args.PreviousValue; @@ -595,14 +596,14 @@ namespace System.Diagnostics.Tracing /// /// This variable points a a linked list that represents all Activities that have started but have not stopped. /// </summary> - AsyncLocal<ActivityInfo> m_current; - bool m_checkedForEnable; + private AsyncLocal<ActivityInfo> m_current; + private bool m_checkedForEnable; // Singleton private static ActivityTracker s_activityTrackerInstance = new ActivityTracker(); // Used to create unique IDs at the top level. Not used for nested Ids (each activity has its own id generator) - static long m_nextId = 0; + private static long m_nextId = 0; private const ushort MAX_ACTIVITY_DEPTH = 100; // Limit maximum depth of activities to be tracked at 100. // This will avoid leaking memory in case of activities that are never stopped. @@ -661,5 +662,4 @@ namespace System.Diagnostics.Tracing } } #endif - } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventDescriptor.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventDescriptor.cs index 116b50f86c..2294fb94f8 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventDescriptor.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventDescriptor.cs @@ -53,14 +53,14 @@ namespace System.Diagnostics.Tracing long keywords ) { - this.m_id = 0; - this.m_version = 0; - this.m_channel = 0; - this.m_traceloggingId = traceloggingId; - this.m_level = level; - this.m_opcode = opcode; - this.m_task = 0; - this.m_keywords = keywords; + m_id = 0; + m_version = 0; + m_channel = 0; + m_traceloggingId = traceloggingId; + m_level = level; + m_opcode = opcode; + m_task = 0; + m_keywords = keywords; } public EventDescriptor( @@ -159,7 +159,7 @@ namespace System.Diagnostics.Tracing if (!(obj is EventDescriptor)) return false; - return Equals((EventDescriptor) obj); + return Equals((EventDescriptor)obj); } public override int GetHashCode() diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs index 1da6a46707..046b27b6b3 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. + using Microsoft.Win32; using System.Collections.Generic; using System.Diagnostics; @@ -45,7 +46,7 @@ namespace System.Diagnostics.Tracing /// Only here because System.Diagnostics.EventProvider needs one more extensibility hook (when it gets a /// controller callback) /// </summary> -#if !CORECLR +#if !CORECLR [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] #endif // CORECLR internal partial class EventProvider : IDisposable @@ -78,7 +79,7 @@ namespace System.Diagnostics.Tracing private static bool m_setInformationMissing; - UnsafeNativeMethods.ManifestEtw.EtwEnableCallback m_etwCallback; // Trace Callback function + private UnsafeNativeMethods.ManifestEtw.EtwEnableCallback m_etwCallback; // Trace Callback function private long m_regHandle; // Trace Registration Handle private byte m_level; // Tracing Level private long m_anyKeywordMask; // Trace Enable Flags @@ -178,7 +179,7 @@ namespace System.Diagnostics.Tracing // Do most of the work under a lock to avoid shutdown race. - long registrationHandle = 0; + long registrationHandle = 0; lock (EventListener.EventListenersLock) { // Double check @@ -200,7 +201,6 @@ namespace System.Diagnostics.Tracing // We solve by Unregistering after releasing the EventListenerLock. if (registrationHandle != 0) EventUnregister(registrationHandle); - } /// <summary> @@ -221,7 +221,7 @@ namespace System.Diagnostics.Tracing // <UsesUnsafeCode Name="Parameter filterData of type: Void*" /> // <UsesUnsafeCode Name="Parameter callbackContext of type: Void*" /> // </SecurityKernel> - unsafe void EtwEnableCallBack( + private unsafe void EtwEnableCallBack( [In] ref System.Guid sourceId, [In] int controlCode, [In] byte setLevel, @@ -362,7 +362,6 @@ namespace System.Diagnostics.Tracing if ((idx = IndexOfSessionInList(liveSessionList, s.etwSessionId)) < 0 || (liveSessionList[idx].sessionIdBit != s.sessionIdBit)) changedSessionList.Add(Tuple.Create(s, false)); - } } // next look for sessions that were created since the last callback (or have changed) @@ -413,7 +412,7 @@ namespace System.Diagnostics.Tracing } private delegate void SessionInfoCallback(int etwSessionId, long matchAllKeywords, ref List<SessionInfo> sessionList); - + /// <summary> /// This method enumerates over all active ETW sessions that have enabled 'this.m_Guid' /// for the current process ID, calling 'action' for each session, and passing it the @@ -432,7 +431,7 @@ namespace System.Diagnostics.Tracing #if ES_SESSION_INFO || !ES_BUILD_STANDALONE int buffSize = 256; // An initial guess that probably works most of the time. byte* buffer; - for (; ; ) + for (;;) { var space = stackalloc byte[buffSize]; buffer = space; @@ -621,7 +620,6 @@ namespace System.Diagnostics.Tracing if ((level <= m_level) || (m_level == 0)) { - // // Check if Keyword is enabled // @@ -1186,7 +1184,7 @@ namespace System.Diagnostics.Tracing return UnsafeNativeMethods.ManifestEtw.EventUnregister(registrationHandle); } - static int[] nibblebits = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; + private static int[] nibblebits = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; private static int bitcount(uint n) { int count = 0; diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs index a558a1647e..3668d8cb64 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs @@ -252,7 +252,6 @@ namespace System.Diagnostics.Tracing /// </remarks> public partial class EventSource : IDisposable { - #if FEATURE_EVENTSOURCE_XPLAT private static readonly EventListener persistent_Xplat_Listener = XplatEventLogger.InitializePersistentListener(); #endif //FEATURE_EVENTSOURCE_XPLAT @@ -1160,7 +1159,6 @@ namespace System.Diagnostics.Tracing #if FEATURE_MANAGED_ETW if (m_eventData[eventId].EnabledForETW) { - #if FEATURE_ACTIVITYSAMPLING // this code should be kept in sync with WriteEventVarargs(). SessionMask etwSessions = SessionMask.All; @@ -1243,7 +1241,6 @@ namespace System.Diagnostics.Tracing m_eventData[eventId].Tags, m_eventData[eventId].Parameters); Interlocked.CompareExchange(ref m_eventData[eventId].TraceLoggingEventTypes, tlet, null); - } EventSourceOptions opt = new EventSourceOptions { @@ -1548,18 +1545,18 @@ namespace System.Diagnostics.Tracing /// </summary> public void Start() { - if (this.w == null) + if (w == null) { - this.w = new uint[85]; + w = new uint[85]; } - this.length = 0; - this.pos = 0; - this.w[80] = 0x67452301; - this.w[81] = 0xEFCDAB89; - this.w[82] = 0x98BADCFE; - this.w[83] = 0x10325476; - this.w[84] = 0xC3D2E1F0; + length = 0; + pos = 0; + w[80] = 0x67452301; + w[81] = 0xEFCDAB89; + w[82] = 0x98BADCFE; + w[83] = 0x10325476; + w[84] = 0xC3D2E1F0; } /// <summary> @@ -1568,8 +1565,8 @@ namespace System.Diagnostics.Tracing /// <param name="input">Data to include in the hash.</param> public void Append(byte input) { - this.w[this.pos / 4] = (this.w[this.pos / 4] << 8) | input; - if (64 == ++this.pos) + w[pos / 4] = (w[pos / 4] << 8) | input; + if (64 == ++pos) { this.Drain(); } @@ -1605,9 +1602,9 @@ namespace System.Diagnostics.Tracing /// </param> public void Finish(byte[] output) { - long l = this.length + 8 * this.pos; + long l = length + 8 * pos; this.Append(0x80); - while (this.pos != 56) + while (pos != 56) { this.Append(0x00); } @@ -1626,9 +1623,9 @@ namespace System.Diagnostics.Tracing int end = output.Length < 20 ? output.Length : 20; for (int i = 0; i != end; i++) { - uint temp = this.w[80 + i / 4]; + uint temp = w[80 + i / 4]; output[i] = (byte)(temp >> 24); - this.w[80 + i / 4] = temp << 8; + w[80 + i / 4] = temp << 8; } } } @@ -1640,54 +1637,54 @@ namespace System.Diagnostics.Tracing { for (int i = 16; i != 80; i++) { - this.w[i] = Rol1((this.w[i - 3] ^ this.w[i - 8] ^ this.w[i - 14] ^ this.w[i - 16])); + w[i] = Rol1((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16])); } unchecked { - uint a = this.w[80]; - uint b = this.w[81]; - uint c = this.w[82]; - uint d = this.w[83]; - uint e = this.w[84]; + uint a = w[80]; + uint b = w[81]; + uint c = w[82]; + uint d = w[83]; + uint e = w[84]; for (int i = 0; i != 20; i++) { const uint k = 0x5A827999; uint f = (b & c) | ((~b) & d); - uint temp = Rol5(a) + f + e + k + this.w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; + uint temp = Rol5(a) + f + e + k + w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; } for (int i = 20; i != 40; i++) { uint f = b ^ c ^ d; const uint k = 0x6ED9EBA1; - uint temp = Rol5(a) + f + e + k + this.w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; + uint temp = Rol5(a) + f + e + k + w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; } for (int i = 40; i != 60; i++) { uint f = (b & c) | (b & d) | (c & d); const uint k = 0x8F1BBCDC; - uint temp = Rol5(a) + f + e + k + this.w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; + uint temp = Rol5(a) + f + e + k + w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; } for (int i = 60; i != 80; i++) { uint f = b ^ c ^ d; const uint k = 0xCA62C1D6; - uint temp = Rol5(a) + f + e + k + this.w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; + uint temp = Rol5(a) + f + e + k + w[i]; e = d; d = c; c = Rol30(b); b = a; a = temp; } - this.w[80] += a; - this.w[81] += b; - this.w[82] += c; - this.w[83] += d; - this.w[84] += e; + w[80] += a; + w[81] += b; + w[82] += c; + w[83] += d; + w[84] += e; } - this.length += 512; // 64 bytes == 512 bits - this.pos = 0; + length += 512; // 64 bytes == 512 bits + pos = 0; } private static uint Rol1(uint input) @@ -1731,7 +1728,7 @@ namespace System.Diagnostics.Tracing Type dataType = GetDataType(m_eventData[eventId], parameterId); - Again: + Again: if (dataType == typeof(IntPtr)) { return *((IntPtr*)dataPointer); @@ -1843,7 +1840,6 @@ namespace System.Diagnostics.Tracing // ETW strings are NULL-terminated, so marshal everything up to the first // null in the string. return System.Runtime.InteropServices.Marshal.PtrToStringUni(dataPointer); - } finally { @@ -1995,7 +1991,6 @@ namespace System.Diagnostics.Tracing EventTags.None, m_eventData[eventId].Parameters); Interlocked.CompareExchange(ref m_eventData[eventId].TraceLoggingEventTypes, tlet, null); - } // TODO: activity ID support EventSourceOptions opt = new EventSourceOptions @@ -2387,7 +2382,6 @@ namespace System.Diagnostics.Tracing } } return true; - } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private void ThrowEventSourceException(string eventName, Exception innerEx = null) @@ -2476,7 +2470,7 @@ namespace System.Diagnostics.Tracing { public OverideEventProvider(EventSource eventSource) { - this.m_eventSource = eventSource; + m_eventSource = eventSource; } protected override void OnControllerCommand(ControllerCommand command, IDictionary<string, string> arguments, int perEventSourceSessionId, int etwSessionId) @@ -2559,7 +2553,7 @@ namespace System.Diagnostics.Tracing if (m_completelyInited) { // After the first command arrive after construction, we are ready to get rid of the deferred commands - this.m_deferredCommands = null; + m_deferredCommands = null; // We are fully initialized, do the command DoCommand(commandArgs); } @@ -2713,7 +2707,7 @@ namespace System.Diagnostics.Tracing } this.OnEventCommand(commandArgs); - var eventCommandCallback = this.m_eventCommandExecuted; + var eventCommandCallback = m_eventCommandExecuted; if (eventCommandCallback != null) eventCommandCallback(this, commandArgs); @@ -3015,7 +3009,6 @@ namespace System.Diagnostics.Tracing Debug.Assert(m_rawManifest == null); m_rawManifest = CreateManifestAndDescriptors(this.GetType(), Name, this); Debug.Assert(m_eventData != null); - } else { @@ -3093,7 +3086,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) { @@ -3467,7 +3460,6 @@ namespace System.Diagnostics.Tracing string.Compare(startEventMetadata.Name, 0, taskName, 0, taskName.Length) == 0 && string.Compare(startEventMetadata.Name, taskName.Length, s_ActivityStartSuffix, 0, Math.Max(startEventMetadata.Name.Length - taskName.Length, s_ActivityStartSuffix.Length)) == 0) { - // Make the stop event match the start event eventAttribute.Task = (EventTask)startEventMetadata.Descriptor.Task; noTask = false; @@ -3627,7 +3619,7 @@ namespace System.Diagnostics.Tracing } #endif return; - Error: + Error: manifest.ManifestError(Resources.GetResourceString("EventSource_EnumKindMismatch", staticField.Name, staticField.FieldType.Name, providerEnumKind)); } @@ -4101,7 +4093,7 @@ namespace System.Diagnostics.Tracing // We use a single instance of ActivityTracker for all EventSources instances to allow correlation between multiple event providers. // We have m_activityTracker field simply because instance field is more efficient than static field fetch. - ActivityTracker m_activityTracker; + private ActivityTracker m_activityTracker; internal const string s_ActivityStartSuffix = "Start"; internal const string s_ActivityStopSuffix = "Stop"; @@ -4627,7 +4619,6 @@ namespace System.Diagnostics.Tracing s_CreatingListener = false; } } - } // Instance fields @@ -5019,7 +5010,7 @@ namespace System.Diagnostics.Tracing { /// <summary>Construct an EventAttribute with specified eventId</summary> /// <param name="eventId">ID of the ETW event (an integer between 1 and 65535)</param> - public EventAttribute(int eventId) { this.EventId = eventId; Level = EventLevel.Informational; this.m_opcodeSet = false; } + public EventAttribute(int eventId) { this.EventId = eventId; Level = EventLevel.Informational; m_opcodeSet = false; } /// <summary>Event's ID</summary> public int EventId { get; private set; } /// <summary>Event's severity level: indicates the severity or verbosity of the event</summary> @@ -5035,8 +5026,8 @@ namespace System.Diagnostics.Tracing } set { - this.m_opcode = value; - this.m_opcodeSet = true; + m_opcode = value; + m_opcodeSet = true; } } @@ -5076,7 +5067,7 @@ namespace System.Diagnostics.Tracing public EventActivityOptions ActivityOptions { get; set; } #region private - EventOpcode m_opcode; + private EventOpcode m_opcode; private bool m_opcodeSet; #endregion } @@ -5115,7 +5106,7 @@ namespace System.Diagnostics.Tracing #if FEATURE_ADVANCED_MANAGED_ETW_CHANNELS public #endif - class EventChannelAttribute : Attribute + internal class EventChannelAttribute : Attribute { /// <summary> /// Specified whether the channel is enabled by default @@ -5155,7 +5146,7 @@ namespace System.Diagnostics.Tracing #if FEATURE_ADVANCED_MANAGED_ETW_CHANNELS public #endif - enum EventChannelType + internal enum EventChannelType { /// <summary>The admin channel</summary> Admin = 1, @@ -5566,7 +5557,7 @@ namespace System.Diagnostics.Tracing } } - #region private + #region private /// <summary> /// Creates a new ActivityFilter that is triggered by 'eventId' from 'source' ever @@ -5735,7 +5726,7 @@ namespace System.Diagnostics.Tracing ActivityFilter m_next; // We create a linked list of these Action<Guid> m_myActivityDelegate; - #endregion + #endregion }; @@ -5860,7 +5851,7 @@ namespace System.Diagnostics.Tracing public bool IsEqualOrSupersetOf(SessionMask m) { - return (this.m_mask | m.m_mask) == this.m_mask; + return (m_mask | m.m_mask) == m_mask; } public static SessionMask All @@ -6139,7 +6130,7 @@ namespace System.Diagnostics.Tracing public ulong[] GetChannelData() { - if (this.channelTab == null) + if (channelTab == null) { return new ulong[0]; } @@ -6147,7 +6138,7 @@ namespace System.Diagnostics.Tracing // We create an array indexed by the channel id for fast look up. // E.g. channelMask[Admin] will give you the bit mask for Admin channel. int maxkey = -1; - foreach (var item in this.channelTab.Keys) + foreach (var item in channelTab.Keys) { if (item > maxkey) { @@ -6156,7 +6147,7 @@ namespace System.Diagnostics.Tracing } ulong[] channelMask = new ulong[maxkey + 1]; - foreach (var item in this.channelTab) + foreach (var item in channelTab) { channelMask[item.Key] = item.Value.Keywords; } @@ -6328,7 +6319,6 @@ namespace System.Diagnostics.Tracing private string CreateManifestString() { - #if FEATURE_MANAGED_ETW_CHANNELS // Write out the channels if (channelTab != null) @@ -6396,7 +6386,6 @@ namespace System.Diagnostics.Tracing // Write out the tasks if (taskTab != null) { - sb.Append(" <tasks>").AppendLine(); var sortedTasks = new List<int>(taskTab.Keys); sortedTasks.Sort(); @@ -6840,7 +6829,7 @@ namespace System.Diagnostics.Tracing } #if FEATURE_MANAGED_ETW_CHANNELS - class ChannelInfo + private class ChannelInfo { public string Name; public ulong Keywords; @@ -6848,15 +6837,15 @@ namespace System.Diagnostics.Tracing } #endif - Dictionary<int, string> opcodeTab; - Dictionary<int, string> taskTab; + private Dictionary<int, string> opcodeTab; + private Dictionary<int, string> taskTab; #if FEATURE_MANAGED_ETW_CHANNELS - Dictionary<int, ChannelInfo> channelTab; + private Dictionary<int, ChannelInfo> channelTab; #endif - Dictionary<ulong, string> keywordTab; - Dictionary<string, Type> mapsTab; + private Dictionary<ulong, string> keywordTab; + private Dictionary<string, Type> mapsTab; - Dictionary<string, string> stringTab; // Maps unlocalized strings to localized ones + private Dictionary<string, string> stringTab; // Maps unlocalized strings to localized ones #if FEATURE_MANAGED_ETW_CHANNELS // WCF used EventSource to mimic a existing ETW manifest. To support this @@ -6865,26 +6854,26 @@ namespace System.Diagnostics.Tracing // this set of channel keywords that we allow to be explicitly set. You // can ignore these bits otherwise. internal const ulong ValidPredefinedChannelKeywords = 0xF000000000000000; - ulong nextChannelKeywordBit = 0x8000000000000000; // available Keyword bit to be used for next channel definition, grows down - const int MaxCountChannels = 8; // a manifest can defined at most 8 ETW channels + private ulong nextChannelKeywordBit = 0x8000000000000000; // available Keyword bit to be used for next channel definition, grows down + private const int MaxCountChannels = 8; // a manifest can defined at most 8 ETW channels #endif - StringBuilder sb; // Holds the provider information. - StringBuilder events; // Holds the events. - StringBuilder templates; + private StringBuilder sb; // Holds the provider information. + private StringBuilder events; // Holds the events. + private StringBuilder templates; #if FEATURE_MANAGED_ETW_CHANNELS - string providerName; + private string providerName; #endif - ResourceManager resources; // Look up localized strings here. - EventManifestOptions flags; - IList<string> errors; // list of currently encountered errors - Dictionary<string, List<int>> perEventByteArrayArgIndices; // "event_name" -> List_of_Indices_of_Byte[]_Arg + private ResourceManager resources; // Look up localized strings here. + private EventManifestOptions flags; + private IList<string> errors; // list of currently encountered errors + private Dictionary<string, List<int>> perEventByteArrayArgIndices; // "event_name" -> List_of_Indices_of_Byte[]_Arg // State we track between StartEvent and EndEvent. - string eventName; // Name of the event currently being processed. - int numParams; // keeps track of the number of args the event has. - List<int> byteArrArgIndices; // keeps track of the index of each byte[] argument + private string eventName; // Name of the event currently being processed. + private int numParams; // keeps track of the number of args the event has. + private List<int> byteArrArgIndices; // keeps track of the index of each byte[] argument #endregion } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSourceException.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSourceException.cs index 3fc9d545b8..c64c97b4df 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSourceException.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSourceException.cs @@ -27,7 +27,8 @@ namespace System.Diagnostics.Tracing /// Initializes a new instance of the EventSourceException class. /// </summary> public EventSourceException() : - base(Resources.GetResourceString("EventSource_ListenerWriteFailure")) { } + base(Resources.GetResourceString("EventSource_ListenerWriteFailure")) + { } /// <summary> /// Initializes a new instance of the EventSourceException class with a specified error message. @@ -48,6 +49,7 @@ namespace System.Diagnostics.Tracing #endif internal EventSourceException(Exception innerException) : - base(Resources.GetResourceString("EventSource_ListenerWriteFailure"), innerException) { } + base(Resources.GetResourceString("EventSource_ListenerWriteFailure"), innerException) + { } } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs index 0a689efe92..71c421231e 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs @@ -130,10 +130,10 @@ namespace System.Diagnostics.Tracing { return Environment.GetResourceString(key, args); } - + private static readonly bool m_EventSourcePreventRecursion = false; } - + internal partial class ManifestBuilder { private string GetTypeNameHelper(Type type) @@ -174,13 +174,13 @@ namespace System.Diagnostics.Tracing return "win:Pointer"; else if ((type.IsArray || type.IsPointer) && type.GetElementType() == typeof(byte)) return "win:Binary"; - + ManifestError(Resources.GetResourceString("EventSource_UnsupportedEventTypeInManifest", type.Name), true); return string.Empty; } } } - + internal partial class EventProvider { internal unsafe int SetInformation( @@ -197,7 +197,7 @@ namespace System.Diagnostics.Tracing status = UnsafeNativeMethods.ManifestEtw.EventSetInformation( m_regHandle, eventInfoClass, - (void *)data, + (void*)data, (int)dataSize); } catch (TypeLoadException) @@ -209,7 +209,7 @@ namespace System.Diagnostics.Tracing return status; } } - + internal static class Resources { internal static string GetResourceString(string key, params object[] args) diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs index 80c524b350..d746f58f24 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs @@ -8,6 +8,7 @@ // // Managed event source for things that can version with MSCORLIB. // + using System; using System.Collections.Generic; using System.Globalization; @@ -15,8 +16,8 @@ using System.Reflection; using System.Text; using System.Runtime.CompilerServices; -namespace System.Diagnostics.Tracing { - +namespace System.Diagnostics.Tracing +{ // To use the framework provider // // \\clrmain\tools\Perfmonitor /nokernel /noclr /provider:8E9F5090-2D75-4d03-8A81-E5AFBF85DAF1 start @@ -28,7 +29,8 @@ namespace System.Diagnostics.Tracing { // [FriendAccessAllowed] [EventSource(Guid = "8E9F5090-2D75-4d03-8A81-E5AFBF85DAF1", Name = "System.Diagnostics.Eventing.FrameworkEventSource")] - sealed internal class FrameworkEventSource : EventSource { + sealed internal class FrameworkEventSource : EventSource + { // Defines the singleton instance for the Resources ETW provider public static readonly FrameworkEventSource Log = new FrameworkEventSource(); @@ -36,16 +38,17 @@ namespace System.Diagnostics.Tracing { // Often each task has a keyword, but where tasks are determined by subsystem, keywords are determined by // usefulness to end users to filter. Generally users don't mind extra events if they are not high volume // so grouping low volume events together in a single keywords is OK (users can post-filter by task if desired) - public static class Keywords { - public const EventKeywords Loader = (EventKeywords)0x0001; // This is bit 0 - public const EventKeywords ThreadPool = (EventKeywords)0x0002; - public const EventKeywords NetClient = (EventKeywords)0x0004; + public static class Keywords + { + public const EventKeywords Loader = (EventKeywords)0x0001; // This is bit 0 + public const EventKeywords ThreadPool = (EventKeywords)0x0002; + public const EventKeywords NetClient = (EventKeywords)0x0004; // // This is a private event we do not want to expose to customers. It is to be used for profiling // uses of dynamic type loading by ProjectN applications running on the desktop CLR // public const EventKeywords DynamicTypeUsage = (EventKeywords)0x0008; - public const EventKeywords ThreadTransfer = (EventKeywords)0x0010; + public const EventKeywords ThreadTransfer = (EventKeywords)0x0010; } /// <summary>ETW tasks that have start/stop events.</summary> @@ -53,7 +56,7 @@ namespace System.Diagnostics.Tracing { public static class Tasks // this name is important for EventSource { /// <summary>Begin / End - GetResponse.</summary> - public const EventTask GetResponse = (EventTask)1; + public const EventTask GetResponse = (EventTask)1; /// <summary>Begin / End - GetRequestStream</summary> public const EventTask GetRequestStream = (EventTask)2; /// <summary>Send / Receive - begin transfer/end transfer</summary> @@ -211,18 +214,21 @@ namespace System.Diagnostics.Tracing { // ResourceManager Event Definitions [Event(1, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerLookupStarted(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerLookupStarted(String baseName, String mainAssemblyName, String cultureName) + { WriteEvent(1, baseName, mainAssemblyName, cultureName); } [Event(2, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerLookingForResourceSet(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerLookingForResourceSet(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(2, baseName, mainAssemblyName, cultureName); } [Event(3, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerFoundResourceSetInCache(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerFoundResourceSetInCache(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(3, baseName, mainAssemblyName, cultureName); } @@ -231,119 +237,138 @@ namespace System.Diagnostics.Tracing { // the cache. This can happen if you have an assembly load callback that called into this // instance of the ResourceManager. [Event(4, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(4, baseName, mainAssemblyName, cultureName); } // manifest resource stream lookup succeeded [Event(5, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerStreamFound(String baseName, String mainAssemblyName, String cultureName, String loadedAssemblyName, String resourceFileName) { + public void ResourceManagerStreamFound(String baseName, String mainAssemblyName, String cultureName, String loadedAssemblyName, String resourceFileName) + { if (IsEnabled()) WriteEvent(5, baseName, mainAssemblyName, cultureName, loadedAssemblyName, resourceFileName); } // manifest resource stream lookup failed [Event(6, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerStreamNotFound(String baseName, String mainAssemblyName, String cultureName, String loadedAssemblyName, String resourceFileName) { + public void ResourceManagerStreamNotFound(String baseName, String mainAssemblyName, String cultureName, String loadedAssemblyName, String resourceFileName) + { if (IsEnabled()) WriteEvent(6, baseName, mainAssemblyName, cultureName, loadedAssemblyName, resourceFileName); } [Event(7, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerGetSatelliteAssemblySucceeded(String baseName, String mainAssemblyName, String cultureName, String assemblyName) { + public void ResourceManagerGetSatelliteAssemblySucceeded(String baseName, String mainAssemblyName, String cultureName, String assemblyName) + { if (IsEnabled()) WriteEvent(7, baseName, mainAssemblyName, cultureName, assemblyName); } [Event(8, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerGetSatelliteAssemblyFailed(String baseName, String mainAssemblyName, String cultureName, String assemblyName) { + public void ResourceManagerGetSatelliteAssemblyFailed(String baseName, String mainAssemblyName, String cultureName, String assemblyName) + { if (IsEnabled()) WriteEvent(8, baseName, mainAssemblyName, cultureName, assemblyName); } [Event(9, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(String baseName, String mainAssemblyName, String assemblyName, String resourceFileName) { + public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(String baseName, String mainAssemblyName, String assemblyName, String resourceFileName) + { if (IsEnabled()) WriteEvent(9, baseName, mainAssemblyName, assemblyName, resourceFileName); } [Event(10, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String baseName, String mainAssemblyName, String assemblyName, String resourceFileName) { + public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String baseName, String mainAssemblyName, String assemblyName, String resourceFileName) + { if (IsEnabled()) WriteEvent(10, baseName, mainAssemblyName, assemblyName, resourceFileName); } // Could not access the manifest resource the assembly [Event(11, Level = EventLevel.Error, Keywords = Keywords.Loader)] - public void ResourceManagerManifestResourceAccessDenied(String baseName, String mainAssemblyName, String assemblyName, String canonicalName) { + public void ResourceManagerManifestResourceAccessDenied(String baseName, String mainAssemblyName, String assemblyName, String canonicalName) + { if (IsEnabled()) WriteEvent(11, baseName, mainAssemblyName, assemblyName, canonicalName); } // Neutral resources are sufficient for this culture. Skipping satellites [Event(12, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourcesSufficient(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerNeutralResourcesSufficient(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(12, baseName, mainAssemblyName, cultureName); } [Event(13, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourceAttributeMissing(String mainAssemblyName) { + public void ResourceManagerNeutralResourceAttributeMissing(String mainAssemblyName) + { if (IsEnabled()) WriteEvent(13, mainAssemblyName); } [Event(14, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCreatingResourceSet(String baseName, String mainAssemblyName, String cultureName, String fileName) { + public void ResourceManagerCreatingResourceSet(String baseName, String mainAssemblyName, String cultureName, String fileName) + { if (IsEnabled()) WriteEvent(14, baseName, mainAssemblyName, cultureName, fileName); } [Event(15, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerNotCreatingResourceSet(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerNotCreatingResourceSet(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(15, baseName, mainAssemblyName, cultureName); } [Event(16, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerLookupFailed(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerLookupFailed(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(16, baseName, mainAssemblyName, cultureName); } [Event(17, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerReleasingResources(String baseName, String mainAssemblyName) { + public void ResourceManagerReleasingResources(String baseName, String mainAssemblyName) + { if (IsEnabled()) WriteEvent(17, baseName, mainAssemblyName); } [Event(18, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourcesNotFound(String baseName, String mainAssemblyName, String resName) { + public void ResourceManagerNeutralResourcesNotFound(String baseName, String mainAssemblyName, String resName) + { if (IsEnabled()) WriteEvent(18, baseName, mainAssemblyName, resName); } [Event(19, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourcesFound(String baseName, String mainAssemblyName, String resName) { + public void ResourceManagerNeutralResourcesFound(String baseName, String mainAssemblyName, String resName) + { if (IsEnabled()) WriteEvent(19, baseName, mainAssemblyName, resName); } [Event(20, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerAddingCultureFromConfigFile(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerAddingCultureFromConfigFile(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(20, baseName, mainAssemblyName, cultureName); } [Event(21, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCultureNotFoundInConfigFile(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerCultureNotFoundInConfigFile(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(21, baseName, mainAssemblyName, cultureName); } [Event(22, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCultureFoundInConfigFile(String baseName, String mainAssemblyName, String cultureName) { + public void ResourceManagerCultureFoundInConfigFile(String baseName, String mainAssemblyName, String cultureName) + { if (IsEnabled()) WriteEvent(22, baseName, mainAssemblyName, cultureName); } @@ -352,159 +377,185 @@ namespace System.Diagnostics.Tracing { // ResourceManager Event Wrappers [NonEvent] - public void ResourceManagerLookupStarted(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerLookupStarted(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerLookupStarted(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerLookingForResourceSet(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerLookingForResourceSet(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerLookingForResourceSet(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerFoundResourceSetInCache(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerFoundResourceSetInCache(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerFoundResourceSetInCache(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerFoundResourceSetInCacheUnexpected(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerStreamFound(String baseName, Assembly mainAssembly, String cultureName, Assembly loadedAssembly, String resourceFileName) { + public void ResourceManagerStreamFound(String baseName, Assembly mainAssembly, String cultureName, Assembly loadedAssembly, String resourceFileName) + { if (IsEnabled()) ResourceManagerStreamFound(baseName, GetName(mainAssembly), cultureName, GetName(loadedAssembly), resourceFileName); } [NonEvent] - public void ResourceManagerStreamNotFound(String baseName, Assembly mainAssembly, String cultureName, Assembly loadedAssembly, String resourceFileName) { + public void ResourceManagerStreamNotFound(String baseName, Assembly mainAssembly, String cultureName, Assembly loadedAssembly, String resourceFileName) + { if (IsEnabled()) ResourceManagerStreamNotFound(baseName, GetName(mainAssembly), cultureName, GetName(loadedAssembly), resourceFileName); } [NonEvent] - public void ResourceManagerGetSatelliteAssemblySucceeded(String baseName, Assembly mainAssembly, String cultureName, String assemblyName) { + public void ResourceManagerGetSatelliteAssemblySucceeded(String baseName, Assembly mainAssembly, String cultureName, String assemblyName) + { if (IsEnabled()) ResourceManagerGetSatelliteAssemblySucceeded(baseName, GetName(mainAssembly), cultureName, assemblyName); } [NonEvent] - public void ResourceManagerGetSatelliteAssemblyFailed(String baseName, Assembly mainAssembly, String cultureName, String assemblyName) { + public void ResourceManagerGetSatelliteAssemblyFailed(String baseName, Assembly mainAssembly, String cultureName, String assemblyName) + { if (IsEnabled()) ResourceManagerGetSatelliteAssemblyFailed(baseName, GetName(mainAssembly), cultureName, assemblyName); } [NonEvent] - public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(String baseName, Assembly mainAssembly, String assemblyName, String resourceFileName) { + public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(String baseName, Assembly mainAssembly, String assemblyName, String resourceFileName) + { if (IsEnabled()) ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(baseName, GetName(mainAssembly), assemblyName, resourceFileName); } [NonEvent] - public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String baseName, Assembly mainAssembly, String assemblyName, String resourceFileName) { + public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String baseName, Assembly mainAssembly, String assemblyName, String resourceFileName) + { if (IsEnabled()) ResourceManagerCaseInsensitiveResourceStreamLookupFailed(baseName, GetName(mainAssembly), assemblyName, resourceFileName); } [NonEvent] - public void ResourceManagerManifestResourceAccessDenied(String baseName, Assembly mainAssembly, String assemblyName, String canonicalName) { + public void ResourceManagerManifestResourceAccessDenied(String baseName, Assembly mainAssembly, String assemblyName, String canonicalName) + { if (IsEnabled()) ResourceManagerManifestResourceAccessDenied(baseName, GetName(mainAssembly), assemblyName, canonicalName); } [NonEvent] - public void ResourceManagerNeutralResourcesSufficient(String baseName, Assembly mainAssembly, String cultureName) { - if (IsEnabled()) + public void ResourceManagerNeutralResourcesSufficient(String baseName, Assembly mainAssembly, String cultureName) + { + if (IsEnabled()) ResourceManagerNeutralResourcesSufficient(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerNeutralResourceAttributeMissing(Assembly mainAssembly) { + public void ResourceManagerNeutralResourceAttributeMissing(Assembly mainAssembly) + { if (IsEnabled()) ResourceManagerNeutralResourceAttributeMissing(GetName(mainAssembly)); } [NonEvent] - public void ResourceManagerCreatingResourceSet(String baseName, Assembly mainAssembly, String cultureName, String fileName) { + public void ResourceManagerCreatingResourceSet(String baseName, Assembly mainAssembly, String cultureName, String fileName) + { if (IsEnabled()) ResourceManagerCreatingResourceSet(baseName, GetName(mainAssembly), cultureName, fileName); } [NonEvent] - public void ResourceManagerNotCreatingResourceSet(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerNotCreatingResourceSet(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerNotCreatingResourceSet(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerLookupFailed(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerLookupFailed(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerLookupFailed(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerReleasingResources(String baseName, Assembly mainAssembly) { + public void ResourceManagerReleasingResources(String baseName, Assembly mainAssembly) + { if (IsEnabled()) ResourceManagerReleasingResources(baseName, GetName(mainAssembly)); } [NonEvent] - public void ResourceManagerNeutralResourcesNotFound(String baseName, Assembly mainAssembly, String resName) { + public void ResourceManagerNeutralResourcesNotFound(String baseName, Assembly mainAssembly, String resName) + { if (IsEnabled()) ResourceManagerNeutralResourcesNotFound(baseName, GetName(mainAssembly), resName); } [NonEvent] - public void ResourceManagerNeutralResourcesFound(String baseName, Assembly mainAssembly, String resName) { + public void ResourceManagerNeutralResourcesFound(String baseName, Assembly mainAssembly, String resName) + { if (IsEnabled()) ResourceManagerNeutralResourcesFound(baseName, GetName(mainAssembly), resName); } [NonEvent] - public void ResourceManagerAddingCultureFromConfigFile(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerAddingCultureFromConfigFile(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerAddingCultureFromConfigFile(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerCultureNotFoundInConfigFile(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerCultureNotFoundInConfigFile(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerCultureNotFoundInConfigFile(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerCultureFoundInConfigFile(String baseName, Assembly mainAssembly, String cultureName) { + public void ResourceManagerCultureFoundInConfigFile(String baseName, Assembly mainAssembly, String cultureName) + { if (IsEnabled()) ResourceManagerCultureFoundInConfigFile(baseName, GetName(mainAssembly), cultureName); } - private static string GetName(Assembly assembly) { + private static string GetName(Assembly assembly) + { if (assembly == null) return "<<NULL>>"; else return assembly.FullName; } - [Event(30, Level = EventLevel.Verbose, Keywords = Keywords.ThreadPool|Keywords.ThreadTransfer)] - public void ThreadPoolEnqueueWork(long workID) { + [Event(30, Level = EventLevel.Verbose, Keywords = Keywords.ThreadPool | Keywords.ThreadTransfer)] + public void ThreadPoolEnqueueWork(long workID) + { WriteEvent(30, workID); } [NonEvent] #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void ThreadPoolEnqueueWorkObject(object workID) { + public unsafe void ThreadPoolEnqueueWorkObject(object workID) + { // convert the Object Id to a long - ThreadPoolEnqueueWork((long) *((void**) JitHelpers.UnsafeCastToStackPointer(ref workID))); + ThreadPoolEnqueueWork((long)*((void**)JitHelpers.UnsafeCastToStackPointer(ref workID))); } - [Event(31, Level = EventLevel.Verbose, Keywords = Keywords.ThreadPool|Keywords.ThreadTransfer)] - public void ThreadPoolDequeueWork(long workID) { + [Event(31, Level = EventLevel.Verbose, Keywords = Keywords.ThreadPool | Keywords.ThreadTransfer)] + public void ThreadPoolDequeueWork(long workID) + { WriteEvent(31, workID); } @@ -512,36 +563,41 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void ThreadPoolDequeueWorkObject(object workID) { + public unsafe void ThreadPoolDequeueWorkObject(object workID) + { // convert the Object Id to a long - ThreadPoolDequeueWork((long) *((void**) JitHelpers.UnsafeCastToStackPointer(ref workID))); + ThreadPoolDequeueWork((long)*((void**)JitHelpers.UnsafeCastToStackPointer(ref workID))); } // In the desktop runtime they don't use Tasks for the point at which the response happens, which means that the // Activity ID created by start using implicit activity IDs does not match. Thus disable implicit activities (until we fix that) - [Event(140, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions=EventActivityOptions.Disable, + [Event(140, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions = EventActivityOptions.Disable, Task = Tasks.GetResponse, Opcode = EventOpcode.Start, Version = 1)] - private void GetResponseStart(long id, string uri, bool success, bool synchronous) { + private void GetResponseStart(long id, string uri, bool success, bool synchronous) + { WriteEvent(140, id, uri, success, synchronous); } - [Event(141, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions=EventActivityOptions.Disable, + [Event(141, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions = EventActivityOptions.Disable, Task = Tasks.GetResponse, Opcode = EventOpcode.Stop, Version = 1)] - private void GetResponseStop(long id, bool success, bool synchronous, int statusCode) { + private void GetResponseStop(long id, bool success, bool synchronous, int statusCode) + { WriteEvent(141, id, success, synchronous, statusCode); } // In the desktop runtime they don't use Tasks for the point at which the response happens, which means that the // Activity ID created by start using implicit activity IDs does not match. Thus disable implicit activities (until we fix that) - [Event(142, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions=EventActivityOptions.Disable, + [Event(142, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions = EventActivityOptions.Disable, Task = Tasks.GetRequestStream, Opcode = EventOpcode.Start, Version = 1)] - private void GetRequestStreamStart(long id, string uri, bool success, bool synchronous) { + private void GetRequestStreamStart(long id, string uri, bool success, bool synchronous) + { WriteEvent(142, id, uri, success, synchronous); } - [Event(143, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions=EventActivityOptions.Disable, + [Event(143, Level = EventLevel.Informational, Keywords = Keywords.NetClient, ActivityOptions = EventActivityOptions.Disable, Task = Tasks.GetRequestStream, Opcode = EventOpcode.Stop, Version = 1)] - private void GetRequestStreamStop(long id, bool success, bool synchronous) { + private void GetRequestStreamStop(long id, bool success, bool synchronous) + { WriteEvent(143, id, success, synchronous); } @@ -549,16 +605,18 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void BeginGetResponse(object id, string uri, bool success, bool synchronous) { + public unsafe void BeginGetResponse(object id, string uri, bool success, bool synchronous) + { if (IsEnabled()) GetResponseStart(IdForObject(id), uri, success, synchronous); } - + [NonEvent] #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void EndGetResponse(object id, bool success, bool synchronous, int statusCode) { + public unsafe void EndGetResponse(object id, bool success, bool synchronous, int statusCode) + { if (IsEnabled()) GetResponseStop(IdForObject(id), success, synchronous, statusCode); } @@ -567,7 +625,8 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void BeginGetRequestStream(object id, string uri, bool success, bool synchronous) { + public unsafe void BeginGetRequestStream(object id, string uri, bool success, bool synchronous) + { if (IsEnabled()) GetRequestStreamStart(IdForObject(id), uri, success, synchronous); } @@ -576,7 +635,8 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void EndGetRequestStream(object id, bool success, bool synchronous) { + public unsafe void EndGetRequestStream(object id, bool success, bool synchronous) + { if (IsEnabled()) GetRequestStreamStop(IdForObject(id), success, synchronous); } @@ -589,7 +649,8 @@ namespace System.Diagnostics.Tracing { // 3 - WinRT dispatch operations // info - any additional information user code might consider interesting [Event(150, Level = EventLevel.Informational, Keywords = Keywords.ThreadTransfer, Task = Tasks.ThreadTransfer, Opcode = EventOpcode.Send)] - public void ThreadTransferSend(long id, int kind, string info, bool multiDequeues) { + public void ThreadTransferSend(long id, int kind, string info, bool multiDequeues) + { if (IsEnabled()) WriteEvent(150, id, kind, info, multiDequeues); } @@ -600,8 +661,9 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void ThreadTransferSendObj(object id, int kind, string info, bool multiDequeues) { - ThreadTransferSend((long) *((void**) JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info, multiDequeues); + public unsafe void ThreadTransferSendObj(object id, int kind, string info, bool multiDequeues) + { + ThreadTransferSend((long)*((void**)JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info, multiDequeues); } // id - represents a correlation ID that allows correlation of two activities, one stamped by @@ -612,7 +674,8 @@ namespace System.Diagnostics.Tracing { // 3 - WinRT dispatch operations // info - any additional information user code might consider interesting [Event(151, Level = EventLevel.Informational, Keywords = Keywords.ThreadTransfer, Task = Tasks.ThreadTransfer, Opcode = EventOpcode.Receive)] - public void ThreadTransferReceive(long id, int kind, string info) { + public void ThreadTransferReceive(long id, int kind, string info) + { if (IsEnabled()) WriteEvent(151, id, kind, info); } @@ -623,8 +686,9 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void ThreadTransferReceiveObj(object id, int kind, string info) { - ThreadTransferReceive((long) *((void**) JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info); + public unsafe void ThreadTransferReceiveObj(object id, int kind, string info) + { + ThreadTransferReceive((long)*((void**)JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info); } // id - represents a correlation ID that allows correlation of two activities, one stamped by @@ -635,7 +699,8 @@ namespace System.Diagnostics.Tracing { // 3 - WinRT dispatch operations // info - any additional information user code might consider interesting [Event(152, Level = EventLevel.Informational, Keywords = Keywords.ThreadTransfer, Task = Tasks.ThreadTransfer, Opcode = Opcodes.ReceiveHandled)] - public void ThreadTransferReceiveHandled(long id, int kind, string info) { + public void ThreadTransferReceiveHandled(long id, int kind, string info) + { if (IsEnabled()) WriteEvent(152, id, kind, info); } @@ -646,15 +711,17 @@ namespace System.Diagnostics.Tracing { #if !CORECLR [System.Security.SecuritySafeCritical] #endif // !CORECLR - public unsafe void ThreadTransferReceiveHandledObj(object id, int kind, string info) { - ThreadTransferReceive((long) *((void**) JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info); + public unsafe void ThreadTransferReceiveHandledObj(object id, int kind, string info) + { + ThreadTransferReceive((long)*((void**)JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info); } // return a stable ID for a an object. We use the hash code which is not truely unique but is // close enough for now at least. we add to it 0x7FFFFFFF00000000 to make it distinguishable // from the style of ID that simply casts the object reference to a long (since old versions of the // runtime will emit IDs of that form). - private static long IdForObject(object obj) { + private static long IdForObject(object obj) + { return obj.GetHashCode() + 0x7FFFFFFF00000000; } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/StubEnvironment.cs b/src/mscorlib/src/System/Diagnostics/Eventing/StubEnvironment.cs index e090c4f106..7b6491094b 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/StubEnvironment.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/StubEnvironment.cs @@ -31,7 +31,7 @@ namespace System.Diagnostics.Tracing.Internal return string.Format(fmt, args); string sargs = String.Empty; - foreach(var arg in args) + foreach (var arg in args) { if (sargs != String.Empty) sargs += ", "; @@ -196,7 +196,7 @@ namespace Microsoft.Reflection String = 18, // Unicode character string } #endif - static class ReflectionExtensions + internal static class ReflectionExtensions { #if (!ES_BUILD_PCL && !PROJECTN) diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ArrayTypeInfo.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ArrayTypeInfo.cs index 5771354f67..f5abd471a4 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ArrayTypeInfo.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ArrayTypeInfo.cs @@ -27,7 +27,7 @@ namespace System.Diagnostics.Tracing EventFieldFormat format) { collector.BeginBufferedArray(); - this.elementInfo.WriteMetadata(collector, name, format); + elementInfo.WriteMetadata(collector, name, format); collector.EndBufferedArray(); } @@ -42,7 +42,7 @@ namespace System.Diagnostics.Tracing count = array.Length; for (int i = 0; i < array.Length; i++) { - this.elementInfo.WriteData(collector, elementInfo.PropertyValueFactory(array.GetValue(i))); + elementInfo.WriteData(collector, elementInfo.PropertyValueFactory(array.GetValue(i))); } } @@ -55,7 +55,7 @@ namespace System.Diagnostics.Tracing var serializedArray = new object[array.Length]; for (int i = 0; i < array.Length; i++) { - serializedArray[i] = this.elementInfo.GetData(array.GetValue(i)); + serializedArray[i] = elementInfo.GetData(array.GetValue(i)); } return serializedArray; } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ConcurrentSet.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ConcurrentSet.cs index 76c01c6c06..eb55c8cf33 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ConcurrentSet.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/ConcurrentSet.cs @@ -31,7 +31,7 @@ namespace System.Diagnostics.Tracing public ItemType TryGet(KeyType key) { ItemType item; - var oldItems = this.items; + var oldItems = items; if (oldItems != null) { @@ -69,7 +69,7 @@ namespace System.Diagnostics.Tracing public ItemType GetOrAdd(ItemType newItem) { ItemType item; - var oldItems = this.items; + var oldItems = items; ItemType[] newItems; Retry: @@ -110,7 +110,7 @@ namespace System.Diagnostics.Tracing Array.Copy(oldItems, lo, newItems, lo + 1, oldLength - lo); } - newItems = Interlocked.CompareExchange(ref this.items, newItems, oldItems); + newItems = Interlocked.CompareExchange(ref items, newItems, oldItems); if (oldItems != newItems) { oldItems = newItems; diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs index 079d7f480b..f3983ed2d9 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs @@ -47,14 +47,14 @@ namespace System.Diagnostics.Tracing GCHandle* pins, int pinCount) { - this.datasStart = datas; - this.scratchEnd = scratch + scratchSize; - this.datasEnd = datas + dataCount; - this.pinsEnd = pins + pinCount; + datasStart = datas; + scratchEnd = scratch + scratchSize; + datasEnd = datas + dataCount; + pinsEnd = pins + pinCount; this.scratch = scratch; this.datas = datas; this.pins = pins; - this.writingScalars = false; + writingScalars = false; } internal void Disable() @@ -73,23 +73,23 @@ namespace System.Diagnostics.Tracing internal EventSource.EventData* Finish() { this.ScalarsEnd(); - return this.datas; + return datas; } internal void AddScalar(void* value, int size) { var pb = (byte*)value; - if (this.bufferNesting == 0) + if (bufferNesting == 0) { - var scratchOld = this.scratch; + var scratchOld = scratch; var scratchNew = scratchOld + size; - if (this.scratchEnd < scratchNew) + if (scratchEnd < scratchNew) { throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_AddScalarOutOfRange")); } this.ScalarsBegin(); - this.scratch = scratchNew; + scratch = scratchNew; for (int i = 0; i != size; i++) { @@ -98,12 +98,12 @@ namespace System.Diagnostics.Tracing } else { - var oldPos = this.bufferPos; - this.bufferPos = checked(this.bufferPos + size); + var oldPos = bufferPos; + bufferPos = checked(bufferPos + size); this.EnsureBuffer(); for (int i = 0; i != size; i++, oldPos++) { - this.buffer[oldPos] = pb[i]; + buffer[oldPos] = pb[i]; } } } @@ -115,7 +115,7 @@ namespace System.Diagnostics.Tracing size = ushort.MaxValue - 1; } - if (this.bufferNesting != 0) + if (bufferNesting != 0) { this.EnsureBuffer(size + 2); } @@ -124,19 +124,19 @@ namespace System.Diagnostics.Tracing if (size != 0) { - if (this.bufferNesting == 0) + if (bufferNesting == 0) { this.ScalarsEnd(); this.PinArray(value, size); } else { - var oldPos = this.bufferPos; - this.bufferPos = checked(this.bufferPos + size); + var oldPos = bufferPos; + bufferPos = checked(bufferPos + size); this.EnsureBuffer(); fixed (void* p = value) { - Marshal.Copy((IntPtr)p, this.buffer, oldPos, size); + Marshal.Copy((IntPtr)p, buffer, oldPos, size); } } } @@ -155,7 +155,7 @@ namespace System.Diagnostics.Tracing } var size = length * itemSize; - if (this.bufferNesting != 0) + if (bufferNesting != 0) { this.EnsureBuffer(size + 2); } @@ -164,17 +164,17 @@ namespace System.Diagnostics.Tracing if (length != 0) { - if (this.bufferNesting == 0) + if (bufferNesting == 0) { this.ScalarsEnd(); this.PinArray(value, size); } else { - var oldPos = this.bufferPos; - this.bufferPos = checked(this.bufferPos + size); + var oldPos = bufferPos; + bufferPos = checked(bufferPos + size); this.EnsureBuffer(); - Buffer.BlockCopy(value, 0, this.buffer, oldPos, size); + Buffer.BlockCopy(value, 0, buffer, oldPos, size); } } } @@ -186,8 +186,8 @@ namespace System.Diagnostics.Tracing internal int BeginBufferedArray() { this.BeginBuffered(); - this.bufferPos += 2; // Reserve space for the array length (filled in by EndEnumerable) - return this.bufferPos; + bufferPos += 2; // Reserve space for the array length (filled in by EndEnumerable) + return bufferPos; } /// <summary> @@ -198,8 +198,8 @@ namespace System.Diagnostics.Tracing internal void EndBufferedArray(int bookmark, int count) { this.EnsureBuffer(); - this.buffer[bookmark - 2] = unchecked((byte)count); - this.buffer[bookmark - 1] = unchecked((byte)(count >> 8)); + buffer[bookmark - 2] = unchecked((byte)count); + buffer[bookmark - 1] = unchecked((byte)(count >> 8)); this.EndBuffered(); } @@ -209,7 +209,7 @@ namespace System.Diagnostics.Tracing internal void BeginBuffered() { this.ScalarsEnd(); - this.bufferNesting += 1; + bufferNesting += 1; } /// <summary> @@ -217,9 +217,9 @@ namespace System.Diagnostics.Tracing /// </summary> internal void EndBuffered() { - this.bufferNesting -= 1; + bufferNesting -= 1; - if (this.bufferNesting == 0) + if (bufferNesting == 0) { /* TODO (perf): consider coalescing adjacent buffered regions into a @@ -230,16 +230,16 @@ namespace System.Diagnostics.Tracing */ this.EnsureBuffer(); - this.PinArray(this.buffer, this.bufferPos); - this.buffer = null; - this.bufferPos = 0; + this.PinArray(buffer, bufferPos); + buffer = null; + bufferPos = 0; } } private void EnsureBuffer() { - var required = this.bufferPos; - if (this.buffer == null || this.buffer.Length < required) + var required = bufferPos; + if (buffer == null || buffer.Length < required) { this.GrowBuffer(required); } @@ -247,8 +247,8 @@ namespace System.Diagnostics.Tracing private void EnsureBuffer(int additionalSize) { - var required = this.bufferPos + additionalSize; - if (this.buffer == null || this.buffer.Length < required) + var required = bufferPos + additionalSize; + if (buffer == null || buffer.Length < required) { this.GrowBuffer(required); } @@ -256,7 +256,7 @@ namespace System.Diagnostics.Tracing private void GrowBuffer(int required) { - var newSize = this.buffer == null ? 64 : this.buffer.Length; + var newSize = buffer == null ? 64 : buffer.Length; do { @@ -264,25 +264,25 @@ namespace System.Diagnostics.Tracing } while (newSize < required); - Array.Resize(ref this.buffer, newSize); + Array.Resize(ref buffer, newSize); } private void PinArray(object value, int size) { - var pinsTemp = this.pins; - if (this.pinsEnd <= pinsTemp) + var pinsTemp = pins; + if (pinsEnd <= pinsTemp) { throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_PinArrayOutOfRange")); } - var datasTemp = this.datas; - if (this.datasEnd <= datasTemp) + var datasTemp = datas; + if (datasEnd <= datasTemp) { throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_DataDescriptorsOutOfRange")); } - this.pins = pinsTemp + 1; - this.datas = datasTemp + 1; + pins = pinsTemp + 1; + datas = datasTemp + 1; *pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned); datasTemp->m_Ptr = (long)(ulong)(UIntPtr)(void*)pinsTemp->AddrOfPinnedObject(); @@ -291,27 +291,27 @@ namespace System.Diagnostics.Tracing private void ScalarsBegin() { - if (!this.writingScalars) + if (!writingScalars) { - var datasTemp = this.datas; - if (this.datasEnd <= datasTemp) + var datasTemp = datas; + if (datasEnd <= datasTemp) { throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_DataDescriptorsOutOfRange")); } - datasTemp->m_Ptr = (long)(ulong)(UIntPtr)this.scratch; - this.writingScalars = true; + datasTemp->m_Ptr = (long)(ulong)(UIntPtr)scratch; + writingScalars = true; } } private void ScalarsEnd() { - if (this.writingScalars) + if (writingScalars) { - var datasTemp = this.datas; - datasTemp->m_Size = checked((int)(this.scratch - (byte*)datasTemp->m_Ptr)); - this.datas = datasTemp + 1; - this.writingScalars = false; + var datasTemp = datas; + datasTemp->m_Size = checked((int)(scratch - (byte*)datasTemp->m_Ptr)); + datas = datasTemp + 1; + writingScalars = false; } } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EnumerableTypeInfo.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EnumerableTypeInfo.cs index 74a3fa27b2..f8bd90f3bd 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EnumerableTypeInfo.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EnumerableTypeInfo.cs @@ -28,7 +28,7 @@ namespace System.Diagnostics.Tracing EventFieldFormat format) { collector.BeginBufferedArray(); - this.elementInfo.WriteMetadata(collector, name, format); + elementInfo.WriteMetadata(collector, name, format); collector.EndBufferedArray(); } @@ -42,7 +42,7 @@ namespace System.Diagnostics.Tracing { foreach (var element in enumerable) { - this.elementInfo.WriteData(collector, elementInfo.PropertyValueFactory(element)); + elementInfo.WriteData(collector, elementInfo.PropertyValueFactory(element)); count++; } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventDataAttribute.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventDataAttribute.cs index cdedf13c64..8707f22bf7 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventDataAttribute.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventDataAttribute.cs @@ -81,8 +81,8 @@ namespace System.Diagnostics.Tracing /// </summary> internal EventLevel Level { - get { return this.level; } - set { this.level = value; } + get { return level; } + set { level = value; } } /// <summary> @@ -107,8 +107,8 @@ namespace System.Diagnostics.Tracing /// </summary> internal EventOpcode Opcode { - get { return this.opcode; } - set { this.opcode = value; } + get { return opcode; } + set { opcode = value; } } /// <summary> diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs index 5967ad6ab5..568bfeaadd 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs @@ -25,7 +25,7 @@ namespace System.Diagnostics.Tracing /// </summary> internal class EventPayload : IDictionary<string, object> { - internal EventPayload(List<string> payloadNames, List<object> payloadValues) + internal EventPayload(List<string> payloadNames, List<object> payloadValues) { Debug.Assert(payloadNames.Count == payloadValues.Count); @@ -44,8 +44,8 @@ namespace System.Diagnostics.Tracing throw new System.ArgumentNullException(nameof(key)); int position = 0; - foreach(var name in m_names) - { + foreach (var name in m_names) + { if (name == key) { return m_values[position]; @@ -102,7 +102,7 @@ namespace System.Diagnostics.Tracing { for (int i = 0; i < Keys.Count; i++) { - yield return new KeyValuePair<string, object>(this.m_names[i], this.m_values[i]); + yield return new KeyValuePair<string, object>(m_names[i], m_values[i]); } } @@ -116,7 +116,7 @@ namespace System.Diagnostics.Tracing { throw new System.NotSupportedException(); } - + public bool Remove(string key) { throw new System.NotSupportedException(); @@ -126,7 +126,7 @@ namespace System.Diagnostics.Tracing { throw new System.NotSupportedException(); } - + public bool TryGetValue(string key, out object value) { if (key == null) @@ -137,7 +137,7 @@ namespace System.Diagnostics.Tracing { if (name == key) { - value = m_values[position]; + value = m_values[position]; return true; } position++; diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs index 309226b84d..732c78dd6e 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs @@ -117,9 +117,9 @@ namespace System.Diagnostics.Tracing Statics.CheckName(name); var coreType = (int)dataType & Statics.InTypeMask; this.name = name; - this.nameSize = Encoding.UTF8.GetByteCount(this.name) + 1; - this.inType = (byte)(coreType | countFlags); - this.outType = (byte)(((int)dataType >> 8) & Statics.OutTypeMask); + nameSize = Encoding.UTF8.GetByteCount(this.name) + 1; + inType = (byte)(coreType | countFlags); + outType = (byte)(((int)dataType >> 8) & Statics.OutTypeMask); this.tags = tags; this.fixedCount = fixedCount; this.custom = custom; @@ -145,20 +145,20 @@ namespace System.Diagnostics.Tracing if (((int)this.tags & 0xfffffff) != 0) { - this.outType |= Statics.OutTypeChainFlag; + outType |= Statics.OutTypeChainFlag; } - if (this.outType != 0) + if (outType != 0) { - this.inType |= Statics.InTypeChainFlag; + inType |= Statics.InTypeChainFlag; } } public void IncrementStructFieldCount() { - this.inType |= Statics.InTypeChainFlag; - this.outType++; - if ((this.outType & Statics.OutTypeMask) == 0) + inType |= Statics.InTypeChainFlag; + outType++; + if ((outType & Statics.OutTypeMask) == 0) { throw new NotSupportedException(Resources.GetResourceString("EventSource_TooManyFields")); } @@ -178,52 +178,52 @@ namespace System.Diagnostics.Tracing // Write out the null terminated UTF8 encoded name if (metadata != null) { - Encoding.UTF8.GetBytes(this.name, 0, this.name.Length, metadata, pos); + Encoding.UTF8.GetBytes(name, 0, name.Length, metadata, pos); } - pos += this.nameSize; + pos += nameSize; // Write 1 byte for inType if (metadata != null) { - metadata[pos] = this.inType; + metadata[pos] = inType; } pos += 1; // If InTypeChainFlag set, then write out the outType - if (0 != (this.inType & Statics.InTypeChainFlag)) + if (0 != (inType & Statics.InTypeChainFlag)) { if (metadata != null) { - metadata[pos] = this.outType; + metadata[pos] = outType; } pos += 1; // If OutTypeChainFlag set, then write out tags - if (0 != (this.outType & Statics.OutTypeChainFlag)) + if (0 != (outType & Statics.OutTypeChainFlag)) { - Statics.EncodeTags((int)this.tags, ref pos, metadata); + Statics.EncodeTags((int)tags, ref pos, metadata); } } // If InTypeFixedCountFlag set, write out the fixedCount (2 bytes little endian) - if (0 != (this.inType & Statics.InTypeFixedCountFlag)) + if (0 != (inType & Statics.InTypeFixedCountFlag)) { if (metadata != null) { - metadata[pos + 0] = unchecked((byte)this.fixedCount); - metadata[pos + 1] = (byte)(this.fixedCount >> 8); + metadata[pos + 0] = unchecked((byte)fixedCount); + metadata[pos + 1] = (byte)(fixedCount >> 8); } pos += 2; // If InTypeCustomCountFlag set, write out the blob of custom meta-data. - if (Statics.InTypeCustomCountFlag == (this.inType & Statics.InTypeCountMask) && - this.fixedCount != 0) + if (Statics.InTypeCustomCountFlag == (inType & Statics.InTypeCountMask) && + fixedCount != 0) { if (metadata != null) { - Buffer.BlockCopy(this.custom, 0, metadata, pos, this.fixedCount); + Buffer.BlockCopy(custom, 0, metadata, pos, fixedCount); } - pos += this.fixedCount; + pos += fixedCount; } } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/InvokeTypeInfo.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/InvokeTypeInfo.cs index 3e5997bc9b..c424108077 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/InvokeTypeInfo.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/InvokeTypeInfo.cs @@ -35,7 +35,7 @@ namespace System.Diagnostics.Tracing typeAnalysis.tags) { if (typeAnalysis.properties.Length != 0) - this.properties = typeAnalysis.properties; + properties = typeAnalysis.properties; } public override void WriteMetadata( @@ -44,9 +44,9 @@ namespace System.Diagnostics.Tracing EventFieldFormat format) { var groupCollector = collector.AddGroup(name); - if (this.properties != null) + if (properties != null) { - foreach (var property in this.properties) + foreach (var property in properties) { var propertyFormat = EventFieldFormat.Default; var propertyAttribute = property.fieldAttribute; @@ -66,9 +66,9 @@ namespace System.Diagnostics.Tracing public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value) { - if (this.properties != null) + if (properties != null) { - foreach (var property in this.properties) + foreach (var property in properties) { property.typeInfo.WriteData(collector, property.getter(value)); } @@ -77,11 +77,11 @@ namespace System.Diagnostics.Tracing public override object GetData(object value) { - if (this.properties != null) + if (properties != null) { var membersNames = new List<string>(); var memebersValues = new List<object>(); - for (int i = 0; i < this.properties.Length; i++) + for (int i = 0; i < properties.Length; i++) { var propertyValue = properties[i].propertyInfo.GetValue(value); membersNames.Add(properties[i].name); diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/NameInfo.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/NameInfo.cs index 668043ae68..fc55788dae 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/NameInfo.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/NameInfo.cs @@ -25,7 +25,7 @@ namespace System.Diagnostics.Tracing /// </summary> internal static void ReserveEventIDsBelow(int eventId) { - for(;;) + for (;;) { int snapshot = lastIdentity; int newIdentity = (lastIdentity & ~0xFFFFFF) + eventId; diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs index 3ea781252f..f95e36da42 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs @@ -65,9 +65,9 @@ namespace System.Diagnostics.Tracing } // Anything not covered by the Scalar union gets stored in this reference. - readonly object _reference; - readonly Scalar _scalar; - readonly int _scalarLength; + private readonly object _reference; + private readonly Scalar _scalar; + private readonly int _scalarLength; private PropertyValue(object value) { diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs index 901a0ed1a2..6ecfc29d58 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs @@ -48,15 +48,15 @@ namespace System.Diagnostics.Tracing /// <summary> /// Type handler for simple scalar types. /// </summary> - sealed class ScalarTypeInfo : TraceLoggingTypeInfo + internal sealed class ScalarTypeInfo : TraceLoggingTypeInfo { - Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc; - TraceLoggingDataType nativeFormat; + private Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc; + private TraceLoggingDataType nativeFormat; private ScalarTypeInfo( Type type, Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc, - TraceLoggingDataType nativeFormat) + TraceLoggingDataType nativeFormat) : base(type) { this.formatFunc = formatFunc; @@ -96,15 +96,15 @@ namespace System.Diagnostics.Tracing /// </summary> internal sealed class ScalarArrayTypeInfo : TraceLoggingTypeInfo { - Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc; - TraceLoggingDataType nativeFormat; - int elementSize; + private Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc; + private TraceLoggingDataType nativeFormat; + private int elementSize; private ScalarArrayTypeInfo( Type type, Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc, TraceLoggingDataType nativeFormat, - int elementSize) + int elementSize) : base(type) { this.formatFunc = formatFunc; @@ -158,14 +158,14 @@ namespace System.Diagnostics.Tracing { collector.AddBinary((string)value.ReferenceValue); } - + public override object GetData(object value) { - if(value == null) + if (value == null) { return ""; } - + return value; } } @@ -271,9 +271,9 @@ namespace System.Diagnostics.Tracing { var typeArgs = type.GenericTypeArguments; 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")); + valueInfo = TraceLoggingTypeInfo.GetInstance(typeArgs[0], recursionCheck); + hasValueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("HasValue")); + valueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("Value")); } public override void WriteMetadata( @@ -283,7 +283,7 @@ namespace System.Diagnostics.Tracing { var group = collector.AddGroup(name); group.AddScalar("HasValue", TraceLoggingDataType.Boolean8); - this.valueInfo.WriteMetadata(group, "Value", format); + valueInfo.WriteMetadata(group, "Value", format); } public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value) @@ -291,7 +291,7 @@ namespace System.Diagnostics.Tracing var hasValue = hasValueGetter(value); collector.AddScalar(hasValue); var val = hasValue.ScalarValue.AsBoolean ? valueGetter(value) : valueInfo.PropertyValueFactory(Activator.CreateInstance(valueInfo.DataType)); - this.valueInfo.WriteData(collector, val); + valueInfo.WriteData(collector, val); } } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs index 07a56751ea..2279544695 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs @@ -445,11 +445,11 @@ namespace System.Diagnostics.Tracing var pins = stackalloc GCHandle[pinCount]; fixed (byte* - pMetadata0 = this.providerMetadata, + pMetadata0 = providerMetadata, pMetadata1 = nameInfo.nameMetadata, pMetadata2 = eventTypes.typeMetadata) { - descriptors[0].SetMetadata(pMetadata0, this.providerMetadata.Length, 2); + descriptors[0].SetMetadata(pMetadata0, providerMetadata.Length, 2); descriptors[1].SetMetadata(pMetadata1, nameInfo.nameMetadata.Length, 1); descriptors[2].SetMetadata(pMetadata2, eventTypes.typeMetadata.Length, 1); @@ -546,11 +546,11 @@ namespace System.Diagnostics.Tracing var descriptors = stackalloc EventData[eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3]; fixed (byte* - pMetadata0 = this.providerMetadata, + pMetadata0 = providerMetadata, pMetadata1 = nameInfo.nameMetadata, pMetadata2 = eventTypes.typeMetadata) { - descriptors[0].SetMetadata(pMetadata0, this.providerMetadata.Length, 2); + descriptors[0].SetMetadata(pMetadata0, providerMetadata.Length, 2); descriptors[1].SetMetadata(pMetadata1, nameInfo.nameMetadata.Length, 1); descriptors[2].SetMetadata(pMetadata2, eventTypes.typeMetadata.Length, 1); int numDescrs = 3; @@ -622,11 +622,11 @@ namespace System.Diagnostics.Tracing var pins = stackalloc GCHandle[pinCount]; fixed (byte* - pMetadata0 = this.providerMetadata, + pMetadata0 = providerMetadata, pMetadata1 = nameInfo.nameMetadata, pMetadata2 = eventTypes.typeMetadata) { - descriptors[0].SetMetadata(pMetadata0, this.providerMetadata.Length, 2); + descriptors[0].SetMetadata(pMetadata0, providerMetadata.Length, 2); descriptors[1].SetMetadata(pMetadata1, nameInfo.nameMetadata.Length, 1); descriptors[2].SetMetadata(pMetadata2, eventTypes.typeMetadata.Length, 1); #endif // FEATURE_MANAGED_ETW @@ -684,7 +684,6 @@ namespace System.Diagnostics.Tracing var eventData = (EventPayload)(eventTypes.typeInfos[0].GetData(data)); WriteToAllListeners(eventName, ref descriptor, nameInfo.tags, pActivityId, eventData); } - } catch (Exception ex) { @@ -715,9 +714,9 @@ namespace System.Diagnostics.Tracing { EventWrittenEventArgs eventCallbackArgs = new EventWrittenEventArgs(this); eventCallbackArgs.EventName = eventName; - eventCallbackArgs.m_level = (EventLevel) eventDescriptor.Level; - eventCallbackArgs.m_keywords = (EventKeywords) eventDescriptor.Keywords; - eventCallbackArgs.m_opcode = (EventOpcode) eventDescriptor.Opcode; + eventCallbackArgs.m_level = (EventLevel)eventDescriptor.Level; + eventCallbackArgs.m_keywords = (EventKeywords)eventDescriptor.Keywords; + eventCallbackArgs.m_opcode = (EventOpcode)eventDescriptor.Opcode; eventCallbackArgs.m_tags = tags; // Self described events do not have an id attached. We mark it internally with -1. @@ -852,7 +851,7 @@ namespace System.Diagnostics.Tracing { return (c - 'A' + 10); } - + throw new ArgumentException(Resources.GetResourceString("BadHexDigit", c), "traits"); } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs index c2239671bb..6f4a1dc71c 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs @@ -199,10 +199,10 @@ namespace System.Diagnostics.Tracing internal NameInfo GetNameInfo(string name, EventTags tags) { - var ret = this.nameInfos.TryGet(new KeyValuePair<string, EventTags>(name, tags)); + var ret = nameInfos.TryGet(new KeyValuePair<string, EventTags>(name, tags)); if (ret == null) { - ret = this.nameInfos.GetOrAdd(new NameInfo(name, tags, this.typeMetadata.Length)); + ret = nameInfos.GetOrAdd(new NameInfo(name, tags, this.typeMetadata.Length)); } return ret; diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs index 41225c8626..583efce973 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs @@ -27,7 +27,7 @@ namespace System.Diagnostics.Tracing /// </summary> internal TraceLoggingMetadataCollector() { - this.impl = new Impl(); + impl = new Impl(); } /// <summary> @@ -39,8 +39,8 @@ namespace System.Diagnostics.Tracing TraceLoggingMetadataCollector other, FieldMetadata group) { - this.impl = other.impl; - this.currentGroup = group; + impl = other.impl; + currentGroup = group; } /// <summary> @@ -55,22 +55,22 @@ namespace System.Diagnostics.Tracing internal int ScratchSize { - get { return this.impl.scratchSize; } + get { return impl.scratchSize; } } internal int DataCount { - get { return this.impl.dataCount; } + get { return impl.dataCount; } } internal int PinCount { - get { return this.impl.pinCount; } + get { return impl.pinCount; } } private bool BeginningBufferedArray { - get { return this.bufferedArrayFieldCount == 0; } + get { return bufferedArrayFieldCount == 0; } } /// <summary> @@ -159,7 +159,7 @@ namespace System.Diagnostics.Tracing throw new ArgumentOutOfRangeException(nameof(type)); } - this.impl.AddScalar(size); + impl.AddScalar(size); this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray)); } @@ -186,8 +186,8 @@ namespace System.Diagnostics.Tracing throw new ArgumentOutOfRangeException(nameof(type)); } - this.impl.AddScalar(2); - this.impl.AddNonscalar(); + impl.AddScalar(2); + impl.AddNonscalar(); this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray)); } @@ -235,31 +235,31 @@ namespace System.Diagnostics.Tracing throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedNestedArraysEnums")); } - this.impl.AddScalar(2); - this.impl.AddNonscalar(); + impl.AddScalar(2); + impl.AddNonscalar(); this.AddField(new FieldMetadata(name, type, this.Tags, true)); } public void BeginBufferedArray() { - if (this.bufferedArrayFieldCount >= 0) + if (bufferedArrayFieldCount >= 0) { throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedNestedArraysEnums")); } - this.bufferedArrayFieldCount = 0; - this.impl.BeginBuffered(); + bufferedArrayFieldCount = 0; + impl.BeginBuffered(); } public void EndBufferedArray() { - if (this.bufferedArrayFieldCount != 1) + if (bufferedArrayFieldCount != 1) { throw new InvalidOperationException(Resources.GetResourceString("EventSource_IncorrentlyAuthoredTypeInfo")); } - this.bufferedArrayFieldCount = int.MinValue; - this.impl.EndBuffered(); + bufferedArrayFieldCount = int.MinValue; + impl.EndBuffered(); } /// <summary> @@ -277,8 +277,8 @@ namespace System.Diagnostics.Tracing throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedCustomSerializedData")); } - this.impl.AddScalar(2); - this.impl.AddNonscalar(); + impl.AddScalar(2); + impl.AddNonscalar(); this.AddField(new FieldMetadata( name, type, @@ -288,21 +288,21 @@ namespace System.Diagnostics.Tracing internal byte[] GetMetadata() { - var size = this.impl.Encode(null); + var size = impl.Encode(null); var metadata = new byte[size]; - this.impl.Encode(metadata); + impl.Encode(metadata); return metadata; } private void AddField(FieldMetadata fieldMetadata) { this.Tags = EventFieldTags.None; - this.bufferedArrayFieldCount++; - this.impl.fields.Add(fieldMetadata); + bufferedArrayFieldCount++; + impl.fields.Add(fieldMetadata); - if (this.currentGroup != null) + if (currentGroup != null) { - this.currentGroup.IncrementStructFieldCount(); + currentGroup.IncrementStructFieldCount(); } } @@ -317,23 +317,23 @@ namespace System.Diagnostics.Tracing public void AddScalar(int size) { - if (this.bufferNesting == 0) + if (bufferNesting == 0) { - if (!this.scalar) + if (!scalar) { this.dataCount = checked((sbyte)(this.dataCount + 1)); } - this.scalar = true; + scalar = true; this.scratchSize = checked((short)(this.scratchSize + size)); } } public void AddNonscalar() { - if (this.bufferNesting == 0) + if (bufferNesting == 0) { - this.scalar = false; + scalar = false; this.pinCount = checked((sbyte)(this.pinCount + 1)); this.dataCount = checked((sbyte)(this.dataCount + 1)); } @@ -341,17 +341,17 @@ namespace System.Diagnostics.Tracing public void BeginBuffered() { - if (this.bufferNesting == 0) + if (bufferNesting == 0) { this.AddNonscalar(); } - this.bufferNesting++; + bufferNesting++; } public void EndBuffered() { - this.bufferNesting--; + bufferNesting--; } public int Encode(byte[] metadata) diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs index d68e106b0b..48198319e3 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs @@ -41,9 +41,9 @@ namespace System.Diagnostics.Tracing Contract.EndContractBlock(); - this.name = dataType.Name; + name = dataType.Name; this.dataType = dataType; - this.propertyValueFactory = PropertyValue.GetFactory(dataType); + propertyValueFactory = PropertyValue.GetFactory(dataType); } internal TraceLoggingTypeInfo( @@ -74,7 +74,7 @@ namespace System.Diagnostics.Tracing this.opcode = opcode; this.tags = tags; this.dataType = dataType; - this.propertyValueFactory = PropertyValue.GetFactory(dataType); + propertyValueFactory = PropertyValue.GetFactory(dataType); } /// <summary> @@ -84,7 +84,7 @@ namespace System.Diagnostics.Tracing /// </summary> public string Name { - get { return this.name; } + get { return name; } } /// <summary> @@ -94,7 +94,7 @@ namespace System.Diagnostics.Tracing /// </summary> public EventLevel Level { - get { return this.level; } + get { return level; } } /// <summary> @@ -104,7 +104,7 @@ namespace System.Diagnostics.Tracing /// </summary> public EventOpcode Opcode { - get { return this.opcode; } + get { return opcode; } } /// <summary> @@ -112,7 +112,7 @@ namespace System.Diagnostics.Tracing /// </summary> public EventKeywords Keywords { - get { return this.keywords; } + get { return keywords; } } /// <summary> @@ -120,17 +120,17 @@ namespace System.Diagnostics.Tracing /// </summary> public EventTags Tags { - get { return this.tags; } + get { return tags; } } internal Type DataType { - get { return this.dataType; } + get { return dataType; } } internal Func<object, PropertyValue> PropertyValueFactory { - get { return this.propertyValueFactory; } + get { return propertyValueFactory; } } /// <summary> diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs b/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs index c93e745173..091166c172 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs @@ -142,7 +142,6 @@ namespace System.Diagnostics.Tracing Analytic = 18, /// <summary>The debug channel</summary> Debug = 19, - }; /// <summary> diff --git a/src/mscorlib/src/System/Diagnostics/ICustomDebuggerNotification.cs b/src/mscorlib/src/System/Diagnostics/ICustomDebuggerNotification.cs index 29323cea2d..e7f41051f2 100644 --- a/src/mscorlib/src/System/Diagnostics/ICustomDebuggerNotification.cs +++ b/src/mscorlib/src/System/Diagnostics/ICustomDebuggerNotification.cs @@ -8,9 +8,11 @@ ** This interface is implemented by classes that support custom debugger notifications. ** ===========================================================*/ -namespace System.Diagnostics { - - using System; + +using System; + +namespace System.Diagnostics +{ // Defines an interface indicating that a custom debugger notification is requested under specific // conditions. Users should implement this interface to be used as an argument to // System.Diagnostics.Debugger.CustomNotification. diff --git a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs index 14f0f26d98..85f4f4f646 100644 --- a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs +++ b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs @@ -2,14 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - using System; - using System.IO; - using System.Collections; - using System.Runtime.Versioning; - using System.Diagnostics.Contracts; - using System.Diagnostics.CodeAnalysis; - +using System; +using System.IO; +using System.Collections; +using System.Runtime.Versioning; +using System.Diagnostics.Contracts; +using System.Diagnostics.CodeAnalysis; + +namespace System.Diagnostics +{ [Serializable] internal class LogSwitch { @@ -18,17 +19,17 @@ namespace System.Diagnostics { // same in the EE code (debugdebugger.cpp/debugdebugger.h) internal String strName; internal String strDescription; - private LogSwitch ParentSwitch; + private LogSwitch ParentSwitch; internal volatile LoggingLevels iLevel; internal volatile LoggingLevels iOldLevel; - + // ! END WARNING ! - - - private LogSwitch () + + + private LogSwitch() { } - + // Constructs a LogSwitch. A LogSwitch is used to categorize log messages. // // All switches (except for the global LogSwitch) have a parent LogSwitch. @@ -40,23 +41,23 @@ namespace System.Diagnostics { Contract.EndContractBlock(); if ((name != null) && (parent != null)) - { + { strName = name; strDescription = description; iLevel = LoggingLevels.ErrorLevel; iOldLevel = iLevel; ParentSwitch = parent; - - Log.m_Hashtable.Add (strName, this); - + + Log.m_Hashtable.Add(strName, this); + // Call into the EE to let it know about the creation of // this switch - Log.AddLogSwitch (this); + Log.AddLogSwitch(this); } else - throw new ArgumentNullException ((name==null ? nameof(name) : nameof(parent))); + throw new ArgumentNullException((name == null ? nameof(name) : nameof(parent))); } - + internal LogSwitch(String name, String description) { strName = name; @@ -65,39 +66,39 @@ namespace System.Diagnostics { iOldLevel = iLevel; ParentSwitch = null; - Log.m_Hashtable.Add (strName, this); - + Log.m_Hashtable.Add(strName, this); + // Call into the EE to let it know about the creation of // this switch - Log.AddLogSwitch (this); + Log.AddLogSwitch(this); } - - + + // Get property returns the name of the switch public virtual String Name { - get { return strName;} + get { return strName; } } - - + + // Property to Get/Set the level of log messages which are "on" for the switch. // - public virtual LoggingLevels MinimumLevel + public virtual LoggingLevels MinimumLevel { get { return iLevel; } - set - { - iLevel = value; + set + { + iLevel = value; iOldLevel = value; - String strParentName = ParentSwitch!=null ? ParentSwitch.Name : ""; + String strParentName = ParentSwitch != null ? ParentSwitch.Name : ""; if (Debugger.IsAttached) - Log.ModifyLogSwitch ((int)iLevel, strName, strParentName); - - Log.InvokeLogSwitchLevelHandlers (this, iLevel); + Log.ModifyLogSwitch((int)iLevel, strName, strParentName); + + Log.InvokeLogSwitchLevelHandlers(this, iLevel); } } - - + + // Checks if the given level is "on" for this switch or one of its parents. // public virtual bool CheckLevel(LoggingLevels level) @@ -105,22 +106,21 @@ namespace System.Diagnostics { if (iLevel > level) { // recurse through the list till parent is hit. - if (this.ParentSwitch == null) + if (ParentSwitch == null) return false; else - return this.ParentSwitch.CheckLevel (level); + return ParentSwitch.CheckLevel(level); } else return true; } - - + + // Returns a switch with the particular name, if any. Returns null if no // such switch exists. public static LogSwitch GetSwitch(String name) { return (LogSwitch)Log.m_Hashtable[name]; } - } } diff --git a/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs b/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs index 0eea0507ec..6b5ea85ee1 100644 --- a/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs +++ b/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs @@ -2,17 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - - using System; - // Constants representing the importance level of messages to be logged. - // This level can be used to organize messages, and also to filter which - // messages are displayed. - // - // An attached debugger can enable or disable which messages will - // actually be reported to the user through the COM+ debugger - // services API. This info is communicated to the runtime so only - // desired events are actually reported to the debugger. + +using System; + +namespace System.Diagnostics +{ + // Constants representing the importance level of messages to be logged. + // This level can be used to organize messages, and also to filter which + // messages are displayed. + // + // An attached debugger can enable or disable which messages will + // actually be reported to the user through the COM+ debugger + // services API. This info is communicated to the runtime so only + // desired events are actually reported to the debugger. // NOTE: The following constants mirror the constants // declared in the EE code (DebugDebugger.h). Any changes here will also // need to be made there. @@ -22,24 +24,23 @@ namespace System.Diagnostics { [Serializable] internal enum LoggingLevels { - TraceLevel0 = 0, - TraceLevel1 = 1, - TraceLevel2 = 2, - TraceLevel3 = 3, - TraceLevel4 = 4, - - StatusLevel0 = 20, - StatusLevel1 = 21, - StatusLevel2 = 22, - StatusLevel3 = 23, - StatusLevel4 = 24, - - - WarningLevel = 40, - - ErrorLevel = 50, - - PanicLevel = 100, - } + TraceLevel0 = 0, + TraceLevel1 = 1, + TraceLevel2 = 2, + TraceLevel3 = 3, + TraceLevel4 = 4, + StatusLevel0 = 20, + StatusLevel1 = 21, + StatusLevel2 = 22, + StatusLevel3 = 23, + StatusLevel4 = 24, + + + WarningLevel = 40, + + ErrorLevel = 50, + + PanicLevel = 100, + } } diff --git a/src/mscorlib/src/System/Diagnostics/Stackframe.cs b/src/mscorlib/src/System/Diagnostics/Stackframe.cs index 13d8f5cdcc..b555a609e7 100644 --- a/src/mscorlib/src/System/Diagnostics/Stackframe.cs +++ b/src/mscorlib/src/System/Diagnostics/Stackframe.cs @@ -2,27 +2,28 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - using System.Text; - using System; - using System.IO; - using System.Reflection; - using System.Diagnostics.Contracts; +using System.Text; +using System; +using System.IO; +using System.Reflection; +using System.Diagnostics.Contracts; +namespace System.Diagnostics +{ // There is no good reason for the methods of this class to be virtual. [Serializable] public class StackFrame { - private MethodBase method; - private int offset; - private int ILOffset; - private String strFileName; - private int iLineNumber; - private int iColumnNumber; - + private MethodBase method; + private int offset; + private int ILOffset; + private String strFileName; + private int iLineNumber; + private int iColumnNumber; + [System.Runtime.Serialization.OptionalField] - private bool fIsLastFrameFromForeignExceptionStackTrace; + private bool fIsLastFrameFromForeignExceptionStackTrace; internal void InitMembers() { @@ -33,21 +34,20 @@ namespace System.Diagnostics { iLineNumber = 0; iColumnNumber = 0; fIsLastFrameFromForeignExceptionStackTrace = false; - } // Constructs a StackFrame corresponding to the active stack frame. public StackFrame() { InitMembers(); - BuildStackFrame (0 + StackTrace.METHODS_TO_SKIP, false);// iSkipFrames=0 + BuildStackFrame(0 + StackTrace.METHODS_TO_SKIP, false);// iSkipFrames=0 } - + // Constructs a StackFrame corresponding to the active stack frame. public StackFrame(bool fNeedFileInfo) { InitMembers(); - BuildStackFrame (0 + StackTrace.METHODS_TO_SKIP, fNeedFileInfo);// iSkipFrames=0 + BuildStackFrame(0 + StackTrace.METHODS_TO_SKIP, fNeedFileInfo);// iSkipFrames=0 } // Constructs a StackFrame corresponding to a calling stack frame. @@ -55,25 +55,25 @@ namespace System.Diagnostics { public StackFrame(int skipFrames) { InitMembers(); - BuildStackFrame (skipFrames + StackTrace.METHODS_TO_SKIP, false); + BuildStackFrame(skipFrames + StackTrace.METHODS_TO_SKIP, false); } - + // Constructs a StackFrame corresponding to a calling stack frame. // public StackFrame(int skipFrames, bool fNeedFileInfo) { InitMembers(); - BuildStackFrame (skipFrames + StackTrace.METHODS_TO_SKIP, fNeedFileInfo); + BuildStackFrame(skipFrames + StackTrace.METHODS_TO_SKIP, fNeedFileInfo); } - + // Called from the class "StackTrace" // internal StackFrame(bool DummyFlag1, bool DummyFlag2) { InitMembers(); } - + // Constructs a "fake" stack frame, just containing the given file // name and line number. Use when you don't want to use the // debugger's line mapping logic. @@ -81,12 +81,12 @@ namespace System.Diagnostics { public StackFrame(String fileName, int lineNumber) { InitMembers(); - BuildStackFrame (StackTrace.METHODS_TO_SKIP, false); + BuildStackFrame(StackTrace.METHODS_TO_SKIP, false); strFileName = fileName; - iLineNumber = lineNumber; + iLineNumber = lineNumber; iColumnNumber = 0; } - + // Constructs a "fake" stack frame, just containing the given file // name, line number and column number. Use when you don't want to @@ -95,48 +95,48 @@ namespace System.Diagnostics { public StackFrame(String fileName, int lineNumber, int colNumber) { InitMembers(); - BuildStackFrame (StackTrace.METHODS_TO_SKIP, false); + BuildStackFrame(StackTrace.METHODS_TO_SKIP, false); strFileName = fileName; - iLineNumber = lineNumber; + iLineNumber = lineNumber; iColumnNumber = colNumber; } // Constant returned when the native or IL offset is unknown - public const int OFFSET_UNKNOWN = -1; - - - internal virtual void SetMethodBase (MethodBase mb) + public const int OFFSET_UNKNOWN = -1; + + + internal virtual void SetMethodBase(MethodBase mb) { method = mb; } - - internal virtual void SetOffset (int iOffset) + + internal virtual void SetOffset(int iOffset) { offset = iOffset; } - - internal virtual void SetILOffset (int iOffset) + + internal virtual void SetILOffset(int iOffset) { ILOffset = iOffset; } - internal virtual void SetFileName (String strFName) + internal virtual void SetFileName(String strFName) { strFileName = strFName; } - internal virtual void SetLineNumber (int iLine) + internal virtual void SetLineNumber(int iLine) { iLineNumber = iLine; } - internal virtual void SetColumnNumber (int iCol) + internal virtual void SetColumnNumber(int iCol) { iColumnNumber = iCol; } - internal virtual void SetIsLastFrameFromForeignExceptionStackTrace (bool fIsLastFrame) + internal virtual void SetIsLastFrameFromForeignExceptionStackTrace(bool fIsLastFrame) { fIsLastFrameFromForeignExceptionStackTrace = fIsLastFrame; } @@ -148,22 +148,22 @@ namespace System.Diagnostics { // Returns the method the frame is executing // - public virtual MethodBase GetMethod () + public virtual MethodBase GetMethod() { Contract.Ensures(Contract.Result<MethodBase>() != null); return method; } - + // Returns the offset from the start of the native (jitted) code for the // method being executed // - public virtual int GetNativeOffset () + public virtual int GetNativeOffset() { return offset; } - - + + // Returns the offset from the start of the IL code for the // method being executed. This offset may be approximate depending // on whether the jitter is generating debuggable code or not. @@ -171,8 +171,8 @@ namespace System.Diagnostics { public virtual int GetILOffset() { return ILOffset; - } - + } + // Returns the file name containing the code being executed. This // information is normally extracted from the debugging symbols // for the executable. @@ -181,7 +181,7 @@ namespace System.Diagnostics { { return strFileName; } - + // Returns the line number in the file containing the code being executed. // This information is normally extracted from the debugging symbols // for the executable. @@ -200,7 +200,7 @@ namespace System.Diagnostics { return iColumnNumber; } - + // Builds a readable representation of the stack frame // public override String ToString() @@ -258,10 +258,10 @@ namespace System.Diagnostics { } sb.Append(Environment.NewLine); - return sb.ToString(); + return sb.ToString(); } - - + + private void BuildStackFrame(int skipFrames, bool fNeedFileInfo) { using (StackFrameHelper StackF = new StackFrameHelper(null)) diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs index cd88f5108f..40c2526ad1 100644 --- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs +++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs @@ -2,21 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - using System; - using System.Collections; - using System.Text; - using System.Threading; - using System.Security; - using System.IO; - using System.Reflection; - using System.Runtime.InteropServices; - using System.Runtime.CompilerServices; - using System.Globalization; - using System.Runtime.Serialization; - using System.Runtime.Versioning; - using System.Diagnostics.Contracts; - +using System; +using System.Collections; +using System.Text; +using System.Threading; +using System.Security; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using System.Globalization; +using System.Runtime.Serialization; +using System.Runtime.Versioning; +using System.Diagnostics.Contracts; + +namespace System.Diagnostics +{ // READ ME: // Modifying the order or fields of this object may require other changes // to the unmanaged definition of the StackFrameHelper class, in @@ -55,7 +56,7 @@ namespace System.Diagnostics { #pragma warning restore 414 private delegate void GetSourceLineInfoDelegate(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, - IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, + IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string sourceFile, out int sourceLine, out int sourceColumn); private static Type s_symbolsType = null; @@ -170,16 +171,16 @@ namespace System.Diagnostics { } } - public virtual MethodBase GetMethodBase(int i) - { + public virtual MethodBase GetMethodBase(int i) + { // There may be a better way to do this. // we got RuntimeMethodHandles here and we need to go to MethodBase // but we don't know whether the reflection info has been initialized // or not. So we call GetMethods and GetConstructors on the type // and then we fetch the proper MethodBase!! IntPtr mh = rgMethodHandle[i]; - - if (mh.IsNull()) + + if (mh.IsNull()) return null; IRuntimeMethodInfo mhReal = RuntimeMethodHandle.GetTypicalMethodDefinition(new RuntimeMethodInfoStub(mh, this)); @@ -187,32 +188,32 @@ namespace System.Diagnostics { return RuntimeType.GetMethodBase(mhReal); } - public virtual int GetOffset(int i) { return rgiOffset[i];} - public virtual int GetILOffset(int i) { return rgiILOffset[i];} - public virtual String GetFilename(int i) { return rgFilename == null ? null : rgFilename[i];} - public virtual int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i];} - public virtual int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i];} + public virtual int GetOffset(int i) { return rgiOffset[i]; } + public virtual int GetILOffset(int i) { return rgiILOffset[i]; } + public virtual String GetFilename(int i) { return rgFilename == null ? null : rgFilename[i]; } + public virtual int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i]; } + public virtual int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i]; } + + public virtual bool IsLastFrameFromForeignExceptionStackTrace(int i) + { + return (rgiLastFrameFromForeignExceptionStackTrace == null) ? false : rgiLastFrameFromForeignExceptionStackTrace[i]; + } - public virtual bool IsLastFrameFromForeignExceptionStackTrace(int i) - { - return (rgiLastFrameFromForeignExceptionStackTrace == null)?false:rgiLastFrameFromForeignExceptionStackTrace[i]; - } + public virtual int GetNumberOfFrames() { return iFrameCount; } - public virtual int GetNumberOfFrames() { return iFrameCount;} - // // serialization implementation // [OnSerializing] - void OnSerializing(StreamingContext context) + private void OnSerializing(StreamingContext context) { // this is called in the process of serializing this object. // For compatibility with Everett we need to assign the rgMethodBase field as that is the field // that will be serialized rgMethodBase = (rgMethodHandle == null) ? null : new MethodBase[rgMethodHandle.Length]; - if (rgMethodHandle != null) + if (rgMethodHandle != null) { - for (int i = 0; i < rgMethodHandle.Length; i++) + for (int i = 0; i < rgMethodHandle.Length; i++) { if (!rgMethodHandle[i].IsNull()) rgMethodBase[i] = RuntimeType.GetMethodBase(new RuntimeMethodInfoStub(rgMethodHandle[i], this)); @@ -221,20 +222,20 @@ namespace System.Diagnostics { } [OnSerialized] - void OnSerialized(StreamingContext context) + private void OnSerialized(StreamingContext context) { // after we are done serializing null the rgMethodBase field rgMethodBase = null; } [OnDeserialized] - void OnDeserialized(StreamingContext context) + private void OnDeserialized(StreamingContext context) { // after we are done deserializing we need to transform the rgMethodBase in rgMethodHandle rgMethodHandle = (rgMethodBase == null) ? null : new IntPtr[rgMethodBase.Length]; - if (rgMethodBase != null) + if (rgMethodBase != null) { - for (int i = 0; i < rgMethodBase.Length; i++) + for (int i = 0; i < rgMethodBase.Length; i++) { if (rgMethodBase[i] != null) rgMethodHandle[i] = rgMethodBase[i].MethodHandle.Value; @@ -243,8 +244,8 @@ namespace System.Diagnostics { rgMethodBase = null; } } - - + + // Class which represents a description of a stack trace // 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 @@ -274,42 +275,40 @@ namespace System.Diagnostics { m_iMethodsToSkip = 0; CaptureStackTrace(METHODS_TO_SKIP, fNeedFileInfo, null, null); } - + // Constructs a stack trace from the current location, in a caller's // frame // public StackTrace(int skipFrames) { - if (skipFrames < 0) - throw new ArgumentOutOfRangeException(nameof(skipFrames), + throw new ArgumentOutOfRangeException(nameof(skipFrames), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); Contract.EndContractBlock(); - + m_iNumOfFrames = 0; m_iMethodsToSkip = 0; - - CaptureStackTrace(skipFrames+METHODS_TO_SKIP, false, null, null); + + CaptureStackTrace(skipFrames + METHODS_TO_SKIP, false, null, null); } - + // Constructs a stack trace from the current location, in a caller's // frame // public StackTrace(int skipFrames, bool fNeedFileInfo) { - if (skipFrames < 0) - throw new ArgumentOutOfRangeException(nameof(skipFrames), + throw new ArgumentOutOfRangeException(nameof(skipFrames), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); Contract.EndContractBlock(); - + m_iNumOfFrames = 0; m_iMethodsToSkip = 0; - - CaptureStackTrace(skipFrames+METHODS_TO_SKIP, fNeedFileInfo, null, null); + + CaptureStackTrace(skipFrames + METHODS_TO_SKIP, fNeedFileInfo, null, null); } - - + + // Constructs a stack trace from the current location. public StackTrace(Exception e) { @@ -334,7 +333,7 @@ namespace System.Diagnostics { m_iMethodsToSkip = 0; CaptureStackTrace(METHODS_TO_SKIP, fNeedFileInfo, null, e); } - + // Constructs a stack trace from the current location, in a caller's // frame // @@ -344,16 +343,16 @@ namespace System.Diagnostics { throw new ArgumentNullException(nameof(e)); if (skipFrames < 0) - throw new ArgumentOutOfRangeException(nameof(skipFrames), + throw new ArgumentOutOfRangeException(nameof(skipFrames), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); Contract.EndContractBlock(); - + m_iNumOfFrames = 0; m_iMethodsToSkip = 0; - - CaptureStackTrace(skipFrames+METHODS_TO_SKIP, false, null, e); + + CaptureStackTrace(skipFrames + METHODS_TO_SKIP, false, null, e); } - + // Constructs a stack trace from the current location, in a caller's // frame // @@ -363,17 +362,17 @@ namespace System.Diagnostics { throw new ArgumentNullException(nameof(e)); if (skipFrames < 0) - throw new ArgumentOutOfRangeException(nameof(skipFrames), + throw new ArgumentOutOfRangeException(nameof(skipFrames), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); Contract.EndContractBlock(); - + m_iNumOfFrames = 0; m_iMethodsToSkip = 0; - - CaptureStackTrace(skipFrames+METHODS_TO_SKIP, fNeedFileInfo, null, e); + + CaptureStackTrace(skipFrames + METHODS_TO_SKIP, fNeedFileInfo, null, e); } - - + + // Constructs a "fake" stack trace, just containing a single frame. // Does not have the overhead of a full stack trace. // @@ -390,22 +389,21 @@ namespace System.Diagnostics { // [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) - { + { m_iNumOfFrames = 0; m_iMethodsToSkip = 0; CaptureStackTrace(METHODS_TO_SKIP, needFileInfo, targetThread, null); - } [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void GetStackFramesInternal(StackFrameHelper sfh, int iSkip, bool fNeedFileInfo, Exception e); - + internal static int CalculateFramesToSkip(StackFrameHelper StackF, int iNumFrames) { int iRetVal = 0; String PackageName = "System.Diagnostics"; - + // Check if this method is part of the System.Diagnostics // package. If so, increment counter keeping track of // System.Diagnostics functions @@ -413,22 +411,22 @@ namespace System.Diagnostics { { MethodBase mb = StackF.GetMethodBase(i); if (mb != null) - { + { Type t = mb.DeclaringType; - if (t == null) + if (t == null) break; String ns = t.Namespace; - if (ns == null) + if (ns == null) break; if (String.Compare(ns, PackageName, StringComparison.Ordinal) != 0) break; } iRetVal++; } - + return iRetVal; } - + // Retrieves an object with stack trace information encoded. // It leaves out the first "iSkip" lines of the stacktrace. // @@ -459,7 +457,7 @@ namespace System.Diagnostics { sfTemp.SetOffset(StackF.GetOffset(i)); sfTemp.SetILOffset(StackF.GetILOffset(i)); - sfTemp.SetIsLastFrameFromForeignExceptionStackTrace(StackF.IsLastFrameFromForeignExceptionStackTrace(i)); + sfTemp.SetIsLastFrameFromForeignExceptionStackTrace(StackF.IsLastFrameFromForeignExceptionStackTrace(i)); if (fNeedFileInfo) { @@ -488,23 +486,23 @@ namespace System.Diagnostics { frames = null; } } - + // Property to get the number of frames in the stack trace // public virtual int FrameCount { - get { return m_iNumOfFrames;} + get { return m_iNumOfFrames; } } - - + + // Returns a given stack frame. Stack frames are numbered starting at // zero, which is the last stack frame pushed. // public virtual StackFrame GetFrame(int index) { if ((frames != null) && (index < m_iNumOfFrames) && (index >= 0)) - return frames[index+m_iMethodsToSkip]; - + return frames[index + m_iMethodsToSkip]; + return null; } @@ -513,18 +511,18 @@ namespace System.Diagnostics { // The nth element of this array is the same as GetFrame(n). // The length of the array is the same as FrameCount. // - public virtual StackFrame [] GetFrames() + public virtual StackFrame[] GetFrames() { if (frames == null || m_iNumOfFrames <= 0) return null; - + // We have to return a subset of the array. Unfortunately this // means we have to allocate a new array and copy over. - StackFrame [] array = new StackFrame[m_iNumOfFrames]; + StackFrame[] array = new StackFrame[m_iNumOfFrames]; Array.Copy(frames, m_iMethodsToSkip, array, 0, m_iNumOfFrames); return array; } - + // Builds a readable representation of the stack trace // public override String ToString() @@ -535,13 +533,13 @@ namespace System.Diagnostics { // TraceFormat is Used to specify options for how the // string-representation of a StackTrace should be generated. - internal enum TraceFormat + internal enum TraceFormat { Normal, TrailingNewLine, // include a trailing new line character NoResourceLookup // to prevent infinite resource recusion } - + // Builds a readable representation of the stack trace, specifying // the format for backwards compatibility. internal String ToString(TraceFormat traceFormat) @@ -550,12 +548,12 @@ namespace System.Diagnostics { String word_At = "at"; String inFileLineNum = "in {0}:line {1}"; - if(traceFormat != TraceFormat.NoResourceLookup) + if (traceFormat != TraceFormat.NoResourceLookup) { word_At = Environment.GetResourceString("Word_At"); inFileLineNum = Environment.GetResourceString("StackTrace_InFileLineNumber"); } - + bool fFirstFrame = true; StringBuilder sb = new StringBuilder(255); for (int iFrameIndex = 0; iFrameIndex < m_iNumOfFrames; iFrameIndex++) @@ -569,11 +567,11 @@ namespace System.Diagnostics { fFirstFrame = false; else sb.Append(Environment.NewLine); - + sb.AppendFormat(CultureInfo.InvariantCulture, " {0} ", word_At); Type t = mb.DeclaringType; - // if there is a type (non global method) print it + // if there is a type (non global method) print it if (t != null) { // Append t.FullName, replacing '+' with '.' @@ -592,7 +590,7 @@ namespace System.Diagnostics { { Type[] typars = ((MethodInfo)mb).GetGenericArguments(); sb.Append('['); - int k=0; + int k = 0; bool fFirstTyParam = true; while (k < typars.Length) { @@ -603,8 +601,8 @@ namespace System.Diagnostics { sb.Append(typars[k].Name); k++; - } - sb.Append(']'); + } + sb.Append(']'); } ParameterInfo[] pi = null; @@ -635,7 +633,7 @@ namespace System.Diagnostics { sb.Append(typeName); sb.Append(' '); sb.Append(pi[j].Name); - } + } sb.Append(')'); } @@ -645,7 +643,7 @@ namespace System.Diagnostics { // If we don't have a PDB or PDB-reading is disabled for the module, // then the file name will be null. String fileName = null; - + // Getting the filename from a StackFrame is a privileged operation - we won't want // to disclose full path names to arbitrarily untrusted code. Rather than just omit // this we could probably trim to just the filename so it's still mostly usefull. @@ -660,7 +658,7 @@ namespace System.Diagnostics { displayFilenames = false; } - if (fileName != null) + if (fileName != null) { // tack on " in c:\tmp\MyFile.cs:line 5" sb.Append(' '); @@ -676,10 +674,10 @@ namespace System.Diagnostics { } } - if(traceFormat == TraceFormat.TrailingNewLine) + if (traceFormat == TraceFormat.TrailingNewLine) sb.Append(Environment.NewLine); - - return sb.ToString(); + + return sb.ToString(); } // This helper is called from within the EE to construct a string representation @@ -693,5 +691,4 @@ namespace System.Diagnostics { return st.ToString(); } } - } diff --git a/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymDocumentWriter.cs b/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymDocumentWriter.cs index a1a2366c0a..09a7a3b0b0 100644 --- a/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymDocumentWriter.cs +++ b/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymDocumentWriter.cs @@ -12,10 +12,11 @@ ** ** ===========================================================*/ -namespace System.Diagnostics.SymbolStore { - - using System; - + +using System; + +namespace System.Diagnostics.SymbolStore +{ // Interface does not need to be marked with the serializable attribute public interface ISymbolDocumentWriter { @@ -23,7 +24,7 @@ namespace System.Diagnostics.SymbolStore { // symbol store. An array of unsigned bytes is used instead of // character data to accommodate a wider variety of "source". void SetSource(byte[] source); - + // Check sum support. void SetCheckSum(Guid algorithmId, byte[] checkSum); } diff --git a/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs b/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs index bfe9133aee..fa2a59797a 100644 --- a/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs +++ b/src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs @@ -11,18 +11,18 @@ ** ** ===========================================================*/ -namespace System.Diagnostics.SymbolStore { - - using System; - using System.Text; - using System.Reflection; - using System.Runtime.InteropServices; - using System.Runtime.Versioning; +using System; +using System.Text; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace System.Diagnostics.SymbolStore +{ // Interface does not need to be marked with the serializable attribute internal interface ISymbolWriter { - // Define a source document. Guid's will be provided for the // languages, vendors, and document types that we currently know // about. @@ -30,7 +30,7 @@ namespace System.Diagnostics.SymbolStore { Guid language, Guid languageVendor, Guid documentType); - + // Open a method to emit symbol information into. The given method // becomes the current method for calls do define sequence points, // parameters and lexical scopes. There is an implicit lexical @@ -40,11 +40,11 @@ namespace System.Diagnostics.SymbolStore { // // There can be only one open method at a time. void OpenMethod(SymbolToken method); - + // Close the current method. Once a method is closed, no more // symbols can be defined within it. 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 @@ -55,7 +55,7 @@ namespace System.Diagnostics.SymbolStore { int[] columns, int[] endLines, int[] endColumns); - + // Open a new lexical scope in the current method. The scope // becomes the new current scope and is effectivley pushed onto a // stack of scopes. startOffset is the offset, in bytes from the @@ -72,12 +72,12 @@ namespace System.Diagnostics.SymbolStore { // 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. void CloseScope(int endOffset); - + // Define a single variable in the current lexical // scope. startOffset and endOffset are optional. If 0, then they // are ignored and the variable is defined over the entire @@ -95,12 +95,12 @@ namespace System.Diagnostics.SymbolStore { int addr3, int startOffset, int endOffset); - + // Defines a custom attribute based upon its name. Not to be // confused with Metadata custom attributes, these attributes are // held in the symbol store. void SetSymAttribute(SymbolToken parent, String name, byte[] data); - + // Specifies that the given, fully qualified namespace name is // being used within the currently open lexical scope. Closing the // current scope will also stop using the namespace, and the @@ -108,5 +108,4 @@ namespace System.Diagnostics.SymbolStore { // currently open scope. void UsingNamespace(String fullName); } - } diff --git a/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs b/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs index bb50d9841b..c4c1ede525 100644 --- a/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs +++ b/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs @@ -11,37 +11,39 @@ ** ** ===========================================================*/ -namespace System.Diagnostics.SymbolStore { - // Only statics, does not need to be marked with the serializable attribute - using System; +// Only statics, does not need to be marked with the serializable attribute +using System; + +namespace System.Diagnostics.SymbolStore +{ [Serializable] internal enum SymAddressKind { // ILOffset: addr1 = IL local var or param index. ILOffset = 1, - + // NativeRVA: addr1 = RVA into module. NativeRVA = 2, - + // NativeRegister: addr1 = register the var is stored in. NativeRegister = 3, - + // NativeRegisterRelative: addr1 = register, addr2 = offset. NativeRegisterRelative = 4, - + // NativeOffset: addr1 = offset from start of parent. NativeOffset = 5, - + // NativeRegisterRegister: addr1 = reg low, addr2 = reg high. NativeRegisterRegister = 6, - + // NativeRegisterStack: addr1 = reg low, addr2 = reg stk, addr3 = offset. NativeRegisterStack = 7, - + // NativeStackRegister: addr1 = reg stk, addr2 = offset, addr3 = reg high. NativeStackRegister = 8, - + // BitField: addr1 = field start, addr = field length. BitField = 9, diff --git a/src/mscorlib/src/System/Diagnostics/SymbolStore/Token.cs b/src/mscorlib/src/System/Diagnostics/SymbolStore/Token.cs index cc1e4a865f..a6e6fdc0ef 100644 --- a/src/mscorlib/src/System/Diagnostics/SymbolStore/Token.cs +++ b/src/mscorlib/src/System/Diagnostics/SymbolStore/Token.cs @@ -9,21 +9,22 @@ ** around metadata tokens. ** ===========================================================*/ -namespace System.Diagnostics.SymbolStore { - - using System; - using System.Runtime.InteropServices; +using System; +using System.Runtime.InteropServices; + +namespace System.Diagnostics.SymbolStore +{ internal struct SymbolToken { internal int m_token; - - public SymbolToken(int val) {m_token=val;} - - public int GetToken() {return m_token;} - - public override int GetHashCode() {return m_token;} - + + public SymbolToken(int val) { m_token = val; } + + public int GetToken() { return m_token; } + + public override int GetHashCode() { return m_token; } + public override bool Equals(Object obj) { if (obj is SymbolToken) @@ -31,7 +32,7 @@ namespace System.Diagnostics.SymbolStore { else return false; } - + public bool Equals(SymbolToken obj) { return obj.m_token == m_token; diff --git a/src/mscorlib/src/System/Diagnostics/log.cs b/src/mscorlib/src/System/Diagnostics/log.cs index d297b8fa08..19e062964c 100644 --- a/src/mscorlib/src/System/Diagnostics/log.cs +++ b/src/mscorlib/src/System/Diagnostics/log.cs @@ -2,7 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { +namespace System.Diagnostics +{ using System.Runtime.Remoting; using System; using System.IO; @@ -12,19 +13,18 @@ namespace System.Diagnostics { using System.Runtime.Versioning; using System.Diagnostics.Contracts; using System.Diagnostics.CodeAnalysis; - - - // LogSwitchLevelHandlers are triggered when the level of a LogSwitch is modified - // NOTE: These are NOT triggered when the log switch setting is changed from the - // attached debugger. - // + + + // LogSwitchLevelHandlers are triggered when the level of a LogSwitch is modified + // NOTE: These are NOT triggered when the log switch setting is changed from the + // attached debugger. + // [Serializable] internal delegate void LogSwitchLevelHandler(LogSwitch ls, LoggingLevels newLevel); - - + + internal static class Log { - // Switches allow relatively fine level control of which messages are // actually shown. Normally most debugging messages are not shown - the // user will typically enable those which are relevant to what is being @@ -36,13 +36,13 @@ namespace System.Diagnostics { // desired events are actually reported to the debugger. internal static Hashtable m_Hashtable; private static volatile bool m_fConsoleDeviceEnabled; - private static volatile LogSwitchLevelHandler _LogSwitchLevelHandler; + private static volatile LogSwitchLevelHandler _LogSwitchLevelHandler; private static Object locker; - + // Constant representing the global switch public static readonly LogSwitch GlobalSwitch; - - + + static Log() { m_Hashtable = new Hashtable(); @@ -51,21 +51,21 @@ namespace System.Diagnostics { //iNumOfMsgHandlers = 0; //iMsgHandlerArraySize = 0; locker = new Object(); - + // allocate the GlobalSwitch object - GlobalSwitch = new LogSwitch ("Global", "Global Switch for this log"); - + GlobalSwitch = new LogSwitch("Global", "Global Switch for this log"); + GlobalSwitch.MinimumLevel = LoggingLevels.ErrorLevel; } - - internal static void InvokeLogSwitchLevelHandlers (LogSwitch ls, LoggingLevels newLevel) + + internal static void InvokeLogSwitchLevelHandlers(LogSwitch ls, LoggingLevels newLevel) { LogSwitchLevelHandler handler = _LogSwitchLevelHandler; if (handler != null) handler(ls, newLevel); } - - + + // Property to Enable/Disable ConsoleDevice. Enabling the console device // adds the console device as a log output, causing any // log messages which make it through filters to be written to the @@ -76,7 +76,7 @@ namespace System.Diagnostics { get { return m_fConsoleDeviceEnabled; } set { m_fConsoleDeviceEnabled = value; } } - + // Generates a log message. If its switch (or a parent switch) allows the // level for the message, it is "broadcast" to all of the log // devices. @@ -84,28 +84,28 @@ namespace System.Diagnostics { public static void LogMessage(LoggingLevels level, LogSwitch logswitch, String message) { if (logswitch == null) - throw new ArgumentNullException ("LogSwitch"); - + throw new ArgumentNullException("LogSwitch"); + if (level < 0) throw new ArgumentOutOfRangeException(nameof(level), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); Contract.EndContractBlock(); - + // Is logging for this level for this switch enabled? - if (logswitch.CheckLevel (level) == true) + if (logswitch.CheckLevel(level) == true) { // Send message for logging - + // first send it to the debugger - Debugger.Log ((int) level, logswitch.strName, message); - + Debugger.Log((int)level, logswitch.strName, message); + // Send to the console device if (m_fConsoleDeviceEnabled) { - Console.Write(message); - } + Console.Write(message); + } } } - + /* * Following are convenience entry points; all go through Log() * Note that the (Switch switch, String message) variations @@ -113,20 +113,19 @@ namespace System.Diagnostics { */ public static void Trace(LogSwitch logswitch, String message) { - LogMessage (LoggingLevels.TraceLevel0, logswitch, message); + LogMessage(LoggingLevels.TraceLevel0, logswitch, message); } - + public static void Trace(String message) { - LogMessage (LoggingLevels.TraceLevel0, GlobalSwitch, message); + LogMessage(LoggingLevels.TraceLevel0, GlobalSwitch, message); } - - + + // Native method to inform the EE about the creation of a new LogSwitch [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void AddLogSwitch(LogSwitch logSwitch); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void ModifyLogSwitch (int iNewLevel, String strSwitchName, String strParentName); + internal static extern void ModifyLogSwitch(int iNewLevel, String strSwitchName, String strParentName); } - } |