// Copyright (c) Microsoft. All rights reserved. using System.Collections.Immutable; using Microsoft.CodeAnalysis; namespace Microsoft.Agents.AI.Workflows.Generators.Models; /// /// Represents the result of analyzing a class with [MessageHandler] attributed methods. /// Combines the executor info (if valid) with any diagnostics to report. /// Note: Instances of this class should not be used within the analyzers caching /// layer because it directly contains a collection of objects. /// /// The executor information. /// Any diagnostics to report. internal sealed class AnalysisResult(ExecutorInfo? executorInfo, ImmutableArray diagnostics) { /// /// Gets the executor information. /// public ExecutorInfo? ExecutorInfo { get; } = executorInfo; /// /// Gets the diagnostics to report. /// public ImmutableArray Diagnostics { get; } = diagnostics.IsDefault ? ImmutableArray.Empty : diagnostics; /// /// Creates a successful result with executor info and no diagnostics. /// public static AnalysisResult Success(ExecutorInfo info) => new(info, ImmutableArray.Empty); /// /// Creates a result with only diagnostics (no valid executor info). /// public static AnalysisResult WithDiagnostics(ImmutableArray diagnostics) => new(null, diagnostics); /// /// Creates a result with executor info and diagnostics. /// public static AnalysisResult WithInfoAndDiagnostics(ExecutorInfo info, ImmutableArray diagnostics) => new(info, diagnostics); /// /// Creates an empty result (no info, no diagnostics). /// public static AnalysisResult Empty => new(null, ImmutableArray.Empty); }