Open sandboxFocus
  • TOC

Metalama Documentation

Getting started

Video tutorials

Conceptual documentation

Commented examples

API documentation

Aspect API

Metalama.​Framework.​Advising

Metalama.​Framework.​Aspects

Metalama.​Framework.​Code

Accessibility

Accessibility­Extensions

Async­Info

Attribute­Extensions

Code­Display­Context

Code­Display­Format

Compilation­Extensions

Constructor­Collection­Extensions

Constructor­Initializer­Kind

Conversion­Kind

Declaration­Enhancements<T>

Declaration­Extensions

Declaration­Kind

Declaration­Origin­Kind

Derived­Types­Options

Enumerable­Kind

Execution­Scope

Generic­Extensions

IAnnotation

IAnnotation<T>

IAspect­Declaration­Origin

IAssembly

IAssembly­Identity

IAttribute

IAttribute­Data

ICompilation

ICompilation­Element

IConstructor

IDeclaration

IDeclaration­Cache

IDeclaration­Factory

IDeclaration­Origin

IDisplayable

IEvent

IExpression

IField

IField­Or­Property

IField­Or­Property­Or­Indexer

IGeneric

IGeneric­Context

IHas­Accessors

IHas­Parameters

IHas­Type

IIndexer

IManaged­Resource

IMember

IMember­Or­Named­Type

IMethod

IMethod­Base

INamed­Declaration

INamed­Type

INamespace

INamespace­Or­Named­Type

IObject­Creation­Expression

IParameter

IProperty

IProperty­Or­Indexer

IRef

IRef<T>

ISource­Expression

Iterator­Info

IType

IType­Parameter

Member­Extensions

Method­Collection­Extensions

Method­Extensions

Method­Kind

Named­Type­Extensions

Namespace­Extensions

Operator­Category

Operator­Kind

Operator­Kind­Extensions

Ref­Comparison

Ref­Extensions

Ref­Kind

Ref­Kind­Extensions

Reflection­Extensions

Serializable­Declaration­Id

Serializable­Type­Id

Source­Reference

Source­Span

Special­Type

Typed­Constant

Type­Extensions

Type­Factory

Type­Kind

Type­Kind­Constraint

Type­Parameter­Kind

Variance­Kind

Writeability

Metalama.​Framework.​Code.​Collections

Metalama.​Framework.​Code.​Comparers

Metalama.​Framework.​Code.​Declaration­Builders

Metalama.​Framework.​Code.​Invokers

Metalama.​Framework.​Code.​Syntax­Builders

Metalama.​Framework.​Code.​Types

Metalama.​Framework.​Code­Fixes

Metalama.​Framework.​Diagnostics

Metalama.​Framework.​Eligibility

Metalama.​Framework.​Fabrics

Metalama.​Framework.​Metrics

Metalama.​Framework.​Options

Metalama.​Framework.​Project

Metalama.​Framework.​Run­Time

Metalama.​Framework.​Serialization

Metalama.​Framework.​Services

Metalama.​Framework.​Utilities

Metalama.​Framework.​Validation

Extensions API

Patterns API

Flashtrace API

Introspection API

Advanced API

Post­Sharp API migration

  • Article

Interface IDeclaration

Represent a declaration.

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

The IDeclaration interface implements IEquatable<T>. 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 ContainingNamespace for that).

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.

GenericContext

Gets the IGenericContext for the current declaration.

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. The reference object is compile-time serializable. It is guaranteed to be deserializable in a different process, even with a different version of Metalama.

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

See Also