Aspects typically don't have access to the underlying Roslyn code model of the current project. The most significant consequence is that aspects can't access the syntax tree of method implementations. The Metalama.Framework.Code namespace only exposes declarations, not implementation syntax.
If your aspect requires access to the syntax tree, use the Metalama SDK.
Using the Roslyn API
Step 1. Reference the Metalama SDK
To use the Roslyn API from an aspect, your project needs to reference the Metalama.Framework.Sdk package privately, in addition to the regular Metalama.Framework package:
<PackageReference Include="Metalama.Framework.Sdk" Version="$(MetalamaVersion)" PrivateAssets="all" />
<PackageReference Include="Metalama.Framework" Version="$(MetalamaVersion)" />
Step 2. Use the Roslyn API
Your aspect gets access to Roslyn types by using extension methods from the SymbolExtensions class. To access syntax, use ISymbol.DeclaringSyntaxReferences.
For example, use the Roslyn API to get the documentation comment ID for a Metalama declaration:
static string? GetDocumentationCommentId(this IDeclaration metalamaDeclaration)
{
var roslynSymbol = metalamaDeclaration.GetSymbol();
return roslynSymbol.GetDocumentationCommentId();
}