MetalamaAPI documentationAspect APIMetalama.​Framework.​CodeIDeclaration
Open sandboxFocus

IDeclaration Interface

Represent a declaration.

Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IDeclaration : IDisplayable, IDiagnosticLocation, ICompilationElement, IMeasurable
Remarks

The IDeclaration interface implements System.IEquatable<>. The implementation uses the Default comparer. To use a different comparer, choose a different comparer from IDeclaration.Compilation.Comparers.

Properties

Name Description
Attributes

Gets the collection of custom attributes on the declaration.

BelongsToCurrentProject

Gets a value indicating whether the current declaration is declared to the current project. It returns false for declarations declared in referenced projects or assemblies.

ContainingDeclaration

Gets the containing declaration, such as a INamedType for nested types or for methods. For non-nested types, returns the containing assembly (and not the namespace, use Namespace for that).

DeclarationKind

Gets the kind of declaration.

DeclaringAssembly

Gets the declaring assembly, which can be the current Compilation or a reference assembly.

Depth

Gets the depth of the current declaration in the code model. The value of the Depth property has no absolute meaning, only a relative one, i.e. it is only relevant when comparing the depth of two declarations. A declaration has always a greater depth than the declaration in which it is contained. A type has always a greater depths than the base it derives from or the interfaces it implements.

IsImplicitlyDeclared

Gets a value indicating whether the member is implicitly declared, i.e. declared without being represented in source code. Returns false if it is explicitly declared in code.

Origin

Gets the origin of the current declaration.

Sources

Gets the set of syntax nodes of the source code that declare the current declaration, or an empty set if the current declaration is not backed by source code.

Methods

Name Description
ToRef()

Gets a reference to the compilation, which can be used to identify the current declaration in a different revision of the compilation.

ToSerializableId()

Gets a serializable identifier for the current declaration. This identifier is guaranteed to be deserializable in a different process, even with a different version of Metalama.

Extension Methods

DeclarationExtensions.IsContainedIn(IDeclaration, IDeclaration)
DeclarationExtensions.ContainingAncestors(IDeclaration)
DeclarationExtensions.ContainingAncestorsAndSelf(IDeclaration)
DeclarationExtensions.Enhancements<T>(T)
DeclarationExtensions.GetClosestNamedType(IDeclaration)
DeclarationExtensions.GetTopmostNamedType(IDeclaration)
GenericExtensions.GetOriginalDefinition(IDeclaration)
EligibilityExtensions.IsAspectEligible<T>(IDeclaration, EligibleScenarios)
EligibilityExtensions.IsAspectEligible(IDeclaration, Type, EligibleScenarios)
EligibilityExtensions.IsAdviceEligible(IDeclaration, AdviceKind)
EligibilityExtensions.IsContractAdviceEligible(IDeclaration, ContractDirection)
SymbolExtensions.GetSymbol(IDeclaration)
ContractExtensions.GetContractOptions(IDeclaration)

See Also