// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Agents.AI.Workflows.Generators.Models;
///
/// Represents the result of analyzing a single method with [MessageHandler].
/// Contains both the method's handler info and class context for grouping.
/// Uses value-equatable types to support incremental generator caching.
///
///
/// Class-level validation (IsPartialClass, DerivesFromExecutor, HasManualConfigureProtocol)
/// is extracted here but validated once per class in CombineMethodResults to avoid
/// redundant validation work when a class has multiple handlers.
///
internal sealed record MethodAnalysisResult(
// Class identification for grouping
string ClassKey,
// Class-level info (extracted once per method, will be same for all methods in class)
string? Namespace,
string ClassName,
string? GenericParameters,
bool IsNested,
string ContainingTypeChain,
bool BaseHasConfigureProtocol,
ImmutableEquatableArray ClassSendTypes,
ImmutableEquatableArray ClassYieldTypes,
// Class-level facts (used for validation in CombineMethodResults)
bool IsPartialClass,
bool DerivesFromExecutor,
bool HasManualConfigureProtocol,
// Class location for diagnostics (value-equatable)
DiagnosticLocationInfo? ClassLocation,
// Method-level info (null if method validation failed)
HandlerInfo? Handler,
// Method-level diagnostics only (class-level diagnostics created in CombineMethodResults)
ImmutableEquatableArray Diagnostics)
{
///
/// Gets an empty result for invalid targets (e.g., attribute on non-method).
///
public static MethodAnalysisResult Empty { get; } = new(
string.Empty, null, string.Empty, null, false, string.Empty,
false, ImmutableEquatableArray.Empty, ImmutableEquatableArray.Empty,
false, false, false,
null, null, ImmutableEquatableArray.Empty);
}