//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Reflection;
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>
/// Code information formatting
/// </summary>
public static class code_fmt {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentException" />
public static string MemberName( string typeNamespace,
                                 string typeNameWithoutNS,
                                 string memberName ) =>
   MemberNameAuto( typeNamespace, typeNameWithoutNS, memberName );

/// <exception cref="ArgumentException" />
public static string MemberNameAuto( string typeNamespace, string typeNameWithoutNS,
                                     [CallerMemberName] string memberName="" ) =>
   Concatenate(
      u.str_argcheck.NE( typeNamespace, nameof(typeNamespace) ),
      u.str_argcheck.NE( typeNameWithoutNS, nameof(typeNameWithoutNS) ),
      u.str_argcheck.NE( memberName, nameof(memberName) ) );

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

/// <exception cref="ArgumentException" />
public static string MemberName( Type objectType, string memberName ) =>
   u.str.FMT( "{0}.{1}", objectType, u.str_argcheck.NE( memberName, nameof(memberName) ) );

/// <exception cref="ArgumentException" />
public static string MemberNameAuto( Type objectType, [CallerMemberName] string memberName="" ) =>
   MemberName( objectType, memberName );

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

public static string MethodName( MethodBase method ) =>
   u.method.GetFullName( method );

public static string PropertyName( MethodBase property ) =>
   u.property.GetFullName( property );

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

public static string Concatenate( params string[] reflectionParts ) =>
   u.str.Join( ".", reflectionParts );

public static string ConcatenateN( params string?[] reflectionParts ) =>
   u.str.JoinN( ".", reflectionParts );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // code_fmt

} // user_rtx (.wasm)
