0

In release mode Postsharp enhanced methods lose the line numbers etc for the calling method only. This is despite the pdb file being provided. If i don't use Postsharp the line number etc are included.

Is there a workaround for this?

Edit:

Here is the output from my logger of the stack trace captured within the OnMethodBoundry aspect:

TestStackTrace.PSOnEntryExit.OnEntry at offset 104 in file:line:column T:\My Projects\TestStackTrace\TestStackTrace\PostScript.cs:33:4

TestStackTrace.Program.testMethod at offset 122 in file:line:column :16777215:0

TestStackTrace.Program.Main at offset 98 in file:line:column T:\My Projects\TestStackTrace\TestStackTrace\Program.cs:21:4

The file:line:column numbers are 'mangled' only when the project is processed by SmartAssembly. SmartAssembly does not need to be configured to actually do anything specific. Indeed, I have left all SmartAssembly options unticked in my efforts to isolate the issue.

David
  • 958
  • 2
  • 12
  • 29
  • We are not able to reproduce this. Could you please share a sample project, including steps to reproduce and the stack trace you see? We also need to know which version of Visual Studio, PostSharp Tools for Visual Studio and PostSharp NuGet package you use. – Antonín Procházka Sep 13 '17 at 12:46
  • @AntonínProcházka Vs2015, PostSharp 4.05. Download link [link](http://aquarius.com.au/trash/teststacktrace.zip) . – David Sep 15 '17 at 22:42
  • The project contains missing references, so I can't build it. Have you tried the latest PostSharp version to see if this behavior hasn't been fixed already? – Antonín Procházka Sep 19 '17 at 09:57
  • The version 4.1.20 (not really 4.05) is quite old and may contain bugs related to PDB reading and writing. It also seem that there is some problem with the aspect - when I use simple StackTrace output, everything seems to point to the correct line. – Daniel Balas Sep 19 '17 at 10:17
  • Also note that since PostSharp reconstructs the method, there are some quirks with sequence point order and location (e.g. sequence point on the opening brace is hit before OnEntry). In case of method interception, the original declaration (method with the original name) that executes `OnInvoke` advice never shows any sequence points. Also, in newer builds of PostSharp 4.3 and later we use arbitrary sequence points that are used by the debugger plugin (e.g. `0xfeefed`). – Daniel Balas Sep 19 '17 at 10:27
  • @danielbalas There are two methods in the example code. Both are identical except the second one has the aspect applied. Change the logging backend to your favourite tool and you will see it works fine. Now process it thru an obfuscator and the aspect loses the line numbers. The methods still have their line numbers, only the code within the aspect loses the line number. I hadn't discovered the obfuscator seems to be the culprit until recently. – David Sep 19 '17 at 23:09

0 Answers0