views:

222

answers:

2

I've made a very simple aspect, and found a problem when debugging it (see code). I set a breakpoint on the method exit, and it hits inside "entry" method actually. PostSharp 1.5, Visual Studio 2008 SP1
Is this a known bug, are there any workarounds?

class Program
{
 [MyAspect]
 static void Main(string[] args)
 {
  Console.WriteLine("body");
 } // setting breakpoint here
}

[Serializable]
class MyAspect : OnMethodBoundaryAspect
{
 public override void OnEntry(MethodExecutionEventArgs eventArgs)
 { // hits here actually! (debug mode)
  Console.WriteLine("entry"); // hits here actually! (release mode)
 }

 public override void OnExit(MethodExecutionEventArgs eventArgs)
 {
  Console.WriteLine("exit");
 }
}
+1  A: 

Usually this happens when the debugging symbols are out of date or don't match the executable being run.

I use PostSharp and haven't seen anything like this before... Have you tried a rebuild? Or deleting your output folder and then building?

Edit:

So I ran your sample. If you move the MyAspect implementation to another file, when you start debugging the code, the breakpoint becomes unavailable with the message: "The breakpoint will not currently be hit. No executable is associated with this line..."

Without the aspect applied, it doesn't happen. So yes, looks like something in post compile step does cause the issue.

I'll leave this answer here as clarification of the question. If you think its not useful, I can delete it too...

Edit 2: As for workaround: Set the breakpoint to the previous line (not on the closing brace), and then step over the last line of code in the method...

Nader Shirazie
Rebuild/cleanup doesn't change anything. Have you tried executing my sample?
skevar7
This seems to be a .pdb problem. PostSharp modifies only the assembly but not the debug symbol file.
boj
A: 

This may be a bug of PostSharp. You can report it to http://www.postsharp.org/tracker.

Gael Fraiteur