Is there a way to enter the code at build time?

I want to enter the following line at the beginning of each method of my application

Trace.WriteLine(this.GetType().Name + "." + "Name of Method");

I would like to do this at compile time or build time or post build time - mostly before it gets into the hands of the client.

Is it possible?

+3
source share
2 answers

You should learn PostSharp , which is designed for this kind of thing. I do not know if he received the attribute exactly for this use case, but I would assume that it would not be difficult to write.

EDIT: - Mono.Cecil, . , .

+4

, , , , PostSharp, .

+1

Source: https://habr.com/ru/post/1728338/


All Articles