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

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

static partial class debug {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( string blockName, Action block ) =>
   u.trace.Do( u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               blockName, block );

/// <exception cref="ArgumentNullException" />
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( [u.req] MethodBase? method, Action block ) =>
   u.trace.Do( u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               method, block );
/// <exception cref="ArgumentNullException" />
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( [u.req] MethodBase? method, bool expanded, Action block ) =>
   u.trace.Do( u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               method, expanded, block );

/// <exception cref="ArgumentException" />
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( Type objectType, Action block, [CallerMemberName] string memberName="" ) =>
   u.trace.Do( u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               objectType, block, memberName );

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

[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( bool condition, string blockName, Action block ) =>
   u.trace.Do( condition && u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               blockName, block );

/// <exception cref="ArgumentNullException" />
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( bool condition, [u.req] MethodBase? method, Action block ) =>
   u.trace.Do( condition && u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               method, block );
/// <exception cref="ArgumentNullException" />
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( bool condition, [u.req] MethodBase? method,
                       bool expanded, Action block ) =>
   u.trace.Do( condition && u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               method, expanded, block );

/// <exception cref="ArgumentException" />
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( bool condition, Type objectType, Action block,
                       [CallerMemberName] string memberName = "" ) =>
   u.trace.Do( condition && u.assembly.IsConfiguredForDebug( Assembly.GetCallingAssembly() ),
               objectType, block, memberName );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // debug

} // user_rtx (.wasm)
