mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Clean up a few ifdefs (#1016)
This commit is contained in:
committed by
GitHub
Unverified
parent
a4e593c795
commit
2d2a5bcd66
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ internal abstract class DeclarativeActionExecutor : Executor<ActionExecutorResul
|
||||
$"""
|
||||
STATE: {this.GetType().Name} [{this.Id}]
|
||||
NAME: {targetPath}
|
||||
VALUE:{valuePosition}{result.Format()} ({result.GetType().Name})
|
||||
VALUE:{valuePosition}{resultValue} ({result.GetType().Name})
|
||||
""");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ internal static class SampleEnvironment
|
||||
public static bool HasShutdownStarted
|
||||
=> SystemEnvironment.HasShutdownStarted;
|
||||
|
||||
#if NET9_0_OR_GREATER
|
||||
#if NET
|
||||
public static int ProcessId
|
||||
=> SystemEnvironment.ProcessId;
|
||||
|
||||
|
||||
+4
-18
@@ -50,25 +50,11 @@ internal static class Step2EntryPoint
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class DetectSpamExecutor : ReflectingExecutor<DetectSpamExecutor>, IMessageHandler<string, bool>
|
||||
internal sealed class DetectSpamExecutor(string id, params string[] spamKeywords) :
|
||||
ReflectingExecutor<DetectSpamExecutor>(id), IMessageHandler<string, bool>
|
||||
{
|
||||
public string[] SpamKeywords { get; }
|
||||
|
||||
public DetectSpamExecutor(string id, params string[] spamKeywords) : base(id)
|
||||
{
|
||||
this.SpamKeywords = spamKeywords;
|
||||
}
|
||||
|
||||
public async ValueTask<bool> 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<bool> HandleAsync(string message, IWorkflowContext context) =>
|
||||
spamKeywords.Any(keyword => message.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0);
|
||||
}
|
||||
|
||||
internal sealed class RespondToMessageExecutor(string id) : ReflectingExecutor<RespondToMessageExecutor>(id), IMessageHandler<bool>
|
||||
|
||||
Reference in New Issue
Block a user