Skip to content

Commit

Permalink
Unify Environment.StackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed May 25, 2021
1 parent a3859fa commit 8938175
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ public static string[] GetCommandLineArgs()
// Used by VM
internal static string? GetResourceStringLocal(string key) => SR.GetResourceString(key);

public static string StackTrace
{
[MethodImpl(MethodImplOptions.NoInlining)] // Prevent inlining from affecting where the stacktrace starts
get => new StackTrace(true).ToString(System.Diagnostics.StackTrace.TraceFormat.Normal);
}

/// <summary>Gets the number of milliseconds elapsed since the system started.</summary>
/// <value>A 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started.</value>
public static extern int TickCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;

namespace System
Expand Down Expand Up @@ -203,6 +204,12 @@ public static Version Version
}
}

public static string StackTrace
{
[MethodImpl(MethodImplOptions.NoInlining)] // Prevent inlining from affecting where the stacktrace starts
get => new StackTrace(true).ToString(System.Diagnostics.StackTrace.TraceFormat.Normal);
}

private static bool ValidateAndConvertRegistryTarget(EnvironmentVariableTarget target)
{
Debug.Assert(target != EnvironmentVariableTarget.Process);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ public static extern int ExitCode
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int GetProcessorCount();

public static string StackTrace
{
[MethodImpl(MethodImplOptions.NoInlining)] // Prevent inlining from affecting where the stacktrace starts
get => new StackTrace(true).ToString(Diagnostics.StackTrace.TraceFormat.Normal);
}

public static extern int TickCount
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
Expand Down

0 comments on commit 8938175

Please sign in to comment.