inversionhourglass / Rougamo

Compile-time AOP component. Works with any method, whether it is async or sync, instance or static. Uses an aspectj-like pattern to match methods.
MIT License
393 stars 47 forks source link

有个问题请教下:更改方法体Instructions后在vs2022打断点调试会有乱跳的情况 #85

Closed chipeng1023 closed 4 weeks ago

chipeng1023 commented 4 weeks ago

image 这里调试时会有乱跳的情况,Sub方法加上DebuggerStepThrough后就直接不进方法体了

image 注入后反编译是这样的

然后我用本项目Retry特性断点逐步调试正常,是怎么解决的?

inversionhourglass commented 4 weeks ago

这里调试时会有乱跳的情况

具体是怎么乱跳的,要不你录一个gif动图吧

然后我用本项目Retry特性断点逐步调试正常,是怎么解决的?

你是指这个直接用 https://github.com/inversionhourglass/Rougamo.Retry

chipeng1023 commented 4 weeks ago

1uxnn-04cyk Convert.ToInt32("");这一行报错的话,正常是从方法体开始位置进来,但是目前是每次报错都会在方法体结束位置弹出提示

chipeng1023 commented 4 weeks ago

你是指这个直接用 https://github.com/inversionhourglass/Rougamo.Retry ? 是的

chipeng1023 commented 4 weeks ago

64tyf-eq1ni 用Rougamo.Retry的效果是这样的,看着一切正常

inversionhourglass commented 4 weeks ago

调试相关的信息大部分存储在DebugInformationCustomDebugInformations中,你生成的$Aop_Xxx方法需要设置这个调试信息。我的做法是拷贝原方法的调试信息的同时做相应修改,可以参考我的实现: https://github.com/inversionhourglass/Shared.Fody.Simulations/blob/49d96098b28bcde6f5ee45c3d93cdc4bea968a9a/Extensions/MonoCloneExtension.cs#L266-L282

你截图里重试+睡眠的方式用 Rougamo.Retry 也可以实现,如果你只是想要额外添加重试睡眠的功能,可以通过扩展Rougamo.Retry来实现,对于比较通用的功能,你也可以提交PR到Rougamo.Retry。当然,如果你是对MSIL/Mono.Cecil/Fody比较感兴趣,自己实现一套也是挺好的。

chipeng1023 commented 4 weeks ago

ok,我改下看看