Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Method Message #507

Open
RichardReukemaOptimus opened this issue Feb 11, 2023 · 1 comment
Open

Start Method Message #507

RichardReukemaOptimus opened this issue Feb 11, 2023 · 1 comment

Comments

@RichardReukemaOptimus
Copy link

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants