Search code examples
c#aoppostsharp

Postsharp for compile time line numbers


I would like to show line numbers for my trace messages.

Example Trace: SomeMethodUsingPostSharpOnEntry (Line:74): Done doing something.

I cannot use stackframe/trace (runtime reflection solution & not sure if pdb's will be distributed).

Already looked at Microsoft options (http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/6a7b021c-ec81-47c5-8f6a-2e280d548f3f) and pdb based solutions (How can I include line numbers in a stack trace without a pdb?).

Is there any way to get/make a LINE macro equivalent using Postsharp or otherwise?


Solution

  • It's not much help now, but C# 5 will have this via "caller info attributes". Read the C# team blog post about C# 5 and VS 11 beta for more information, or see the docs for these attributes: