tonerdo / pose

Replace any .NET method (including static and non-virtual) with a delegate
MIT License
1.08k stars 75 forks source link

Fix try/catch/finally il code generation #42

Open vCipher opened 5 years ago

vCipher commented 5 years ago

There is some problem with methods contain try/catch/finally statement.

Pose.Tests.MethodRewriterTests.TestExceptionHandlersRewrite

Test method Pose.Tests.MethodRewriterTests.TestExceptionHandlersRewrite threw exception: 
System.InvalidOperationException: Incorrect code generation for exception block.
   at System.Reflection.Emit.ILGenerator.EndExceptionBlock()
   at Pose.IL.MethodRewriter.EmitILForExceptionHandlers(ILGenerator ilGenerator, Instruction instruction, List`1 handlers)
   at Pose.IL.MethodRewriter.Rewrite()
   at Pose.Tests.MethodRewriterTests.TestExceptionHandlersRewrite()

Wrong exception handler instruction order failed:

  1. begin exception block
  2. begin exception block
  3. begin catch handler
  4. begin finally handler
  5. end catch handler
  6. end finally handler

I have fixed instruction order. Now order is:

  1. begin exception block
  2. begin exception block
  3. begin catch handler
  4. end catch handler
  5. begin finally handler
  6. end finally handler
jwdonahue commented 4 years ago

Why hasn't this fix been accepted? Is this project dead?