//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// 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 trace {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( string blockName, Action block )
{
   using ( new TRACE_IF( u.assembly.IsConfiguredForTrace( Assembly.GetCallingAssembly() ),
                         blockName ) )
      block();
}

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

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

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

[MethodImpl(MethodImplOptions.NoInlining)]
public static void Do( bool condition, string blockName, Action block )
{
   using ( new TRACE_IF( condition &&
                         u.assembly.IsConfiguredForTrace( Assembly.GetCallingAssembly() ),
                         blockName ) )
      block();
}

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

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // trace

} // user_rtx (.wasm)
