Clarify null element validation messages

Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/af831ee2-0a99-4427-9ffd-a3b5022c1b3b

Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-13 19:14:55 +00:00
committed by GitHub
Unverified
parent 9c839ea6eb
commit 9a02dafbc3
2 changed files with 17 additions and 5 deletions
@@ -37,9 +37,13 @@ public sealed class SwitchBuilder
HashSet<int> indicies = [];
foreach (ExecutorBinding executor in executors)
int executorIndex = 0;
foreach (ExecutorBinding? executor in executors)
{
Throw.IfNull(executor, nameof(executors));
if (executor is null)
{
throw new ArgumentNullException(nameof(executors), $"Executors collection contains a null element at index {executorIndex}.");
}
if (!this._executorIndicies.TryGetValue(executor.Id, out int index))
{
@@ -49,6 +53,7 @@ public sealed class SwitchBuilder
}
indicies.Add(index);
executorIndex++;
}
Func<object?, bool> casePredicate = WorkflowBuilder.CreateConditionFunc(predicate)!;
@@ -66,9 +71,13 @@ public sealed class SwitchBuilder
{
Throw.IfNull(executors);
foreach (ExecutorBinding executor in executors)
int executorIndex = 0;
foreach (ExecutorBinding? executor in executors)
{
Throw.IfNull(executor, nameof(executors));
if (executor is null)
{
throw new ArgumentNullException(nameof(executors), $"Executors collection contains a null element at index {executorIndex}.");
}
if (!this._executorIndicies.TryGetValue(executor.Id, out int index))
{
@@ -78,6 +87,7 @@ public sealed class SwitchBuilder
}
this._defaultIndicies.Add(index);
executorIndex++;
}
return this;
@@ -128,14 +128,16 @@ public static class WorkflowBuilderExtensions
Throw.IfNull(targets);
List<ExecutorBinding> targetList = [];
int targetIndex = 0;
foreach (ExecutorBinding? target in targets)
{
if (target is null)
{
throw new ArgumentNullException(nameof(targets), "Targets collection cannot contain null elements.");
throw new ArgumentNullException(nameof(targets), $"Targets collection contains a null element at index {targetIndex}.");
}
targetList.Add(target);
targetIndex++;
}
Throw.IfNullOrEmpty(targetList, nameof(targets));