public static void test8_s(object a0, object a1)//, long a2, IntPtr a3, ref Book a4, ref AOP a5) { MList.M = MethodBase.GetCurrentMethod(); MList.L.Add(a0); MList.L.Add(a1); AOP.SDoS(); }
public static object test1_s(object a0, object a1)//, long a2, IntPtr a3, ref Book a4, ref AOP a5) { return(AOP.SDo(MethodBase.GetCurrentMethod(), new MList() { a0, a1 })); }
public object test0()//object inputStringasObject0,ref System.Int64 inputStringasObject1)//, long a2, IntPtr a3, ref IntPtr a4, ref AOP a5, testStruct a6,ref testStruct a7) { MList.O = this; MList.M = MethodBase.GetCurrentMethod(); // MList.L.Add(inputStringasObject0); MList.L.Add(inputStringasObject1); return(AOP.DoS()); // return Do(this, MethodBase.GetCurrentMethod(), MList.L); }
public void TestOne() { var dal = new SomeTestClass(new DateTime(2010, 2, 5)); // Example of the most common use case: calling instance GetDateString() method returning string. string actual = dal.GetProxy(TestAspects).Invoke(instance => instance.GetDateString("whatevs")); Assert.AreEqual("whatevs 2/5/2010 12:00:00 AM", actual); // Example of instantiating an IDisposable class, calling its instance method returning string, and disposing of class instance. actual = AOP.GetProxy <SomeTestDisposable>(TestAspects).Invoke(dispInstance => dispInstance.Echo("some text")); Assert.AreEqual("some text", actual); }
public void CallPerfStaticCounterProfile() { int parmInt = 123; string parmStr = "bogus"; bool parmBool = false; decimal parmDec = 1.0m; int[] arr = { 1, 2, 3, 4, 5 }; long runsPerSec; runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr))); this.TestContext.WriteLine("SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr) non-parallel perf test result: {0} calls/second.", runsPerSec); }
public void TestStaticLogging() { Assert.IsNull(Proxy.CurrentLog); const int intParm = 456; this.IntProp = intParm; string refString = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture); bool outBool = false; SomeTestClass obj = new SomeTestClass(); // Example of calling static void method. AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj, ref refString, out outBool)); Assert.IsTrue(outBool); }
public void CallConstStaticPerfCounter() { const int baseLineMultiThreadConstStaticParmRunsPerSec = 23000; // 31500; // 33500; const int baseLineSingleThreadConstStaticParmRunsPerSec = 8500; // 9000 long runsPerSec; runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(123, "bogus", false, 1m, null))); this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED PARALLEL LOCALVARS CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineMultiThreadConstStaticParmRunsPerSec); //Assert.IsTrue(runsPerSec >= baseLineMultiThreadConstStaticParmRunsPerSec); runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(123, "bogus", false, 1m, null))); this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED SEQUENTIAL CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineSingleThreadConstStaticParmRunsPerSec); //Assert.IsTrue(runsPerSec >= baseLineSingleThreadConstStaticParmRunsPerSec); }
private object Prepared(int o) { return(AOP.Do(this, MethodBase.GetCurrentMethod(), new MList() { o })); /* 0000 : ldarg.0(2) * 0001 : call System.Reflection.MethodBase System.Reflection.MethodBase::GetCurrentMethod()(40 | 150 | 0 | 0 | 10) 167772310 * 0006 : newobj instance void MList::.ctor()(115 | 75 | 0 | 0 | 6) 100663371 * 0011 : dup(37) * 0012 : ldarg.1(3) * 0013 : box int (140 | 105 | 0 | 0 | 1) 16777321 * 0018 : callvirt instance System.Void MList::Add()(111 | 74 | 0 | 0 | 6) 100663370 * 0023 : call System.Object AOP::Do()(40 | 46 | 0 | 0 | 6) 100663342 * 0028 : ret(42)*/ }
public aops(MethodBase M, MethodInfo BM, MethodInfo EM) { HandlersConditionsInst = new List <string>(); foreach (var x in AOP.HandlersConditions) { if (x.Value(M)) { HandlersConditionsInst.Add(x.Key); } } BegCode = M.GetMethodBody().GetILAsByteArray(); ChangeCode = AOP.GetRealBody(M); BasicM = M; BasicBeginM = BM; BasicEndM = EM; RuntimeHelpers.PrepareMethod(this.BasicM.MethodHandle); InjectionHelper.UpdateILCodes(this.BasicM, this.ChangeCode); }
public void TestJSonSerializtion() { string nullObj = null; string json = nullObj.ToJsonString(); Assert.AreEqual("null", json); nullObj = json.FromJsonString <string>(); Assert.AreEqual(null, nullObj); IList <Address> addresses = LinqTests.GetQueryCustomerAddressesByCustomerId(); json = AOP.Invoke(AspectacularTest.TestAspects, () => addresses.ToJsonString()); Address[] deserializedAddresses = json.FromJsonString <Address[]>(); Assert.AreEqual(addresses.Count, deserializedAddresses.Length); deserializedAddresses.For((addr, i) => Assert.AreEqual(addr[i].ToJsonString(), deserializedAddresses[i].ToJsonString())); deserializedAddresses[0].AddressID++; Assert.AreNotEqual(addresses[0].ToJsonString(), deserializedAddresses[0].ToJsonString()); }
public void CallPerfStaticCounter() { const int baseLineParallelRunsPerSec = 9500; // 10000; const int baseLineRunsPerSec = 3300; // 3500; int parmInt = 123; string parmStr = "bogus"; bool parmBool = false; decimal parmDec = 1.0m; int[] arr = { 1, 2, 3, 4, 5 }; long runsPerSec; runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr))); this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED PARALLEL VRPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineParallelRunsPerSec); //Assert.IsTrue(runsPerSec >= baseLineParallelRunsPerSec); runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(parmInt, parmStr, parmBool, parmDec, arr))); this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED SEQUENTIAL VARPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineRunsPerSec); //Assert.IsTrue(runsPerSec >= baseLineRunsPerSec); }
public void TestMethodMetadata() { int intParm = 456; this.IntProp = intParm; string refString1 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture); bool outBool = false; SomeTestClass obj1 = new SomeTestClass(); // Example of calling static void method. AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj1, ref refString1, out outBool)); Assert.IsTrue(outBool); Thread.Sleep(100); intParm = 12456; IntProp = intParm; string refString2 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture); SomeTestClass obj2 = new SomeTestClass(new DateTime(1999, 5, 3)); AOP.Invoke(TestAspects, () => SomeTestClass.MiscParmsStatic(this.IntProp, obj2, ref refString2, out outBool)); Assert.IsTrue(outBool); }
private object Prepared(int o) { return(AOP.Do(this, MethodBase.GetCurrentMethod(), new MList() { o, "test" })); /*-2012 0000 : ldarg.0 (2) * 0001 : call System.Reflection.MethodBase System.Reflection.MethodBase::GetCurrentMethod() (40|135|0|0|10) 167772295 * 0006 : newobj instance void MList::.ctor() (115|36|0|0|6) 100663332 * 0011 : stloc.0 (10) * 0012 : ldloc.0 (6) * 0013 : ldarg.1 (3) * 0014 : box int (140|55|0|0|1) 16777271 * 0019 : callvirt instance System.Void MList::Add() (111|35|0|0|6) 100663331 * 0024 : ldloc.0 (6) * 0025 : ldstr "test1879052150" (114|118|15|0|112) 1879052150 * 0030 : callvirt instance System.Void MList::Add() (111|35|0|0|6) 100663331 * 0035 : ldloc.0 (6) * 0036 : call System.Object AOP::Do() (40|75|0|0|6) 100663371 * 0041 : ret (42) */ }
public object test(object a0, ref char a1, long a2, UIntPtr a3, ref UIntPtr a4, testStruct a5, ref testStruct a6, ref AOP a7, DateTime a8, ref DateTime a9) { return(Do(this, MethodBase.GetCurrentMethod(), new MList() { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9 })); /*0000 : ldarg.0 (2) * 0001 : ldarg.0 (2) * 0002 : call System.Reflection.MethodBase System.Reflection.MethodBase::GetCurrentMethod() (40|145|0|0|10) 167772305 * 0007 : newobj instance void MList::.ctor() (115|88|0|0|6) 100663384 * 0012 : stloc.0 (10) * 0013 : ldloc.0 (6) * 0014 : ldarg.1 (3) * 0015 : callvirt instance System.Void MList::Add() (111|91|0|0|6) 100663387 * 0020 : ldloc.0 (6) * 0021 : ldarg.2 (4) * 0022 : callvirt instance System.Void MList::Add() (111|91|0|0|6) 100663387 * 0027 : ldloc.0 (6) * 0028 : call instance System.Object testType::Do() (40|96|0|0|6) 100663392 * 0033 : ret (42) */ }
public void TestEmptyAspectCollection() { AOP.Invoke(null, () => DateTime.IsLeapYear(2012)); }