Fody/MethodTimer

Some async methods throw InvalidOperationException

GeertvanHorrik opened this issue · 4 comments

Describe the issue

With the new update, some (not all!) methods throw this exception:

System.InvalidOperationException: 'Could not execute the method because either the method itself or the containing type is not fully instantiated.'

Minimal Repro

This happens to Orchestra. I will try to figure out what exactly is happening and why it's causing issues.

Make an effort to fix the bug

Working on it!

Seems to happen on generic methods (so not the class, but the method is generic).

Figured it out, the casts don't have the generic info on them:

image

Looks much better since there is no need for casting anymore (since using the right generic instance types):

image

Interesting, this bug has been in there forever, just never caused exceptions. The reason it's breaking now is because I've moved the Stop logic into a separate method (smaller IL code).