diff --git a/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs index ff4744bd08..ecc9f4738d 100644 --- a/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs @@ -96,7 +96,7 @@ namespace SampleApp public string? ThreadDbKey { get; private set; } - public override async Task AddMessagesAsync(IEnumerable messages, CancellationToken cancellationToken) + public override async Task AddMessagesAsync(IEnumerable messages, CancellationToken cancellationToken = default) { this.ThreadDbKey ??= Guid.NewGuid().ToString("N"); @@ -113,7 +113,7 @@ namespace SampleApp }), cancellationToken); } - public override async Task> GetMessagesAsync(CancellationToken cancellationToken) + public override async Task> GetMessagesAsync(CancellationToken cancellationToken = default) { var collection = this._vectorStore.GetCollection("ChatHistory"); await collection.EnsureCollectionExistsAsync(cancellationToken); diff --git a/dotnet/samples/GettingStarted/Workflows/Concurrent/MapReduce/Program.cs b/dotnet/samples/GettingStarted/Workflows/Concurrent/MapReduce/Program.cs index f519c67256..791fb074a7 100644 --- a/dotnet/samples/GettingStarted/Workflows/Concurrent/MapReduce/Program.cs +++ b/dotnet/samples/GettingStarted/Workflows/Concurrent/MapReduce/Program.cs @@ -219,7 +219,7 @@ internal sealed class Shuffler(string[] reducerIds, string[] mapperIds, string i { private readonly string[] _reducerIds = reducerIds; private readonly string[] _mapperIds = mapperIds; - private readonly List _mapResults = new(); + private readonly List _mapResults = []; /// /// Aggregate mapper outputs and write one partition file per reducer. diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatMessageStore.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatMessageStore.cs index 7bb92e85ac..f8cf5e8754 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatMessageStore.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatMessageStore.cs @@ -97,7 +97,7 @@ public sealed class InMemoryChatMessageStore : ChatMessageStore, IList - public override async Task AddMessagesAsync(IEnumerable messages, CancellationToken cancellationToken) + public override async Task AddMessagesAsync(IEnumerable messages, CancellationToken cancellationToken = default) { _ = Throw.IfNull(messages); @@ -110,7 +110,7 @@ public sealed class InMemoryChatMessageStore : ChatMessageStore, IList - public override async Task> GetMessagesAsync(CancellationToken cancellationToken) + public override async Task> GetMessagesAsync(CancellationToken cancellationToken = default) { if (this.ReducerTriggerEvent is ChatReducerTriggerEvent.BeforeMessagesRetrieval && this.ChatReducer is not null) { diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.A2A/AIAgentExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.A2A/AIAgentExtensions.cs index b2d3e9ce1f..000504b860 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.A2A/AIAgentExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.A2A/AIAgentExtensions.cs @@ -26,8 +26,8 @@ public static class AIAgentExtensions TaskManager? taskManager = null, ILoggerFactory? loggerFactory = null) { - ArgumentNullException.ThrowIfNull(agent, nameof(agent)); - ArgumentNullException.ThrowIfNull(agent.Name, nameof(agent.Name)); + ArgumentNullException.ThrowIfNull(agent); + ArgumentNullException.ThrowIfNull(agent.Name); taskManager ??= new(); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowOptions.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowOptions.cs index 607bdc65c6..638bed1f90 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowOptions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowOptions.cs @@ -15,7 +15,7 @@ public sealed class DeclarativeWorkflowOptions(WorkflowAgentProvider agentProvid /// /// Defines the agent provider. /// - public WorkflowAgentProvider AgentProvider { get; } = Throw.IfNull(agentProvider, nameof(agentProvider)); + public WorkflowAgentProvider AgentProvider { get; } = Throw.IfNull(agentProvider); /// /// Defines the configuration settings for the workflow. diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/AddConversationMessageExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/AddConversationMessageExecutor.cs index 17c005294e..68925e7f01 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/AddConversationMessageExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/AddConversationMessageExecutor.cs @@ -15,7 +15,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class AddConversationMessageExecutor(AddConversationMessage model, WorkflowAgentProvider agentProvider, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { Throw.IfNull(this.Model.ConversationId, $"{nameof(this.Model)}.{nameof(this.Model.ConversationId)}"); string conversationId = this.Evaluator.GetValue(this.Model.ConversationId).Value; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ClearAllVariablesExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ClearAllVariablesExecutor.cs index 0ab89a1971..419e112d0a 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ClearAllVariablesExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ClearAllVariablesExecutor.cs @@ -13,7 +13,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class ClearAllVariablesExecutor(ClearAllVariables model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { EvaluationResult variablesResult = this.Evaluator.GetValue(this.Model.Variables); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ConditionGroupExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ConditionGroupExecutor.cs index 6995ba3517..65a6510b18 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ConditionGroupExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ConditionGroupExecutor.cs @@ -48,7 +48,7 @@ internal sealed class ConditionGroupExecutor : DeclarativeActionExecutor ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { for (int index = 0; index < this.Model.Conditions.Length; ++index) { diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CopyConversationMessagesExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CopyConversationMessagesExecutor.cs index 1a63e216bd..e54e294730 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CopyConversationMessagesExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CopyConversationMessagesExecutor.cs @@ -16,7 +16,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class CopyConversationMessagesExecutor(CopyConversationMessages model, WorkflowAgentProvider agentProvider, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { Throw.IfNull(this.Model.ConversationId, $"{nameof(this.Model)}.{nameof(this.Model.ConversationId)}"); string conversationId = this.Evaluator.GetValue(this.Model.ConversationId).Value; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CreateConversationExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CreateConversationExecutor.cs index 64b4dff8ce..b291ba677c 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CreateConversationExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/CreateConversationExecutor.cs @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class CreateConversationExecutor(CreateConversation model, WorkflowAgentProvider agentProvider, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { string conversationId = await agentProvider.CreateConversationAsync(cancellationToken).ConfigureAwait(false); await this.AssignAsync(this.Model.ConversationId?.Path, FormulaValue.New(conversationId), context).ConfigureAwait(false); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/DefaultActionExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/DefaultActionExecutor.cs index 2c2418d1e8..e9d01adacd 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/DefaultActionExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/DefaultActionExecutor.cs @@ -11,7 +11,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class DefaultActionExecutor(DialogAction model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { // No action needed - the edge will be followed automatically return default; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableExecutor.cs index d5b85b55ef..3e05a4f314 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableExecutor.cs @@ -16,7 +16,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class EditTableExecutor(EditTable model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { PropertyPath variablePath = Throw.IfNull(this.Model.ItemsVariable?.Path, $"{nameof(this.Model)}.{nameof(this.Model.ItemsVariable)}"); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableV2Executor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableV2Executor.cs index a1e76709fa..4a5e8c3938 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableV2Executor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/EditTableV2Executor.cs @@ -16,7 +16,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class EditTableV2Executor(EditTableV2 model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { PropertyPath variablePath = Throw.IfNull(this.Model.ItemsVariable?.Path, $"{nameof(this.Model)}.{nameof(this.Model.ItemsVariable)}"); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs index 93bc282c73..41c9e7cb5a 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs @@ -35,7 +35,7 @@ internal sealed class ForeachExecutor : DeclarativeActionExecutor protected override bool IsDiscreteAction => false; - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { this._index = 0; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs index 757228b10a..9d0c2eb3d5 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs @@ -20,7 +20,7 @@ internal sealed class InvokeAzureAgentExecutor(InvokeAzureAgent model, WorkflowA private AzureAgentInput? AgentInput => this.Model.Input; private AzureAgentOutput? AgentOutput => this.Model.Output; - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { string? conversationId = this.GetConversationId(); string agentName = this.GetAgentName(); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ParseValueExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ParseValueExecutor.cs index 04cce69710..94a9b9ef1d 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ParseValueExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ParseValueExecutor.cs @@ -17,7 +17,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class ParseValueExecutor(ParseValue model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { PropertyPath variablePath = Throw.IfNull(this.Model.Variable?.Path, $"{nameof(this.Model)}.{nameof(model.Variable)}"); ValueExpression valueExpression = Throw.IfNull(this.Model.Value, $"{nameof(this.Model)}.{nameof(this.Model.Value)}"); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/QuestionExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/QuestionExecutor.cs index c788d88463..1d34869441 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/QuestionExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/QuestionExecutor.cs @@ -37,7 +37,7 @@ internal sealed class QuestionExecutor(Question model, WorkflowFormulaState stat return executorMessage.Result is null; } - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { await this._promptCount.WriteAsync(context, 0).ConfigureAwait(false); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ResetVariableExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ResetVariableExecutor.cs index 04650c77bc..da625b11ae 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ResetVariableExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ResetVariableExecutor.cs @@ -14,7 +14,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class ResetVariableExecutor(ResetVariable model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { Throw.IfNull(this.Model.Variable, $"{nameof(this.Model)}.{nameof(model.Variable)}"); await context.QueueStateResetAsync(this.Model.Variable).ConfigureAwait(false); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessageExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessageExecutor.cs index dde0ccb673..d5f522f208 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessageExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessageExecutor.cs @@ -14,7 +14,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class RetrieveConversationMessageExecutor(RetrieveConversationMessage model, WorkflowAgentProvider agentProvider, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { Throw.IfNull(this.Model.ConversationId, $"{nameof(this.Model)}.{nameof(this.Model.ConversationId)}"); string conversationId = this.Evaluator.GetValue(this.Model.ConversationId).Value; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessagesExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessagesExecutor.cs index a90d039b58..9f982a671f 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessagesExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/RetrieveConversationMessagesExecutor.cs @@ -16,7 +16,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class RetrieveConversationMessagesExecutor(RetrieveConversationMessages model, WorkflowAgentProvider agentProvider, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { Throw.IfNull(this.Model.ConversationId, $"{nameof(this.Model)}.{nameof(this.Model.ConversationId)}"); string conversationId = this.Evaluator.GetValue(this.Model.ConversationId).Value; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SendActivityExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SendActivityExecutor.cs index ed79bf7d91..69ed8bb970 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SendActivityExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SendActivityExecutor.cs @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class SendActivityExecutor(SendActivity model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { if (this.Model.Activity is MessageActivityTemplate messageActivity) { diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetMultipleVariablesExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetMultipleVariablesExecutor.cs index 96e7654360..6ab2e7b2f3 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetMultipleVariablesExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetMultipleVariablesExecutor.cs @@ -14,7 +14,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class SetMultipleVariablesExecutor(SetMultipleVariables model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { foreach (VariableAssignment assignment in this.Model.Assignments) { diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetTextVariableExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetTextVariableExecutor.cs index b4d2167b13..c2a49d8c39 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetTextVariableExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetTextVariableExecutor.cs @@ -13,7 +13,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class SetTextVariableExecutor(SetTextVariable model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { if (this.Model.Value is null) { diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetVariableExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetVariableExecutor.cs index fe9de10278..449e982982 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetVariableExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SetVariableExecutor.cs @@ -15,7 +15,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; internal sealed class SetVariableExecutor(SetVariable model, WorkflowFormulaState state) : DeclarativeActionExecutor(model, state) { - protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) + protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken = default) { PropertyPath variablePath = Throw.IfNull(this.Model.Variable?.Path, $"{nameof(this.Model)}.{nameof(model.Variable)}"); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowExpressionEngine.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowExpressionEngine.cs index f2b4256e50..17a013cb11 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowExpressionEngine.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowExpressionEngine.cs @@ -43,7 +43,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(BoolExpression expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -67,7 +67,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(StringExpression expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -96,7 +96,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(IntExpression expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -120,7 +120,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(NumberExpression expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -149,7 +149,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(ValueExpression expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -163,7 +163,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(EnumExpression expression) where TValue : EnumWrapper { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -184,7 +184,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult Evaluate(ObjectExpression expression) where TValue : BotElement { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.LiteralValue is not null) { @@ -215,7 +215,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult> Evaluate(ArrayExpression expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); if (expression.IsLiteral) { @@ -229,7 +229,7 @@ internal sealed class WorkflowExpressionEngine private EvaluationResult> Evaluate(ArrayExpressionOnly expression) { - Throw.IfNull(expression, nameof(expression)); + Throw.IfNull(expression); EvaluationResult expressionResult = this.EvaluateScope(expression); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/AgentWorkflowBuilder.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/AgentWorkflowBuilder.cs index 2705fb111a..b21edee04c 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/AgentWorkflowBuilder.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/AgentWorkflowBuilder.cs @@ -583,7 +583,7 @@ public static partial class AgentWorkflowBuilder public ValueTask ResetAsync() => default; } - private record class HandoffState( + private sealed record class HandoffState( TurnToken TurnToken, string? InvokedHandoff, List Messages); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/EdgeMap.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/EdgeMap.cs index aec0341a29..6ed6214868 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/EdgeMap.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/EdgeMap.cs @@ -11,7 +11,7 @@ namespace Microsoft.Agents.AI.Workflows.Execution; internal sealed class EdgeMap { private readonly Dictionary _edgeRunners = []; - private readonly Dictionary _statefulRunners = new(); + private readonly Dictionary _statefulRunners = []; private readonly Dictionary _portEdgeRunners; private readonly InputEdgeRunner _inputRunner; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/MessageEnvelope.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/MessageEnvelope.cs index 4e234950c9..420175c943 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/MessageEnvelope.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/Execution/MessageEnvelope.cs @@ -21,7 +21,7 @@ internal sealed class MessageEnvelope(object message, ExecutorIdentity source, T internal MessageEnvelope(object message, ExecutorIdentity source, Type declaredType, string? targetId = null) : this(message, source, new TypeId(declaredType), targetId) { - if (!declaredType.IsAssignableFrom(message.GetType())) + if (!declaredType.IsInstanceOfType(message)) { throw new ArgumentException($"The declared type {declaredType} is not compatible with the message instance of type {message.GetType()}"); } diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/ExternalRequest.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/ExternalRequest.cs index 35477ab7b4..37986e6e86 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/ExternalRequest.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/ExternalRequest.cs @@ -39,7 +39,7 @@ public record ExternalRequest(InputPortInfo PortInfo, string RequestId, Portable /// Thrown when the input data object does not match the expected request type. public static ExternalRequest Create(InputPort port, [NotNull] object data, string? requestId = null) { - if (!port.Request.IsAssignableFrom(Throw.IfNull(data).GetType())) + if (!port.Request.IsInstanceOfType(Throw.IfNull(data))) { throw new InvalidOperationException( $"Message type {data.GetType().Name} is not assignable to the request type {port.Request.Name} of input port {port.Id}."); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/PortableValue.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/PortableValue.cs index 4a7ffe6210..3007303cd9 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/PortableValue.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/PortableValue.cs @@ -158,7 +158,7 @@ public sealed class PortableValue this._deserializedValueCache ??= delayedDeserialization.Deserialize(targetType); } - if (this.Value is not null && targetType.IsAssignableFrom(this.Value.GetType())) + if (this.Value is not null && targetType.IsInstanceOfType(this.Value)) { value = this.Value; return true; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/Reflection/RouteBuilderExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/Reflection/RouteBuilderExtensions.cs index 9cb61a4be2..c0c6b8c8ca 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/Reflection/RouteBuilderExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/Reflection/RouteBuilderExtensions.cs @@ -86,7 +86,7 @@ internal static class RouteBuilderExtensions Throw.IfNull(builder); Type executorType = typeof(TExecutor); - Debug.Assert(executorType.IsAssignableFrom(executor.GetType()), + Debug.Assert(executorType.IsInstanceOfType(executor), "executorType must be the same type or a base type of the executor instance."); foreach (MessageHandlerInfo handlerInfo in executorType.GetHandlerInfos()) diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/RequestInfoExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/RequestInfoExecutor.cs index 4dc9259cd0..034dc702c9 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/RequestInfoExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/RequestInfoExecutor.cs @@ -11,7 +11,7 @@ namespace Microsoft.Agents.AI.Workflows.Specialized; internal sealed class RequestInfoExecutor : Executor { - private readonly Dictionary _wrappedRequests = new(); + private readonly Dictionary _wrappedRequests = []; private InputPort Port { get; } private IExternalRequestSink? RequestSink { get; set; } @@ -57,7 +57,7 @@ internal sealed class RequestInfoExecutor : Executor object? maybeRequest = message.AsType(this.Port.Request); if (maybeRequest != null) { - Debug.Assert(this.Port.Request.IsAssignableFrom(maybeRequest.GetType())); + Debug.Assert(this.Port.Request.IsInstanceOfType(maybeRequest)); ExternalRequest request = ExternalRequest.Create(this.Port, maybeRequest!); await this.RequestSink!.PostAsync(request).ConfigureAwait(false); @@ -93,7 +93,7 @@ internal sealed class RequestInfoExecutor : Executor public async ValueTask HandleAsync(object message, IWorkflowContext context) { Throw.IfNull(message); - Debug.Assert(this.Port.Request.IsAssignableFrom(message.GetType())); + Debug.Assert(this.Port.Request.IsInstanceOfType(message)); ExternalRequest request = ExternalRequest.Create(this.Port, message); await this.RequestSink!.PostAsync(request).ConfigureAwait(false); diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/Visualization/WorkflowVisualizer.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/Visualization/WorkflowVisualizer.cs index 4c27df2206..bd28801352 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/Visualization/WorkflowVisualizer.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/Visualization/WorkflowVisualizer.cs @@ -21,7 +21,7 @@ public static class WorkflowVisualizer /// A string representation of the workflow in DOT format. public static string ToDotString(this Workflow workflow) { - Throw.IfNull(workflow, nameof(workflow)); + Throw.IfNull(workflow); var lines = new List { @@ -249,10 +249,7 @@ public static class WorkflowVisualizer { var sortedSources = sources.OrderBy(x => x, StringComparer.Ordinal).ToList(); var input = target + "|" + string.Join("|", sortedSources); - using (var sha256 = SHA256.Create()) - { - return ComputeShortHash(input); - } + return ComputeShortHash(input); } private static string ComputeShortHash(string input) diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs index 7add0138a5..6e739ad92f 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs @@ -24,7 +24,7 @@ internal sealed class WorkflowHostAgent : AIAgent public WorkflowHostAgent(Workflow> workflow, string? id = null, string? name = null) { - this._workflow = Throw.IfNull(workflow, nameof(workflow)); + this._workflow = Throw.IfNull(workflow); this._id = id; this.Name = name; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowMessageStore.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowMessageStore.cs index 2d656d50ce..1fffb502fc 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowMessageStore.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowMessageStore.cs @@ -45,14 +45,14 @@ internal sealed class WorkflowMessageStore : ChatMessageStore internal void AddMessages(params IEnumerable messages) => this._chatMessages.AddRange(messages); - public override Task AddMessagesAsync(IEnumerable messages, CancellationToken cancellationToken) + public override Task AddMessagesAsync(IEnumerable messages, CancellationToken cancellationToken = default) { this._chatMessages.AddRange(messages); return Task.CompletedTask; } - public override Task> GetMessagesAsync(CancellationToken cancellationToken) => Task.FromResult>(this._chatMessages.AsReadOnly()); + public override Task> GetMessagesAsync(CancellationToken cancellationToken = default) => Task.FromResult>(this._chatMessages.AsReadOnly()); public IEnumerable GetFromBookmark() { diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowOutputEvent.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowOutputEvent.cs index 68ec6a81ac..64c7b5be4c 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowOutputEvent.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowOutputEvent.cs @@ -31,9 +31,7 @@ public sealed class WorkflowOutputEvent : WorkflowEvent /// /// The type to compare with the type of the underlying data. /// true if the underlying data is assignable to type T; otherwise, false. - public bool IsType(Type type) => this.Data == null - ? false - : type.IsAssignableFrom(this.Data.GetType()); + public bool IsType(Type type) => this.Data is { } data && type.IsInstanceOfType(data); /// /// Attempts to retrieve the underlying data as the specified type. diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowThread.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowThread.cs index 3b8766a09d..8db2eabe93 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowThread.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowThread.cs @@ -12,7 +12,7 @@ internal sealed class WorkflowThread : AgentThread public WorkflowThread(string workflowId, string? workflowName, string runId) { this.MessageStore = new(); - this.RunId = Throw.IfNullOrEmpty(runId, nameof(runId)); + this.RunId = Throw.IfNullOrEmpty(runId); } public WorkflowThread(JsonElement serializedThread, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/src/Microsoft.Agents.AI/OpenTelemetryAgent.cs b/dotnet/src/Microsoft.Agents.AI/OpenTelemetryAgent.cs index fafc224e77..a155feb3c9 100644 --- a/dotnet/src/Microsoft.Agents.AI/OpenTelemetryAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI/OpenTelemetryAgent.cs @@ -171,7 +171,7 @@ public sealed class OpenTelemetryAgent : DelegatingAIAgent, IDisposable private sealed class ForwardingChatClient(OpenTelemetryAgent parentAgent) : IChatClient { public async Task GetResponseAsync( - IEnumerable messages, ChatOptions? options, CancellationToken cancellationToken) + IEnumerable messages, ChatOptions? options = null, CancellationToken cancellationToken = default) { ForwardedOptions? fo = options as ForwardedOptions; @@ -186,7 +186,7 @@ public sealed class OpenTelemetryAgent : DelegatingAIAgent, IDisposable } public async IAsyncEnumerable GetStreamingResponseAsync( - IEnumerable messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken) + IEnumerable messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default) { ForwardedOptions? fo = options as ForwardedOptions; diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentRunOptionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentRunOptionsTests.cs index 0c9bce2867..9dd1fce4fb 100644 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentRunOptionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentRunOptionsTests.cs @@ -320,7 +320,7 @@ public class ChatClientAgentRunOptionsTests // Arrange var originalClient = new Mock(); - IChatClient ClientFactory(IChatClient client) => null!; + static IChatClient ClientFactory(IChatClient client) => null!; var agent = new ChatClientAgent(originalClient.Object); var messages = new List { new(ChatRole.User, "Test message") }; diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/FunctionInvocationDelegatingAgentTests.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/FunctionInvocationDelegatingAgentTests.cs index 722e981e9c..c68de37177 100644 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/FunctionInvocationDelegatingAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.UnitTests/FunctionInvocationDelegatingAgentTests.cs @@ -344,7 +344,7 @@ public sealed class FunctionInvocationDelegatingAgentTests if (options?.Tools?.FirstOrDefault() is AIFunction function) { executionOrder.Add("Direct-Function-Invocation"); - await function.InvokeAsync(new AIFunctionArguments(), ct); + await function.InvokeAsync([], ct); } return new ChatResponse([new ChatMessage(ChatRole.Assistant, "Response after direct invocation")]); }); @@ -476,7 +476,7 @@ public sealed class FunctionInvocationDelegatingAgentTests var messages = new List { new(ChatRole.User, "Test message") }; const string ModifiedResult = "Modified by middleware"; - async ValueTask MiddlewareCallbackAsync(AIAgent agent, FunctionInvocationContext context, Func> next, CancellationToken cancellationToken) + static async ValueTask MiddlewareCallbackAsync(AIAgent agent, FunctionInvocationContext context, Func> next, CancellationToken cancellationToken) { await next(context, cancellationToken); return ModifiedResult; // Return the modified result instead of setting context property @@ -770,7 +770,7 @@ public sealed class FunctionInvocationDelegatingAgentTests var innerAgent = new ChatClientAgent(mockChatClient.Object); var messages = new List { new(ChatRole.User, "Test message") }; - ValueTask MiddlewareCallbackAsync(AIAgent agent, FunctionInvocationContext context, Func> next, CancellationToken cancellationToken) + static ValueTask MiddlewareCallbackAsync(AIAgent agent, FunctionInvocationContext context, Func> next, CancellationToken cancellationToken) { // Don't call next() - this should prevent function execution // Return the blocked result directly diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/TestOutputAdapter.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/TestOutputAdapter.cs index 5eeb11f3f7..e1a0857c85 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/TestOutputAdapter.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/TestOutputAdapter.cs @@ -21,13 +21,13 @@ public sealed class TestOutputAdapter(ITestOutputHelper output) : TextWriter, IL public bool IsEnabled(LogLevel logLevel) => true; - public override void WriteLine(object? value = null) => this.SafeWrite($"{value}"); + public override void WriteLine(object? value) => this.SafeWrite($"{value}"); public override void WriteLine(string? format, params object?[] arg) => this.SafeWrite(string.Format(format ?? string.Empty, arg)); public override void WriteLine(string? value) => this.SafeWrite(value ?? string.Empty); - public override void Write(object? value = null) => this.SafeWrite($"{value}"); + public override void Write(object? value) => this.SafeWrite($"{value}"); public override void Write(char[]? buffer) => this.SafeWrite(new string(buffer)); diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/TestOutputAdapter.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/TestOutputAdapter.cs index 7d1e39ee97..72da232da9 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/TestOutputAdapter.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/TestOutputAdapter.cs @@ -21,13 +21,13 @@ public sealed class TestOutputAdapter(ITestOutputHelper output) : TextWriter, IL public bool IsEnabled(LogLevel logLevel) => true; - public override void WriteLine(object? value = null) => this.SafeWrite($"{value}"); + public override void WriteLine(object? value) => this.SafeWrite($"{value}"); public override void WriteLine(string? format, params object?[] arg) => this.SafeWrite(string.Format(format ?? string.Empty, arg)); public override void WriteLine(string? value) => this.SafeWrite(value ?? string.Empty); - public override void Write(object? value = null) => this.SafeWrite($"{value}"); + public override void Write(object? value) => this.SafeWrite($"{value}"); public override void Write(char[]? buffer) => this.SafeWrite(new string(buffer)); diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/EdgeRunnerTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/EdgeRunnerTests.cs index 0880b14353..4239b6ef6d 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/EdgeRunnerTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/EdgeRunnerTests.cs @@ -103,7 +103,7 @@ public class EdgeRunnerTests && (!targetMatch.HasValue || targetMatch.Value); bool expectForwardFrom3 = !assignerSelectsEmpty.HasValue && !targetMatch.HasValue; // if there is a target, it is never executor3 - HashSet expectedReceivers = new(); + HashSet expectedReceivers = []; if (expectForwardFrom2) { expectedReceivers.Add("executor2"); diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/05_Simple_Workflow_Checkpointing.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/05_Simple_Workflow_Checkpointing.cs index df14d6e892..d630c44a85 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/05_Simple_Workflow_Checkpointing.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/05_Simple_Workflow_Checkpointing.cs @@ -13,7 +13,7 @@ internal static class Step5EntryPoint { public static async ValueTask RunAsync(TextWriter writer, Func userGuessCallback, bool rehydrateToRestore = false, CheckpointManager? checkpointManager = null) { - Dictionary checkpointedOutputs = new(); + Dictionary checkpointedOutputs = []; NumberSignal signal = NumberSignal.Init; string? prompt = Step4EntryPoint.UpdatePrompt(null, signal); diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowVisualizerTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowVisualizerTests.cs index e00e513775..441dd28439 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowVisualizerTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowVisualizerTests.cs @@ -84,7 +84,7 @@ public class WorkflowVisualizerTests var end = new MockExecutor("end"); // Condition that is never used during viz, but presence should mark the edge - bool OnlyIfFoo(string? msg) => msg == "foo"; + static bool OnlyIfFoo(string? msg) => msg == "foo"; var workflow = new WorkflowBuilder("start") .AddEdge(start, mid, OnlyIfFoo) @@ -195,7 +195,7 @@ public class WorkflowVisualizerTests var c = new MockExecutor("c"); var end = new ListStrTargetExecutor("end"); - bool Condition(string? msg) => msg?.Contains("test") ?? false; + static bool Condition(string? msg) => msg?.Contains("test") ?? false; var workflow = new WorkflowBuilder("start") .AddEdge(start, a, Condition) // Conditional edge @@ -241,7 +241,7 @@ public class WorkflowVisualizerTests // Test visualization of self-loop edge var executor = new MockExecutor("loop"); - bool LoopCondition(string? msg) => (msg?.Length ?? 0) < 10; + static bool LoopCondition(string? msg) => (msg?.Length ?? 0) < 10; var workflow = new WorkflowBuilder("loop") .AddEdge(executor, executor, LoopCondition) @@ -281,7 +281,7 @@ public class WorkflowVisualizerTests var mid = new MockExecutor("mid"); var end = new MockExecutor("end"); - bool OnlyIfFoo(string? msg) => msg == "foo"; + static bool OnlyIfFoo(string? msg) => msg == "foo"; var workflow = new WorkflowBuilder("start") .AddEdge(start, mid, OnlyIfFoo) @@ -374,7 +374,7 @@ public class WorkflowVisualizerTests var c = new MockExecutor("c"); var end = new ListStrTargetExecutor("end"); - bool Condition(string? msg) => msg?.Contains("test") ?? false; + static bool Condition(string? msg) => msg?.Contains("test") ?? false; var workflow = new WorkflowBuilder("start") .AddEdge(start, a, Condition) // Conditional edge