Outbound
Gets an object that provides fabric-like capabilities for adding child aspects, validators, and diagnostics to code transformed by later aspects. This allows aspects to work with the final transformed code, not just the immediate target.
Declaration
IQuery<out TAspectTarget> Outbound { get; }Property Value
| Type | Description |
|---|---|
| IQuery<TAspectTarget> |
Remarks
The Outbound property functions like having a fabric embedded within your aspect. It allows you to:
-
Add child aspects: Apply aspects to related declarations using
Outbound.SelectMany(...).AddAspect() -
Register validators: Validate code after all aspects have been applied using
Outbound.Validate() -
Validate references: Check how other code references the target using
Outbound.ValidateInboundReferences() - Report diagnostics: Report or suppress diagnostics on the final transformed code
Key difference from builder: Operations performed through Outbound execute after all aspects ordered
after the current aspect have completed. This lets you work with the fully transformed code rather than just the immediate state.
In contrast, advice added directly through the builder (e.g., builder.Override()) works with the code in its current state.
Typical usage pattern: Use Outbound to add child aspects to members of the target type, validate final code structure,
or ensure that introduced members are used correctly after all transformations.
Examples
// Add a logging aspect to all methods in the target type
builder.Outbound.SelectMany(t => t.Methods).AddAspect<LoggingAspect>();
// Validate that the transformed code meets requirements
builder.Outbound.Validate(declaration => {
if (declaration.Methods.Count == 0)
builder.Diagnostics.Report(MyDiagnostics.NoMethods);
});