|
| 1 | +namespace PatternKit.Generators.Composer; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Marks a partial type as a composer pipeline host that will generate deterministic |
| 5 | +/// composition of ordered components into a single executable pipeline. |
| 6 | +/// </summary> |
| 7 | +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] |
| 8 | +public sealed class ComposerAttribute : Attribute |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Gets or sets the name of the generated synchronous invoke method. |
| 12 | + /// Default is "Invoke". |
| 13 | + /// </summary> |
| 14 | + public string InvokeMethodName { get; set; } = "Invoke"; |
| 15 | + |
| 16 | + /// <summary> |
| 17 | + /// Gets or sets the name of the generated asynchronous invoke method. |
| 18 | + /// Default is "InvokeAsync". |
| 19 | + /// </summary> |
| 20 | + public string InvokeAsyncMethodName { get; set; } = "InvokeAsync"; |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// Gets or sets whether to generate async methods. |
| 24 | + /// When null (default), async generation is inferred from the presence of async steps or terminal. |
| 25 | + /// Note: Nullable bool in attributes is non-standard but supported by C#. |
| 26 | + /// Set to true/false explicitly to control async generation, or leave unset for inference. |
| 27 | + /// </summary> |
| 28 | + public bool? GenerateAsync { get; set; } |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// Gets or sets whether to force async generation even if all steps are synchronous. |
| 32 | + /// Default is false. |
| 33 | + /// </summary> |
| 34 | + public bool ForceAsync { get; set; } |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Gets or sets the wrapping order for pipeline steps. |
| 38 | + /// Default is OuterFirst (step with Order=0 is outermost). |
| 39 | + /// </summary> |
| 40 | + public ComposerWrapOrder WrapOrder { get; set; } = ComposerWrapOrder.OuterFirst; |
| 41 | +} |
| 42 | + |
| 43 | +/// <summary> |
| 44 | +/// Defines the order in which pipeline steps wrap each other. |
| 45 | +/// </summary> |
| 46 | +public enum ComposerWrapOrder |
| 47 | +{ |
| 48 | + /// <summary> |
| 49 | + /// Steps with lower Order values wrap steps with higher Order values. |
| 50 | + /// Order=0 is the outermost wrapper (executes first). |
| 51 | + /// </summary> |
| 52 | + OuterFirst = 0, |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Steps with higher Order values wrap steps with lower Order values. |
| 56 | + /// Order=0 is the innermost wrapper (executes last, closest to terminal). |
| 57 | + /// </summary> |
| 58 | + InnerFirst = 1 |
| 59 | +} |
0 commit comments