mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Use indexed parameter name in SwitchBuilder Throw.IfNull: executors[index]
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/c5655707-5b0b-44f3-98a9-5f3961e32cfe Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
14b9c02c52
commit
f94ed16bc8
@@ -36,10 +36,12 @@ public sealed class SwitchBuilder
|
||||
Throw.IfNull(executors);
|
||||
|
||||
HashSet<int> indicies = [];
|
||||
int executorIndex = 0;
|
||||
|
||||
foreach (ExecutorBinding executor in executors)
|
||||
{
|
||||
Throw.IfNull(executor);
|
||||
Throw.IfNull(executor, $"{nameof(executors)}[{executorIndex}]");
|
||||
executorIndex++;
|
||||
|
||||
if (!this._executorIndicies.TryGetValue(executor.Id, out int index))
|
||||
{
|
||||
@@ -66,9 +68,12 @@ public sealed class SwitchBuilder
|
||||
{
|
||||
Throw.IfNull(executors);
|
||||
|
||||
int executorIndex = 0;
|
||||
|
||||
foreach (ExecutorBinding executor in executors)
|
||||
{
|
||||
Throw.IfNull(executor);
|
||||
Throw.IfNull(executor, $"{nameof(executors)}[{executorIndex}]");
|
||||
executorIndex++;
|
||||
|
||||
if (!this._executorIndicies.TryGetValue(executor.Id, out int index))
|
||||
{
|
||||
|
||||
@@ -445,9 +445,9 @@ public partial class WorkflowBuilderSmokeTests
|
||||
// Act/Assert
|
||||
Assert.Throws<ArgumentNullException>("predicate", () => switchBuilder.AddCase<string>(null!, [target]));
|
||||
Assert.Throws<ArgumentNullException>("executors", () => switchBuilder.AddCase<string>(_ => true, null!));
|
||||
Assert.Throws<ArgumentNullException>("executor", () => switchBuilder.AddCase<string>(_ => true, [target, null!]));
|
||||
Assert.Throws<ArgumentNullException>("executors[1]", () => switchBuilder.AddCase<string>(_ => true, [target, null!]));
|
||||
Assert.Throws<ArgumentNullException>("executors", () => switchBuilder.WithDefault(null!));
|
||||
Assert.Throws<ArgumentNullException>("executor", () => switchBuilder.WithDefault([target, null!]));
|
||||
Assert.Throws<ArgumentNullException>("executors[1]", () => switchBuilder.WithDefault([target, null!]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user