|
3 | 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
4 | 4 | //
|
5 | 5 |
|
| 6 | +using System.ComponentModel; |
6 | 7 | using System.Threading;
|
7 | 8 | using System.Threading.Tasks;
|
| 9 | +using MediatR; |
| 10 | +using OmniSharp.Extensions.DebugAdapter.Protocol; |
| 11 | +using OmniSharp.Extensions.DebugAdapter.Protocol.Client; |
8 | 12 | using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
|
9 | 13 | using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
|
| 14 | +using OmniSharp.Extensions.DebugAdapter.Protocol.Server; |
| 15 | +using OmniSharp.Extensions.JsonRpc; |
| 16 | +using OmniSharp.Extensions.JsonRpc.Generation; |
| 17 | +using Thread = OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread; |
| 18 | + |
| 19 | +namespace System.Runtime.CompilerServices |
| 20 | +{ |
| 21 | + [EditorBrowsable(EditorBrowsableState.Never)] |
| 22 | + public class IsExternalInit{} |
| 23 | +} |
| 24 | + |
| 25 | +namespace OmniSharp.Extensions.DebugAdapter.Protocol |
| 26 | +{ |
| 27 | + |
| 28 | + [Parallel] |
| 29 | + [Method(RequestNames.Threads, Direction.ClientToServer)] |
| 30 | + [ |
| 31 | + GenerateHandler, |
| 32 | + GenerateHandlerMethods(typeof(IDebugAdapterServerRegistry)), |
| 33 | + GenerateRequestMethods(typeof(IDebugAdapterClient)), |
| 34 | + ] |
| 35 | + public record ThreadsTempArguments : IRequest<ThreadsTempResponse> |
| 36 | + { |
| 37 | + } |
| 38 | + |
| 39 | + public record ThreadsTempResponse |
| 40 | + { |
| 41 | + public Container<Thread>? Threads { get; init; } |
| 42 | + } |
| 43 | + |
| 44 | +} |
10 | 45 |
|
11 | 46 | namespace Microsoft.PowerShell.EditorServices.Handlers
|
12 | 47 | {
|
| 48 | + /* |
13 | 49 | internal class ThreadsHandler : IThreadsHandler
|
14 | 50 | {
|
| 51 | + internal static Thread MainDebuggedThread { get; } = new Thread(() => { }); |
| 52 | +
|
15 | 53 | public Task<ThreadsResponse> Handle(ThreadsArguments request, CancellationToken cancellationToken)
|
16 | 54 | {
|
17 | 55 | return Task.FromResult(new ThreadsResponse
|
18 | 56 | {
|
19 |
| - // TODO: This is an empty container of threads...do we need to make a thread? |
20 |
| - Threads = new Container<System.Threading.Thread>() |
| 57 | + // TODO: Omnisharp supports multithreaded debugging (where multiple threads can be debugged at once), but we don't. |
| 58 | + // This means we always need to set AllThreadsStoppped and AllThreadsContinued in our events. |
| 59 | + // But if we one day support multithreaded debugging, we'd need a way to associate debugged runspaces with .NET threads in a consistent way |
| 60 | + Threads = new Container<Thread>(MainDebuggedThread), |
21 | 61 | });
|
22 | 62 | }
|
23 | 63 | }
|
| 64 | + */ |
| 65 | + |
| 66 | + internal class ThreadsTempHandler : ThreadsTempHandlerBase |
| 67 | + { |
| 68 | + internal static Thread PipelineThread { get; } = new Thread { Id = 1, Name = "PowerShell Pipeline Thread" }; |
| 69 | + |
| 70 | + public override Task<ThreadsTempResponse> Handle(ThreadsTempArguments request, CancellationToken cancellationToken) |
| 71 | + { |
| 72 | + return Task.FromResult( |
| 73 | + new ThreadsTempResponse |
| 74 | + { |
| 75 | + Threads = new Container<Thread>(PipelineThread) |
| 76 | + }); |
| 77 | + } |
| 78 | + } |
24 | 79 | }
|
0 commit comments