Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support <DebugType> Embedded #175

Open
JasonBock opened this issue Jan 21, 2022 · 2 comments
Open

Support <DebugType> Embedded #175

JasonBock opened this issue Jan 21, 2022 · 2 comments

Comments

@JasonBock
Copy link

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:

<DebugType>Embedded</DebugType>

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 references AspectInjectorInvestigation. Put one class in it that does something like this:

public sealed class LogCallUsage
{
  [LogCall]
  public void DoIt() { }
}

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 reference AspectInjectorInvestigation.Usage. Add a test like this:

[Fact]
public static void LogCall()
{
  var usage = new LogCallUsage();
  usage.DoIt();
}

Make sure you're building in Debug mode, and put a breakpoint on the code in LogEnter() method in LogCallAttribute.

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.

@pamidur
Copy link
Owner

pamidur commented Jan 21, 2022

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.

@pamidur pamidur changed the title Setting <DebugType> to Embedded Prevents Debugging and Code Coverage Support <DebugType> to Embedded Jan 21, 2022
@pamidur pamidur changed the title Support <DebugType> to Embedded Support <DebugType> Embedded Jan 21, 2022
@JasonBock
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants