public void Parameter_test_try_catch_finally_result() { var tryCatchParameter = Variable(typeof(TryCatchTest)); var assignExpr = Lambda <Func <TryCatchTest, TryCatchTest> >( Block( Assign( tryCatchParameter, TryCatch( New(tryCatchParameter.Type.GetConstructor(Type.EmptyTypes)), Catch(typeof(Exception), Default(tryCatchParameter.Type)))), tryCatchParameter ), tryCatchParameter); var func = assignExpr.CompileFast(true); Assert.IsNotNull(func); var input = new TryCatchTest(); var tryCatchResult = func(input); Assert.AreNotSame(input, tryCatchResult); Assert.IsNotNull(tryCatchResult); }
public void TestTryCatchNop() { var ctx = _patchContext.AcquireContext(); ctx.GetPattern(TryCatchTest._target).Transpilers.Add(_nopTranspiler); _patchContext.Commit(); Assert.False(TryCatchTest.Target()); Assert.True(TryCatchTest.FinallyHit); _patchContext.FreeContext(ctx); _patchContext.Commit(); }
public void TestTryCatchCancel() { var ctx = _patchContext.AcquireContext(); ctx.GetPattern(TryCatchTest._target).Transpilers.Add(TryCatchTest._removeThrowTranspiler); ctx.GetPattern(TryCatchTest._target).DumpTarget = @"C:\tmp\dump.txt"; ctx.GetPattern(TryCatchTest._target).DumpMode = MethodRewritePattern.PrintModeEnum.Original | MethodRewritePattern.PrintModeEnum.Patched; _patchContext.Commit(); Assert.True(TryCatchTest.Target()); Assert.True(TryCatchTest.FinallyHit); _patchContext.FreeContext(ctx); _patchContext.Commit(); }