Fody / MethodTimer

Injects some very basic method timing code.
MIT License
719 stars 69 forks source link

Start Method Message #507

Open RichardReukemaOptimus opened 1 year ago

RichardReukemaOptimus commented 1 year ago

I would like to have a message at the start of the method, as method start, other async methods execute, and it causes confusion in the call train.

I tried to update the AsyncMethodProcessor within the InjectStopWatchStart - after a couple of hours understanding the flow....

I tried to add these two lines (for what its worth) //todo: write method start time message Instruction.Create(OpCodes.Ldstr, string.Concat(Method.FullName,"-Start") ), Instruction.Create(OpCodes.Call, ModuleWeaver.TraceWriteLineMethod)

but after I compiled, and incorporated in to my solution - it seems that I broke the entire Nuget package. I'm not looking for someone to do the work for me, but I would like to know If I'm on the right track, and how to incorporate a new version into my project without loosing all reference resolution to the Time attribute.

I also tried adding this constructuor on the time attribute: using a optional parameter to avoid a change in parameter or method signature:

public TimeAttribute(string format, bool WriteStartMessage = false) { }

but i didn't get as far in understanding how the MethodTimer uses either of these CTOR....

I'm new to Fody, but aware of what IL weaving, just never really got into it.

Regards RIchard

GeertvanHorrik commented 1 year ago

The best way to start working on Fody weavers is to:

  1. Create unit tests
  2. Create example code (in release mode), then view the generated IL using a tool like IL Spy

Then you can copy the generated code instructions and should be able to figure out what needs to be injected.