Metalama icon indicating copy to clipboard operation
Metalama copied to clipboard

Debugging aspected code without extra effort

Open ekmedinet opened this issue 1 year ago • 4 comments

When we try to debug a method that has aspects, debugger behaves strangely seemingly not in sync with its binary.

After trying the recommendation in this link we can debug, but it seems like a hassle if we don't need to debug the actual aspects.

Is there a way to enable default debugging behavior, so that we don't need to use LamaDebug configuration and debug through aspect code to get to the code we are interested in?

Thanks!

ekmedinet avatar Nov 26 '24 02:11 ekmedinet

Hello,

LamaDebug, among other things, sets the MetalamaDebugTransformedCode property to True, which enables the debugging.

So, if you create Directory.Build.props that looks like the following, you should get the behavior you want:

<?xml version="1.0" encoding="utf-8" ?>
<Project>
    <PropertyGroup>
        <MetalamaDebugTransformedCode Condition="$(Configuration) == 'Debug'">True</MetalamaDebugTransformedCode>
    </PropertyGroup>
</Project>

However, note that this would also automatically format the output code, which results in worse build performance for all Debug builds.

addabis avatar Nov 26 '24 12:11 addabis

Thank you for response @addabis , your solution helps in a way that we don't have to create separate LamaDebug configuration.

The drawback however is that we still see aspect code and have to debug through it (though 99 percent of time we are not interested in that).

So it is not possible to debug only our custom code like we were able with PostSharp?

ekmedinet avatar Nov 27 '24 00:11 ekmedinet

If there is a defect in debugging behavior, it would be best to record a video demonstrating the issue and give the code of the aspect that causes it.

gfraiteur avatar Nov 27 '24 06:11 gfraiteur

@gfraiteur, I thought this was expected behavior. When not using LamaDebug configuration it looks like debug pointer is following hidden aspect code, jumping around custom code. Similar to when binary being debugged is not in sync with source code.

I will try to prepare test project shortly.

ekmedinet avatar Nov 27 '24 21:11 ekmedinet

Closed because we don't know how to reproduce the issue.

gfraiteur avatar Apr 26 '25 17:04 gfraiteur