Open JasonBock opened 2 years ago
Thank you @JasonBock . it is indeed interesting case. AspectInjector only works with Portable Mode so if there is embedded pdb it will modify the code but won't modify the debug Symbols.
I'll rename this issue to track this feature.
That makes sense. If that debug mode isn't supported and that's documented, that works (and again, we usually don't set that mode anyway, so removing it was fine by us). But I get why you want to track this to see if it is something you can potentially support in the future.
setting <DebugType>Embedded</DebugType>
allows visual studio to set breakpoints in a referenced nuget package's source code while debugging. Just ran across this issue, is there any support for this or workarounds?
Note: I did this using different permutations of .NET 5 and .NET 6 target frameworks along with the 2.5.0, 2.6.0, and 2.6.1 versions of AspectInjector, and I believe they all have the same behavior.
Here's the setup. First, make a class library that references AspectInjector (call it
AspectInjectorInvestigation
). Make sure this setting is in the .csproj file:Add the
LogCallAttribute
from the readme file, just so you have an aspect in the library.Next, make another class library called
AspectInjectorInvestigation.Usage
that referencesAspectInjectorInvestigation
. Put one class in it that does something like this:Finally, make a test class library called
AspectInjectorInvestigation.Usage.Tests
(I just used the xUnit template in VS to get it set up). This will referenceAspectInjectorInvestigation.Usage
. Add a test like this:Make sure you're building in
Debug
mode, and put a breakpoint on the code inLogEnter()
method inLogCallAttribute
.What should happen when you run the test in the debugger is that the breakpoint isn't hit. If I remove the
<DebugMode>
setting, then the breakpoint is hit.Also, I've noticed that with the
<DebugMode>
setting, code coverage isn't done for that class library. If it's removed, code coverage works.This isn't a showstopper, because the aspect injection works. We only noticed it when we added code coverage metrics in our CI/CD process. We decided to remove that
<DebugMode>
setting. We weren't sure why it was there in the first place (it was code we inherited :) ), and we don't put that setting into our projects by default. Just wanted to make you aware of this.