From cbbaa59e0a926a69652e9331696b51b8fe062aee Mon Sep 17 00:00:00 2001
From: Chris <66376200+crickman@users.noreply.github.com>
Date: Thu, 11 Apr 2024 07:02:28 -0700
Subject: [PATCH] .Net - Agents IReadonlyList instead of IEnumerable (Step
#ANY) (#5832)
### Motivation and Context
`IEnumerable` can be cumbersome if not required. Identified a usage that
is improved by `IReadOnlyList` (as the usage of `IEnumerable` was
extraneous.)
### Description
Been on the look-out for tuning these signatures...this one slipped
through.
### Contribution Checklist
- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone :smile:
---
dotnet/src/Agents/Abstractions/AgentChannel.cs | 2 +-
dotnet/src/Agents/Abstractions/ChatHistoryChannel.cs | 2 +-
dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs | 2 +-
dotnet/src/Agents/UnitTests/AgentChannelTests.cs | 2 +-
dotnet/src/Agents/UnitTests/Internal/BroadcastQueueTests.cs | 4 ++--
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dotnet/src/Agents/Abstractions/AgentChannel.cs b/dotnet/src/Agents/Abstractions/AgentChannel.cs
index ceb240b3d452..868990e94cc7 100644
--- a/dotnet/src/Agents/Abstractions/AgentChannel.cs
+++ b/dotnet/src/Agents/Abstractions/AgentChannel.cs
@@ -16,7 +16,7 @@ public abstract class AgentChannel
///
/// The chat history at the point the channel is created.
/// The to monitor for cancellation requests. The default is .
- protected internal abstract Task ReceiveAsync(IEnumerable history, CancellationToken cancellationToken = default);
+ protected internal abstract Task ReceiveAsync(IReadOnlyList history, CancellationToken cancellationToken = default);
///
/// Perform a discrete incremental interaction between a single and .
diff --git a/dotnet/src/Agents/Abstractions/ChatHistoryChannel.cs b/dotnet/src/Agents/Abstractions/ChatHistoryChannel.cs
index 5a44b0a1a9e4..cc4f0372c4a3 100644
--- a/dotnet/src/Agents/Abstractions/ChatHistoryChannel.cs
+++ b/dotnet/src/Agents/Abstractions/ChatHistoryChannel.cs
@@ -34,7 +34,7 @@ protected internal sealed override async IAsyncEnumerable In
}
///
- protected internal sealed override Task ReceiveAsync(IEnumerable history, CancellationToken cancellationToken)
+ protected internal sealed override Task ReceiveAsync(IReadOnlyList history, CancellationToken cancellationToken)
{
this._history.AddRange(history);
diff --git a/dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs b/dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs
index 0819635e2612..089628251c41 100644
--- a/dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs
+++ b/dotnet/src/Agents/Abstractions/Internal/BroadcastQueue.cs
@@ -9,7 +9,7 @@ namespace Microsoft.SemanticKernel.Agents.Internal;
///
/// Utility class used by to manage the broadcast of
/// conversation messages via the .
-/// (.)
+/// (.)
///
///
/// Maintains a set of channel specific queues, each with individual locks, in addition to a global state lock.
diff --git a/dotnet/src/Agents/UnitTests/AgentChannelTests.cs b/dotnet/src/Agents/UnitTests/AgentChannelTests.cs
index c35bd5bc365d..7223b8d46805 100644
--- a/dotnet/src/Agents/UnitTests/AgentChannelTests.cs
+++ b/dotnet/src/Agents/UnitTests/AgentChannelTests.cs
@@ -57,7 +57,7 @@ protected internal override IAsyncEnumerable GetHistoryAsync
throw new NotImplementedException();
}
- protected internal override Task ReceiveAsync(IEnumerable history, CancellationToken cancellationToken = default)
+ protected internal override Task ReceiveAsync(IReadOnlyList history, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
diff --git a/dotnet/src/Agents/UnitTests/Internal/BroadcastQueueTests.cs b/dotnet/src/Agents/UnitTests/Internal/BroadcastQueueTests.cs
index 0716799ed88b..eb0dda489a65 100644
--- a/dotnet/src/Agents/UnitTests/Internal/BroadcastQueueTests.cs
+++ b/dotnet/src/Agents/UnitTests/Internal/BroadcastQueueTests.cs
@@ -141,7 +141,7 @@ protected internal override IAsyncEnumerable InvokeAsync(Age
throw new NotImplementedException();
}
- protected internal override async Task ReceiveAsync(IEnumerable history, CancellationToken cancellationToken = default)
+ protected internal override async Task ReceiveAsync(IReadOnlyList history, CancellationToken cancellationToken = default)
{
this.ReceivedMessages.AddRange(history);
this.ReceiveCount += 1;
@@ -164,7 +164,7 @@ protected internal override IAsyncEnumerable InvokeAsync(Age
throw new NotImplementedException();
}
- protected internal override async Task ReceiveAsync(IEnumerable history, CancellationToken cancellationToken = default)
+ protected internal override async Task ReceiveAsync(IReadOnlyList history, CancellationToken cancellationToken = default)
{
await Task.Delay(this.ReceiveDuration, cancellationToken);