Skip to content

Commit

Permalink
[C#] fix: StreamingResponse array instantiation (#2101)
Browse files Browse the repository at this point in the history
## Linked issues

closes: #minor

## Details

Update to use new() for backwards compat.

## Attestation Checklist

- [x] My code follows the style guidelines of this project

- I have checked for/fixed spelling, linting, and other errors
- I have commented my code for clarity
- I have made corresponding changes to the documentation (updating the
doc strings in the code is sufficient)
- My changes generate no new warnings
- I have added tests that validates my changes, and provides sufficient
test coverage. I have tested with:
  - Local testing
  - E2E testing in Teams
- New and existing unit tests pass locally with my changes
  • Loading branch information
lilyydu authored Oct 9, 2024
1 parent 8b28322 commit 73b15e2
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public class StreamingResponse
private bool _ended = false;

// Queue for outgoing activities
private IList<Func<Activity>> _queue = [];
private List<Func<Activity>> _queue = new();
private Task? _queueSync;
private bool _chunkQueued = false;

/// <summary>
/// Fluent interface for accessing the attachments.
/// </summary>
public IList<Attachment>? Attachments { get; set; } = [];
public List<Attachment>? Attachments { get; set; } = new();

/// <summary>
/// Gets the stream ID of the current response.
Expand Down Expand Up @@ -159,16 +159,21 @@ private void QueueNextChunk()
if (this._ended)
{
// Send final message
return new Activity
Activity activity = new Activity
{
Type = ActivityTypes.Message,
Text = Message,
Attachments = Attachments != null ? Attachments : [],
ChannelData = new StreamingChannelData
{
StreamType = StreamType.Final,
}
};

if (Attachments != null && Attachments.Count > 0)
{
activity.Attachments = Attachments;
}
return activity;
}
else
{
Expand Down

0 comments on commit 73b15e2

Please sign in to comment.