diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/ObsoleteAttributes.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/ObsoleteAttributes.cs new file mode 100644 index 0000000000..87ffb7f89a --- /dev/null +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/ObsoleteAttributes.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System; +using Microsoft.Shared.Diagnostics; + +namespace Microsoft.Agents.AI.Workflows; + +/// +/// Declares that an executor may yield messages of the specified type as workflow outputs. +/// +/// +/// +/// Apply this attribute to an class to declare the types of messages +/// it may yield via . This information is used +/// for protocol validation and documentation. +/// +/// +/// This attribute can be applied multiple times to declare multiple output types. +/// It is inherited by derived classes, allowing base executors to declare common output types. +/// +/// +/// +/// +/// [YieldsMessage(typeof(FinalResult))] +/// [YieldsMessage(typeof(StreamChunk))] +/// public partial class MyExecutor : Executor +/// { +/// // ... +/// } +/// +/// +[Obsolete("Use YieldsOutput instead. The Code Generator and the runtime attribute-based type mapping ignore this attribute.")] +[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] +public sealed class YieldsMessageAttribute : Attribute +{ + /// + /// Gets the type of message that the executor may yield. + /// + public Type Type { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The type of message that the executor may yield. + /// is . + public YieldsMessageAttribute(Type type) + { + this.Type = Throw.IfNull(type); + } +} + +/// +/// This attribute indicates that a message handler streams messages during its execution. +/// +[Obsolete("This attribute does not do anything. The Code Generator and the runtime attribute-based type mapping ignore this attribute.")] +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] +public sealed class StreamsMessageAttribute : Attribute +{ + /// + /// The type of the message that the handler yields. + /// + public Type Type { get; } + + /// + /// Indicates that the message handler yields streaming messages during the course of execution. + /// + public StreamsMessageAttribute(Type type) + { + // This attribute is used to mark executors that yield messages. + this.Type = Throw.IfNull(type); + } +}