mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 00:08:05 -04:00
* Move all unit tests to Engine/Tests * Fix Margin.EdgeSubtract * Fix Capsule.Contains * EnvironmentVariables.Remove if it's null * Fixed ray trace never returning startedsolid * Fix HistoryList.Navigate on empty list * Fix GameObject.WorldPosition accepting NaNs * Fix flex: initial expanding to the wrong grow/shrink * Translation.TryConvert shouldn't throw on invalid enum strings * Skip sound file tests on machines with no audio device
69 lines
1.1 KiB
C#
69 lines
1.1 KiB
C#
using Sandbox;
|
|
using System;
|
|
|
|
[AttributeUsage( AttributeTargets.Method )]
|
|
[CodeGenerator( CodeGeneratorFlags.WrapMethod | CodeGeneratorFlags.Instance, "OnMethodInvoked" )]
|
|
[CodeGenerator( CodeGeneratorFlags.WrapMethod | CodeGeneratorFlags.Static, "WrapCall.OnMethodInvokedStatic" )]
|
|
public class WrapCall : Attribute
|
|
{
|
|
public static void OnMethodInvokedStatic<T1>( WrappedMethod m, T1 arga )
|
|
{
|
|
m.Resume();
|
|
}
|
|
|
|
public static void OnMethodInvokedStatic( WrappedMethod m )
|
|
{
|
|
m.Resume();
|
|
}
|
|
}
|
|
|
|
public partial class TestWrapCall
|
|
{
|
|
[WrapCall]
|
|
public void TestPreprocessorWrappedMethod()
|
|
{
|
|
#if true
|
|
if ( true )
|
|
{
|
|
// Hello there!
|
|
}
|
|
#endif
|
|
|
|
#if SERVER
|
|
// Server-side code only
|
|
#endif
|
|
|
|
#if !SERVER
|
|
// Client-side code only
|
|
#endif
|
|
}
|
|
|
|
[WrapCall]
|
|
public void AnotherTest()
|
|
{
|
|
#if true
|
|
if ( true )
|
|
{
|
|
// Hello there!
|
|
}
|
|
#endif
|
|
|
|
Log.Info( $"Another line - so the trivia is empty below" );
|
|
}
|
|
|
|
internal bool OnMethodInvoked<T1>( WrappedMethod<bool> m, T1 arga )
|
|
{
|
|
|
|
}
|
|
|
|
internal void OnMethodInvoked<T1>( WrappedMethod m, T1 arga )
|
|
{
|
|
|
|
}
|
|
|
|
internal void OnMethodInvoked( WrappedMethod m )
|
|
{
|
|
m.Resume();
|
|
}
|
|
}
|