File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ *--------------------------------------------------------------------------------------------*/
4+
5+ namespace GitHub . Copilot . SDK ;
6+
7+ /// <summary>
8+ /// A disposable that invokes an action when disposed.
9+ /// </summary>
10+ internal sealed class ActionDisposable : IDisposable
11+ {
12+ private Action ? _action ;
13+
14+ public ActionDisposable ( Action action )
15+ {
16+ _action = action ;
17+ }
18+
19+ public void Dispose ( )
20+ {
21+ var action = Interlocked . Exchange ( ref _action , null ) ;
22+ action ? . Invoke ( ) ;
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -1561,22 +1561,3 @@ public class ToolResultAIContent(ToolResultObject toolResult) : AIContent
15611561{
15621562 public ToolResultObject Result => toolResult ;
15631563}
1564-
1565- /// <summary>
1566- /// A disposable that invokes an action when disposed.
1567- /// </summary>
1568- internal sealed class ActionDisposable : IDisposable
1569- {
1570- private Action ? _action ;
1571-
1572- public ActionDisposable ( Action action )
1573- {
1574- _action = action ;
1575- }
1576-
1577- public void Dispose ( )
1578- {
1579- var action = Interlocked . Exchange ( ref _action , null ) ;
1580- action ? . Invoke ( ) ;
1581- }
1582- }
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ void Handler(SessionEvent evt)
246246 public IDisposable On ( SessionEventHandler handler )
247247 {
248248 _eventHandlers . Add ( handler ) ;
249- return new OnDisposeCall ( ( ) => _eventHandlers . Remove ( handler ) ) ;
249+ return new ActionDisposable ( ( ) => _eventHandlers . Remove ( handler ) ) ;
250250 }
251251
252252 /// <summary>
@@ -600,11 +600,6 @@ await InvokeRpcAsync<object>(
600600 }
601601 }
602602
603- private class OnDisposeCall ( Action callback ) : IDisposable
604- {
605- public void Dispose ( ) => callback ( ) ;
606- }
607-
608603 internal record SendMessageRequest
609604 {
610605 public string SessionId { get ; init ; } = string . Empty ;
You can’t perform that action at this time.
0 commit comments