未验证 提交 915da6a5 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #45381 from tmat/StackTraceLineNumbers

Include line numbers in Integration Test stack traces
......@@ -27,8 +27,7 @@ internal static void OnFatalException(Exception exception)
#if !NET20
// don't fail fast with an aggregate exception that is masking true exception
var aggregate = exception as AggregateException;
if (aggregate != null && aggregate.InnerExceptions.Count == 1)
if (exception is AggregateException aggregate && aggregate.InnerExceptions.Count == 1)
{
exception = aggregate.InnerExceptions[0];
}
......@@ -72,32 +71,6 @@ internal static void DumpStackTrace(Exception? exception = null, string? message
}
}
#if !NET20 && !NETSTANDARD1_3
Console.WriteLine("Stack trace of handler");
var stackTrace = new StackTrace();
Console.WriteLine(stackTrace.ToString());
#endif
Console.Out.Flush();
}
/// <summary>
/// Dumps the stack trace of the exception and the handler to the console. This is useful
/// for debugging unit tests that hit a fatal exception
/// </summary>
[Conditional("DEBUG")]
private static void DumpStackTrace(Exception exception)
{
Console.WriteLine("Dumping info before call to failfast");
Console.WriteLine("Exception info");
for (Exception? current = exception; current is object; current = current!.InnerException)
{
Console.WriteLine(current.Message);
Console.WriteLine(current.StackTrace);
current = current.InnerException;
}
#if !NET20 && !NETSTANDARD1_3
Console.WriteLine("Stack trace of handler");
var stackTrace = new StackTrace();
......
......@@ -29,6 +29,8 @@ internal class IntegrationService : MarshalByRefObject
public IntegrationService()
{
AppContext.SetSwitch("Switch.System.Diagnostics.IgnorePortablePDBsInStackTraces", false);
PortName = GetPortName(Process.GetCurrentProcess().Id);
BaseUri = "ipc://" + this.PortName;
}
......
......@@ -78,10 +78,7 @@ private static void FirstChanceExceptionHandler(object sender, FirstChanceExcept
Directory.CreateDirectory(logDir);
var exception = eventArgs.Exception;
File.WriteAllText(
Path.Combine(logDir, $"{baseFileName}.log"),
$"{exception}.GetType().Name{Environment.NewLine}{exception.StackTrace}");
File.WriteAllText(Path.Combine(logDir, $"{baseFileName}.log"), eventArgs.Exception.ToString());
EventLogCollector.TryWriteDotNetEntriesToFile(Path.Combine(logDir, $"{baseFileName}.DotNet.log"));
EventLogCollector.TryWriteWatsonEntriesToFile(Path.Combine(logDir, $"{baseFileName}.Watson.log"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册