Open sandboxFocus

Class AttributeExtensions

Extension methods for the IAttribute interface.

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

Methods

Name Description
Construct(IAttribute)
Construct<T>(IAttribute)
GetArgumentValue<T>(IAttribute, string, T?)

Tries to gets the value of an argument given its name, considering both NamedArguments and ConstructorArguments. For constructor arguments, the name of the corresponding parameter is taken into account. Comparisons are case-insensitive. In case of ambiguity, the first match wins.

ToAttributeConstruction(IAttribute)

Converts an IAttribute to an AttributeConstruction object.

TryConstruct(IAttribute, ScopedDiagnosticSink, out Attribute?)

Tries to construct an instance of the attribute represented by the current IAttribute. The attribute type must not be a run-time-only type.

TryConstruct(IAttribute, out Attribute?)
TryGetArgumentValue<T>(IAttribute, string, out T)

Tries to gets the value of an argument given its name, considering both NamedArguments and ConstructorArguments. For constructor arguments, the name of the corresponding parameter is taken into account. Comparisons are case-insensitive. In case of ambiguity, the first match wins.

TryGetNamedArgument(IAttribute, string, out TypedConstant)

Tries to get a named argument (i.e. the value assigned to a field or property).