Skip to content

Commit 339a2e6

Browse files
flaviocdcCopilot
andcommitted
fix: address PR review feedback
- Add using declarations on TurnContext instances to ensure disposal - Use ChannelId constructor instead of implicit string conversion for msteams and directline channel IDs for consistency - Fix grammar in comment: 'we will required' -> 'we will require' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e054e0a commit 339a2e6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Notification/Microsoft.Agents.A365.Notifications/AgentNotification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public AgentNotification OnAgentNotification(string subChannelId, AgentNotificat
5454
{
5555
// Wrap the activity in an AgentNotificationActivity
5656
var agentNotificationActivity = new AgentNotificationActivity(turnContext.Activity);
57-
// for now, we will required the handler to return the proper result.. we will change this later to return a structured result and handle the response back.
57+
// For now, we will require the handler to return the proper result. We will change this later to return a structured result and handle the response back.
5858
await handler(turnContext, turnState, agentNotificationActivity, cancellationToken);
5959
};
6060
AddRoute(_app, routeSelector, routeHandler, isAgenticOnly: true, rank: rank, autoSignInHandlers: autoSignInHandlers);

src/Tests/Microsoft.Agents.A365.Notifications.Tests/AgentNotificationRoutingTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public async Task AgenticEmailNotification_RoutesToNotificationHandler_NotGeneri
5454
RouteRank.Last,
5555
isAgenticOnly: true);
5656

57-
var turnContext = CreateAgenticNotificationTurnContext(SubChannels.AgentsEmailSubChannel);
57+
using var turnContext = CreateAgenticNotificationTurnContext(SubChannels.AgentsEmailSubChannel);
5858

5959
// Act
6060
await app.OnTurnAsync(turnContext, CancellationToken.None);
@@ -94,7 +94,7 @@ public async Task AgenticNotification_WithWildcardHandler_RoutesToNotificationHa
9494
RouteRank.Last,
9595
isAgenticOnly: true);
9696

97-
var turnContext = CreateAgenticNotificationTurnContext(SubChannels.AgentsWordSubChannel);
97+
using var turnContext = CreateAgenticNotificationTurnContext(SubChannels.AgentsWordSubChannel);
9898

9999
// Act
100100
await app.OnTurnAsync(turnContext, CancellationToken.None);
@@ -131,7 +131,7 @@ public async Task LifecycleNotification_RoutesToLifecycleHandler_NotGenericEvent
131131
RouteRank.Last,
132132
isAgenticOnly: true);
133133

134-
var turnContext = CreateAgenticLifecycleNotificationTurnContext(Events.AgenticUserIdentityCreated);
134+
using var turnContext = CreateAgenticLifecycleNotificationTurnContext(Events.AgenticUserIdentityCreated);
135135

136136
// Act
137137
await app.OnTurnAsync(turnContext, CancellationToken.None);
@@ -179,7 +179,7 @@ public async Task NonAgenticMessage_RoutesToNonAgenticHandler()
179179
isAgenticOnly: false);
180180

181181
// Create a normal (non-agentic) message — no agents channel, no agenticUser role
182-
var turnContext = CreateNonAgenticMessageTurnContext();
182+
using var turnContext = CreateNonAgenticMessageTurnContext();
183183

184184
// Act
185185
await app.OnTurnAsync(turnContext, CancellationToken.None);
@@ -222,12 +222,12 @@ public async Task AgenticMessage_NonAgentsChannel_RoutesToGenericAgenticHandler(
222222
{
223223
Type = ActivityTypes.Message,
224224
Text = "Hello from Teams",
225-
ChannelId = "msteams",
225+
ChannelId = new ChannelId("msteams"),
226226
Recipient = new ChannelAccount { Id = "bot1", Role = RoleTypes.AgenticUser },
227227
From = new ChannelAccount { Id = "user1" },
228228
Conversation = new ConversationAccount { Id = "conv1" },
229229
};
230-
var turnContext = new TurnContext(new StubAdapter(), activity);
230+
using var turnContext = new TurnContext(new StubAdapter(), activity);
231231

232232
// Act
233233
await app.OnTurnAsync(turnContext, CancellationToken.None);
@@ -299,7 +299,7 @@ private static async Task AssertSubChannelRoutesToNotificationHandler(
299299
RouteRank.Last,
300300
isAgenticOnly: true);
301301

302-
var turnContext = CreateAgenticNotificationTurnContext(subChannel);
302+
using var turnContext = CreateAgenticNotificationTurnContext(subChannel);
303303

304304
// Act
305305
await app.OnTurnAsync(turnContext, CancellationToken.None);
@@ -356,7 +356,7 @@ private static TurnContext CreateNonAgenticMessageTurnContext()
356356
{
357357
Type = ActivityTypes.Message,
358358
Text = "Hello",
359-
ChannelId = "directline",
359+
ChannelId = new ChannelId("directline"),
360360
Recipient = new ChannelAccount { Id = "bot1" },
361361
From = new ChannelAccount { Id = "user1" },
362362
Conversation = new ConversationAccount { Id = "conv1" },

0 commit comments

Comments
 (0)