tonerdo / pose

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

Question - debugging? #5

Open alexzaytsev-newsroomly opened 6 years ago

alexzaytsev-newsroomly commented 6 years ago

I wrote a Pose test, but when i put breakpoints inside the action i pass to Pose or inside the code under test, none of my breakpoints are hit. (both using Resharper runner and VS built in runner)

I am using .Net core 2.0.

Is this expected?

tonerdo commented 6 years ago

@alexzaytsev-newsroomly Yes this is expected behavior. There's some work that needs to be done around debugging and exceptions. However, breakpoints set within a shim replacement delegate are hit.

ilengyel commented 6 years ago

@tonerdo I suppose this also means that code coverage tools will not track lines called under the Isolate method?

tonerdo commented 6 years ago

@ilengyel yes that is correct

douglasg14b commented 2 weeks ago

What is the cause of this behavior? I'm curious to learn more.

douglasg14b commented 2 weeks ago

Maybe @Miista Has insight 🤔

Miista commented 2 weeks ago

Right. So the reason breakpoints are not hit is due to the code being rewritten at runtime. That is the short answer, at least.

The slightly longer answer is that breakpoints are a feature of the IDE and not the IL. This means that information about a breakpoint is not available to us when rewriting the code. As such we cannot carry over the breakpoint. Even if we did have the information, I don't think there is functionality for setting a breakpoint in IL.

@douglasg14b I hope that answers your question. If not please let me know.