Open sandboxFocus

Class SymbolExtensions

Provides extension methods to bridge between the Metalama code model (IDeclaration, IType, etc.) and the Roslyn symbol model (ISymbol).

Inheritance
SymbolExtensions
Namespace: Metalama.Framework.Engine.CodeModel
Assembly: Metalama.Framework.Sdk.dll
Syntax
public static class SymbolExtensions
Remarks

This class enables aspect weavers to convert Metalama declarations to Roslyn symbols for use with the Roslyn API. It also provides methods to go from Roslyn symbols back to Metalama declarations.

Common operations:

Methods

Name Description
GetDeclaration(ICompilation, ISymbol)
GetExpressionType(ISymbol)
GetOverriddenMember(ISymbol?, bool)
GetRootDefinition(IFieldSymbol)
GetRootDefinition(ISymbol)
GetRoslynCompilation(ICompilation)

Gets the underlying Roslyn Compilation from a Metalama ICompilation.

GetSemanticModel(ICompilation, SyntaxTree)
GetSymbol(IAssembly, bool)

Gets the Roslyn IAssemblySymbol for a Metalama IAssembly.

GetSymbol(ICompilationElement, bool)

Gets the Roslyn ISymbol for a Metalama declaration.

GetSymbol(IEvent, bool)

Gets the Roslyn IEventSymbol for a Metalama IEvent.

GetSymbol(IField, bool)

Gets the Roslyn IFieldSymbol for a Metalama IField.

GetSymbol(IMethodBase, bool)

Gets the Roslyn IMethodSymbol for a Metalama IMethodBase (method or constructor).

GetSymbol(INamedType, bool)

Gets the Roslyn INamedTypeSymbol for a Metalama INamedType.

GetSymbol(IParameter, bool)

Gets the Roslyn IParameterSymbol for a Metalama IParameter.

GetSymbol(IProperty, bool)

Gets the Roslyn IPropertySymbol for a Metalama IProperty.

GetSymbol(IRef, Compilation, bool)
GetSymbol(IType, bool)

Gets the Roslyn ITypeSymbol for a Metalama IType.

GetSymbol(ITypeParameter, bool)

Gets the Roslyn ITypeParameterSymbol for a Metalama ITypeParameter.

IsDefinitionSafe(ISymbol)
TryGetDeclaration(ICompilation, ISymbol, out IDeclaration?)

See Also