//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;
using System.Runtime.CompilerServices;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

/// <summary>
/// user_rtx internal helpers
/// </summary>
static class urtx {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public static bool IsStandard    => urtx_core_info.BuildExtFlag_Standard;
public static bool IsWin32Build  => urtx_core_info.BuildExtFlag_Win32;
public static bool IsWASM        => urtx_core_info.BuildExtFlag_Wasm;
//==================================================================================================

#if !WASM
public const string NS = "user_rtx";
#else // WASM
public const string NS = "user_rtx.wasm";
#endif // WASM

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

public static string MemberName( string typeNameWithoutNS, string memberName ) =>
   u.code_fmt.MemberName( NS, typeNameWithoutNS, memberName );

public static string MemberNameAuto( string typeNameWithoutNS,
                                     [CallerMemberName] string memberName="" ) =>
   u.code_fmt.MemberName( NS, typeNameWithoutNS, memberName );

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

/// <exception cref="ArgumentNullException" />
public static string MSG( string typeNameWithoutNS, string message,
                          [CallerMemberName] string memberName="" )
{
   var sb = new StringBuilder( message.TXT() );
   sb.AppendLine();
   sb.Append( '(' );
   sb.Append( MemberName( typeNameWithoutNS, memberName ) );
   sb.Append( ')' );
   return sb.ToString();
}

/// <exception cref="ArgumentNullException" />
public static string MSG( Type objectType, string message,
                          [CallerMemberName] string memberName="" )
{
   var sb = new StringBuilder( message.TXT() );
   sb.AppendLine();
   sb.Append( '(' );
   sb.Append( u.code_fmt.MemberName( objectType, memberName ) );
   sb.Append( ')' );
   return sb.ToString();
}

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

public static string FMT( string typeNameWithoutNS, string memberName,
                          string messageFmt, params object?[] args ) =>
   MSG( typeNameWithoutNS, string.Format( messageFmt, args ), memberName );

public static string FMT( Type objectType, string memberName,
                          string messageFmt, params object?[] args ) =>
   MSG( objectType, string.Format( messageFmt, args ), memberName );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // urtx

} // user_rtx (.wasm)
