Open sandboxFocus

Interface ITaggedQuery<TDeclaration, TTag>

Represents a LINQ-like query over a set of code declarations where each declaration is associated with a tag. Create using WithTag<TTag>(Func<TDeclaration, TTag>). Tags allow you to pass additional data alongside declarations through query transformations, enabling context-aware aspect application and configuration.

Namespace: Metalama.Framework.Fabrics
Assembly: Metalama.Framework.dll
Syntax
public interface ITaggedQuery<out TDeclaration, out TTag> : IQuery<TDeclaration>, IQuery where TDeclaration : class, IDeclaration
Type Parameters
Name Description
TDeclaration

The type of declarations in the current query result set (e.g., INamedType, IMethod, IProperty).

TTag

The type of the tag associated with each declaration in the query.

Remarks

Tagged queries extend IQuery<TDeclaration> by associating arbitrary data (tags) with each declaration. This allows you to carry context through query transformations. For example, when adding aspects based on attribute data, you can tag declarations with the attribute instance and later use that tag when configuring the aspect.

Many methods in this interface have overloads that accept the tag as a parameter to the selector or predicate delegates, allowing you to make decisions based on both the declaration and its associated tag.

Extension methods for this interface are provided by:

  • AspectQueryExtensions - for adding aspects with tag-based configuration
  • OptionQueryExtensions - for configuring options based on tags
  • DiagnosticsQueryExtensions - for reporting diagnostics
  • QueryExtensions - for additional querying capabilities
  • Metalama.Extensions.Architecture.Predicates.PredicateExtensions - for architecture validation predicates
  • Metalama.Extensions.Validation.ValidationQueryExtensions - for validation rules
  • Metalama.Extensions.Validation.ReferenceValidationQueryExtensions - for reference validation
  • Metalama.Extensions.CodeFixes.CodeFixQueryExtensions - for code fix suggestions

Methods

Name Description
OfType<TOut>()

Selects all declarations of a given type.

SelectMany<TMember>(Func<TDeclaration, IEnumerable<TMember>>)

Projects each declaration of the current set to an IEnumerable<T> (typically a list of child declarations) and flattens the resulting sequences into one set.

SelectMany<TMember>(Func<TDeclaration, TTag, IEnumerable<TMember>>)

Projects each declaration of the current set to an IEnumerable<T> (typically a list of child declarations) and flattens the resulting sequences into one set. This overload does supplies the tag to the selector delegate.

SelectTypes(bool)

Selects all types enclosed in declarations of the current set.

SelectTypesDerivedFrom(INamedType, DerivedTypesOptions)

Selects all types, among those enclosed in declarations of the current set, that derive from or implement a given INamedType.

SelectTypesDerivedFrom(Type, DerivedTypesOptions)

Selects all types, among those enclosed in declarations of the current set, that derive from or implement a given Type.

Select<TMember>(Func<TDeclaration, TTag, TMember>)

Projects each declaration of the current set into a new declaration. This overload does supplies the tag to the selector delegate.

Select<TMember>(Func<TDeclaration, TMember>)

Projects each declaration of the current set into a new declaration.

Tag<TNewTag>(Func<TDeclaration, TTag, TNewTag>)
Tag<TNewTag>(Func<TDeclaration, TNewTag>)
Where(Func<TDeclaration, bool>)

Filters the set of declarations based on a predicate.

Where(Func<TDeclaration, TTag, bool>)

Filters the set of declarations based on a predicate. This overload does supplies the tag to the predicate delegate.

WithTag<TNewTag>(Func<TDeclaration, TTag, TNewTag>)

Projects the declarations in the current set by replacing the tag of each declaration. This overload does supplies the old tag to the getTag delegate.

WithTag<TNewTag>(Func<TDeclaration, TNewTag>)

Projects the declarations in the current set by replacing the tag of each declaration.

Extension Methods

See Also