-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable ETW error logging for S.SM.Federation (#4391)
Co-authored-by: Matt Connew <matt.connew@microsoft.com>
- Loading branch information
Showing
28 changed files
with
895 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 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 System.Diagnostics; | ||
|
||
namespace System.Runtime | ||
{ | ||
internal static class AssertHelper | ||
{ | ||
internal static void FireAssert(string message) | ||
{ | ||
Debug.Assert(false, message); | ||
} | ||
} | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
src/Common/src/Internals/System/Runtime/DiagnosticStrings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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.Runtime | ||
{ | ||
internal static partial class DiagnosticStrings | ||
{ | ||
internal const string DataTag = "Data"; | ||
internal const string DataItemsTag = "DataItems"; | ||
internal const string ExceptionStringTag = "ExceptionString"; | ||
internal const string ExceptionTag = "Exception"; | ||
internal const string ExceptionTypeTag = "ExceptionType"; | ||
internal const string KeyTag = "Key"; | ||
internal const string InnerExceptionTag = "InnerException"; | ||
internal const string MessageTag = "Message"; | ||
internal const string StackTraceTag = "StackTrace"; | ||
internal const string ValueTag = "Value"; | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/Common/src/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// 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 System.Diagnostics; | ||
using System.Text; | ||
|
||
namespace System.Runtime.Diagnostics | ||
{ | ||
internal abstract partial class DiagnosticTraceBase | ||
{ | ||
public DiagnosticTraceBase() | ||
{ | ||
} | ||
|
||
//only used for exceptions, perf is not important | ||
public static string XmlEncode(string text) | ||
{ | ||
if (string.IsNullOrEmpty(text)) | ||
{ | ||
return text; | ||
} | ||
|
||
int len = text.Length; | ||
StringBuilder encodedText = new StringBuilder(len + 8); //perf optimization, expecting no more than 2 > characters | ||
|
||
for (int i = 0; i < len; ++i) | ||
{ | ||
char ch = text[i]; | ||
switch (ch) | ||
{ | ||
case '<': | ||
encodedText.Append("<"); | ||
break; | ||
case '>': | ||
encodedText.Append(">"); | ||
break; | ||
case '&': | ||
encodedText.Append("&"); | ||
break; | ||
default: | ||
encodedText.Append(ch); | ||
break; | ||
} | ||
} | ||
return encodedText.ToString(); | ||
} | ||
|
||
protected static string StackTraceString(Exception exception) | ||
{ | ||
string retval = exception.StackTrace; | ||
if (string.IsNullOrEmpty(retval)) | ||
{ | ||
// This means that the exception hasn't been thrown yet. We need to manufacture the stack then. | ||
StackTrace stackTrace = new StackTrace(false); | ||
// Figure out how many frames should be throw away | ||
StackFrame[] stackFrames = stackTrace.GetFrames(); | ||
|
||
int frameCount = 0; | ||
bool breakLoop = false; | ||
foreach (StackFrame frame in stackFrames) | ||
{ | ||
string methodName = frame.GetMethod().Name; | ||
switch (methodName) | ||
{ | ||
case "StackTraceString": | ||
case "AddExceptionToTraceString": | ||
case "BuildTrace": | ||
case "TraceEvent": | ||
case "TraceException": | ||
case "GetAdditionalPayload": | ||
++frameCount; | ||
break; | ||
default: | ||
if (methodName.StartsWith("ThrowHelper", StringComparison.Ordinal)) | ||
{ | ||
++frameCount; | ||
} | ||
else | ||
{ | ||
breakLoop = true; | ||
} | ||
break; | ||
} | ||
if (breakLoop) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
stackTrace = new StackTrace(frameCount, false); | ||
retval = stackTrace.ToString(); | ||
} | ||
return retval; | ||
} | ||
} | ||
} |
Oops, something went wrong.