From 27018d615d3a9e16a78e0cfbcd1cc81344164a51 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 13 May 2026 19:43:17 +0000 Subject: [PATCH] Use TFM-specialized count check: TryGetNonEnumeratedCount for NET6+, ICollection pattern for NETFX Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/8ec28a43-e7b7-456e-8d8e-921511b4accc Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com> --- .../WorkflowBuilderExtensions.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs index eeeaf63bc8..a771f89878 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs @@ -114,7 +114,11 @@ public static class WorkflowBuilderExtensions Func predicate = WorkflowBuilder.CreateConditionFunc((Func)IsAllowedType)!; +#if NET6_0_OR_GREATER if (targets.TryGetNonEnumeratedCount(out int count) && count == 1) +#else + if (targets is ICollection { Count: 1 }) +#endif { return builder.AddEdge(source, Throw.IfNull(targets.First(), nameof(targets)), predicate); }