From 89381757069abf79ac0574c38821d92817cbd37d Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 24 May 2021 21:22:12 -0700 Subject: [PATCH] Unify Environment.StackTrace --- .../src/System/Environment.CoreCLR.cs | 6 ------ .../System.Private.CoreLib/src/System/Environment.cs | 7 +++++++ .../System.Private.CoreLib/src/System/Environment.Mono.cs | 6 ------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Environment.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Environment.CoreCLR.cs index b375cfddc7ba5..56ac1ec84dfa8 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Environment.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Environment.CoreCLR.cs @@ -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); - } - /// Gets the number of milliseconds elapsed since the system started. /// A 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started. public static extern int TickCount diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.cs index 15e19465cae31..6c6c8ced629d0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Diagnostics; using System.Reflection; +using System.Runtime.CompilerServices; using System.Threading; namespace System @@ -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); diff --git a/src/mono/System.Private.CoreLib/src/System/Environment.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Environment.Mono.cs index 69c6bf09ab2dd..43350fe683f2b 100644 --- a/src/mono/System.Private.CoreLib/src/System/Environment.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Environment.Mono.cs @@ -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)]