Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows.Generators/Models/AnalysisResult.cs
T
ea7818d390 Python: .NET: Executor source gen for workflow executor routing (#3131)
* Roslyn Source Generators for Workflow Executor Routing.

* Update dotnet/src/Microsoft.Agents.AI.Workflows.Generators/ExecutorRouteGenerator.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* WIP.

* All fixed up except dangling sends/yields attriutes, working on that next.

* Add protocol-only generation for SendsMessage/YieldsOutput attributes

* Ensuring collections that can change order are sorted to enable pipeline caching.

* Improvents per PR feedback.

---------

Co-authored-by: alliscode <bentho@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-22 16:02:12 +00:00

51 lines
2.0 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
namespace Microsoft.Agents.AI.Workflows.Generators.Models;
/// <summary>
/// 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 <see cref="Diagnostic"/> objects.
/// </summary>
/// <param name="executorInfo">The executor information.</param>
/// <param name="diagnostics">Any diagnostics to report.</param>
internal sealed class AnalysisResult(ExecutorInfo? executorInfo, ImmutableArray<Diagnostic> diagnostics)
{
/// <summary>
/// Gets the executor information.
/// </summary>
public ExecutorInfo? ExecutorInfo { get; } = executorInfo;
/// <summary>
/// Gets the diagnostics to report.
/// </summary>
public ImmutableArray<Diagnostic> Diagnostics { get; } = diagnostics.IsDefault ? ImmutableArray<Diagnostic>.Empty : diagnostics;
/// <summary>
/// Creates a successful result with executor info and no diagnostics.
/// </summary>
public static AnalysisResult Success(ExecutorInfo info) =>
new(info, ImmutableArray<Diagnostic>.Empty);
/// <summary>
/// Creates a result with only diagnostics (no valid executor info).
/// </summary>
public static AnalysisResult WithDiagnostics(ImmutableArray<Diagnostic> diagnostics) =>
new(null, diagnostics);
/// <summary>
/// Creates a result with executor info and diagnostics.
/// </summary>
public static AnalysisResult WithInfoAndDiagnostics(ExecutorInfo info, ImmutableArray<Diagnostic> diagnostics) =>
new(info, diagnostics);
/// <summary>
/// Creates an empty result (no info, no diagnostics).
/// </summary>
public static AnalysisResult Empty => new(null, ImmutableArray<Diagnostic>.Empty);
}