// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Agents.AI.Workflows.Generators.Models;
///
/// Contains all information needed to generate code for an executor class.
/// Uses record for automatic value equality, which is required for incremental generator caching.
///
/// The namespace of the executor class.
/// The name of the executor class.
/// The generic type parameters of the class (e.g., "<T, U>"), or null if not generic.
/// Whether the class is nested inside another class.
/// The chain of containing types for nested classes (e.g., "OuterClass.InnerClass"). Empty string if not nested.
/// Whether the base class has a ConfigureRoutes method that should be called.
/// The list of handler methods to register.
/// The types declared via class-level [SendsMessage] attributes.
/// The types declared via class-level [YieldsOutput] attributes.
internal sealed record ExecutorInfo(
string? Namespace,
string ClassName,
string? GenericParameters,
bool IsNested,
string ContainingTypeChain,
bool BaseHasConfigureProtocol,
ImmutableEquatableArray Handlers,
ImmutableEquatableArray ClassSendTypes,
ImmutableEquatableArray ClassYieldTypes)
{
///
/// Gets whether any "Sent" message type registrations should be generated.
///
public bool ShouldGenerateSentMessageRegistrations => !this.ClassSendTypes.IsEmpty || this.HasHandlerWithSendTypes;
///
/// Gets whether any "Yielded" output type registrations should be generated.
///
public bool ShouldGenerateYieldedOutputRegistrations => !this.ClassYieldTypes.IsEmpty || this.HasHandlerWithYieldTypes;
///
/// Gets whether any handler has explicit Send types.
///
public bool HasHandlerWithSendTypes
{
get
{
foreach (var handler in this.Handlers)
{
if (!handler.SendTypes.IsEmpty)
{
return true;
}
}
return false;
}
}
///
/// Gets whether any handler has explicit Yield types or output types.
///
public bool HasHandlerWithYieldTypes
{
get
{
foreach (var handler in this.Handlers)
{
if (!handler.YieldTypes.IsEmpty)
{
return true;
}
if (handler.HasOutput)
{
return true;
}
}
return false;
}
}
}