//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
/// <summary>
/// </summary>
public static partial class HStackTrace {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetText()
{
   return GetText( new StackTrace( 1 ) );
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetText(bool needFileInfo)
{
   return GetText( new StackTrace( needFileInfo ) );
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetText(int skipFrames)
{
   return GetText( new StackTrace( skipFrames + 1 ) );
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetText(int skipFrames,bool needFileInfo)
{
   return GetText( new StackTrace( skipFrames + 1, needFileInfo ) );
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static string GetText(StackTrace stackTrace)
{
   HArgChecking.VerifyNotNull( stackTrace );
   string text = stackTrace.ToString();
   return text.EndsWith( Environment.NewLine ) ?
      text.Remove( text.Length - Environment.NewLine.Length ) :
      text;
}

//==================================================================================================

static HStackTrace()
{
   CommonHelpers_Core.Access();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HStackTrace
//**************************************************************************************************

} // CommonHelpers (.WASM)
