Open sandboxFocus

Class DeclarationExtensions

Extension methods for IDeclaration.

Inheritance
DeclarationExtensions
Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public static class DeclarationExtensions

Methods

Name Description
ContainedChildren(IDeclaration)

Gets the declarations (namespaces, types, methods, properties, fields, constructors, events, indexers) directly contained in the given declaration.

ContainedDescendants(IDeclaration)

Gets the declarations (namespaces, types, methods, properties, fields, constructors, events, indexers) in the given declaration and in any child of the declaration.

ContainedDescendantsAndSelf(IDeclaration)

Gets the declarations (namespaces, types, methods, properties, fields, constructors, events, indexers) in the given declaration and in any child of the declaration, plus the given declaration.

ContainingAncestors(IDeclaration)

Gets all containing ancestors, i.e. declaration.ContainingDeclaration, declaration.ContainingDeclaration.ContainingDeclaration, declaration.ContainingDeclaration.ContainingDeclaration.ContainingDeclaration...

ContainingAncestorsAndSelf(IDeclaration)

Gets all containing ancestors including the current declaration, i.e. declaration, declaration.ContainingDeclaration, declaration.ContainingDeclaration.ContainingDeclaration, declaration.ContainingDeclaration.ContainingDeclaration.ContainingDeclaration...

Enhancements<T>(T)

Gets an object that gives access to the aspects, options and annotations on the current declaration.

ForCompilation<T>(T?, ICompilation)

Gets a representation of the current declaration in a different version of the compilation.

GetClosestMemberOrNamedType(IDeclaration)

Gets the declaring IMemberOrNamedType of a given declaration if the declaration if not an IMemberOrNamedType, or the IMemberOrNamedType itself if the given declaration is itself an IMemberOrNamedType.

GetClosestNamedType(IDeclaration)

Gets the declaring INamedType of a given declaration if the declaration is not an INamedType, or the INamedType itself if the given declaration is itself an INamedType.

GetEffectiveAccessibility(IMember)

Gets the effective accessibility of a member, taking into account the accessibility of all containing types. For example, a public method inside an internal class has an effective accessibility of internal.

GetEffectiveAccessibility(IType)

Gets the effective accessibility of a type, taking into account the accessibility of containing types, element types (for arrays and pointers), and type arguments (for generic types).

GetMembers(INamedType, DeclarationKind)

Gets the collection of members of a specific DeclarationKind.

GetNamespace(IDeclaration)

Gets the namespace of a given declaration, i.e. the namespace itself if the given declaration is a namespace, the closest containing namespace, or the global namespace if an ICompilation is given.

GetTopmostNamedType(IDeclaration)

Gets the topmost type of a nested type, i.e. a type that is not contained in any other type. If the given type is not a nested type, returns the given type itself.

IsAutoPropertyBackingField(IField)

Determines whether the specified field is a compiler-generated backing field for an auto-property.

IsContainedIn(IDeclaration, IDeclaration)

Determines if a given declaration is a child of another given declaration, using the ContainingDeclaration relationship for all declarations except for named type, where the parent namespace is considered.

IsRecordCopyConstructor(IConstructor)

Determines whether a constructor is a compiler-generated record copy constructor.

TryForCompilation<T>(T?, ICompilation, out T?)

Tries to get a representation of the current declaration in a different version of the compilation.

WithDeterministicOrder<T>(IEnumerable<T>)

Sorts a sequence of IDeclaration in a deterministic order. The specific order is an implementation detail; it is guaranteed to be stable across builds but is not part of the public contract. Sort key: Depth, then containing declaration (recursively), then name, then signature (for overloadable members). Useful in aspects to make generated code independent of source declaration order.

get_IsAssembly(DeclarationKind)

Gets a value indicating whether the declaration kind represents an assembly (compilation or assembly reference).

get_IsMember(DeclarationKind)

Determines whether a DeclarationKind represents an IMember (event, field, finalizer, property, indexer, constructor, operator, or method).

get_IsMemberOrNamedType(DeclarationKind)

Determines whether a DeclarationKind represents an IMember or a INamedType.

get_IsNamedDeclaration(DeclarationKind)

Gets a value indicating whether the declaration kind represents a named declaration (method, property, field, event, parameter, type parameter, named type, or namespace).

get_IsType(DeclarationKind)

Determines whether a DeclarationKind represents an IType.

See Also