Metalama 1.0 / / Metalama Documentation / Conceptual Documentation / Using Aspects / Debugging Code With Aspects

Debugging Code With Aspects

When debugging code that uses Metalama, by default, the debugger only shows you your original code, without the modifications applied by Metalama. This is convenient when you're using an existing aspect, but when you're developing an aspect, you want to be able to see the transformed code.

There are two options to debug the transformed code.

Option 1. Using the LamaDebug build configuration

The easiest option to debug the transformed code (instead of the source code) is to switch to the build configuration named LamaDebug. This build configuration, besides the default Debug and Release configurations, is automatically defined for any project that imports the Metalama.Framework package.

To create a LamaDebug build configuration using Visual Studio:

  1. In the Build menu, choose Configuration Manager.
  2. In the Active solution configuration list box, choose .
  3. Fill this dialog as follows:

    • Name: LamaDebug (or your own name).
    • Copy settings from: <Empty>.
    • Create new project configurations: No.

      Screenshot

  4. Then, make sure that the solution configuration uses the project configuration named LamaDebug for each project that uses Metalama.

Screenshot

The benefit of this approach is that you can easily switch between source code and transformed code debugging.

Option 2. Setting properties manually

Alternatively, you can set the following MSBuild properties:

            <PropertyGroup>
    <MetalamaFormatOutput>True</MetalamaFormatOutput>
    <MetalamaDebugTransformedCode>True</MetalamaDebugTransformedCode>
    <MetalamaEmitCompilerTransformedFiles>True</MetalamaEmitCompilerTransformedFiles>
</PropertyGroup>

          

For details about these properties, see MSBuild Configuration Properties and Items.