diff --git a/dotnet/.editorconfig b/dotnet/.editorconfig index 57997400cd..14fe9911a1 100644 --- a/dotnet/.editorconfig +++ b/dotnet/.editorconfig @@ -207,6 +207,7 @@ dotnet_diagnostic.CS1998.severity = none # async method lacks 'await' operators dotnet_diagnostic.CA2000.severity = none # Call System.IDisposable.Dispose on object before all references to it are out of scope dotnet_diagnostic.CA2225.severity = none # Operator overloads have named alternates dotnet_diagnostic.CA2227.severity = none # Change to be read-only by removing the property setter +dotnet_diagnostic.CA2249.severity = suggestion # Consider using 'Contains' method instead of 'IndexOf' method dotnet_diagnostic.CA2253.severity = none # Named placeholders in the logging message template should not be comprised of only numeric characters dotnet_diagnostic.CA2253.severity = none # Named placeholders in the logging message template should not be comprised of only numeric characters dotnet_diagnostic.CA2263.severity = suggestion # Use generic overload diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs index 9ca8dd0898..d668b398c1 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs @@ -1,14 +1,14 @@ // Copyright (c) Microsoft. All rights reserved. using System; -#if NET9_0_OR_GREATER +#if NET using System.Buffers; #endif using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -#if NET9_0_OR_GREATER +#if NET using System.Text; #endif using System.Text.Json; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/DeclarativeActionExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/DeclarativeActionExecutor.cs index aa3da84f40..042b7c4b68 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/DeclarativeActionExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/DeclarativeActionExecutor.cs @@ -118,7 +118,7 @@ internal abstract class DeclarativeActionExecutor : Executor SystemEnvironment.HasShutdownStarted; -#if NET9_0_OR_GREATER +#if NET public static int ProcessId => SystemEnvironment.ProcessId; diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/02_Simple_Workflow_Condition.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/02_Simple_Workflow_Condition.cs index fa404fd1e1..ed0ccbd8f3 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/02_Simple_Workflow_Condition.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/02_Simple_Workflow_Condition.cs @@ -50,25 +50,11 @@ internal static class Step2EntryPoint } } -internal sealed class DetectSpamExecutor : ReflectingExecutor, IMessageHandler +internal sealed class DetectSpamExecutor(string id, params string[] spamKeywords) : + ReflectingExecutor(id), IMessageHandler { - public string[] SpamKeywords { get; } - - public DetectSpamExecutor(string id, params string[] spamKeywords) : base(id) - { - this.SpamKeywords = spamKeywords; - } - - public async ValueTask HandleAsync(string message, IWorkflowContext context) - { -#if NET5_0_OR_GREATER - bool isSpam = this.SpamKeywords.Any(keyword => message.Contains(keyword, StringComparison.OrdinalIgnoreCase)); -#else - bool isSpam = this.SpamKeywords.Any(keyword => message.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0); -#endif - - return isSpam; - } + public async ValueTask HandleAsync(string message, IWorkflowContext context) => + spamKeywords.Any(keyword => message.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0); } internal sealed class RespondToMessageExecutor(string id) : ReflectingExecutor(id), IMessageHandler