Skip to content

Commit caaf907

Browse files
Updated to latest DAP spec (#448)
* Fixed case where if serialization fails the server will die silently. * Updated to latest dap spec * updated enum to have proper string values * Updated coverlet config
1 parent 5f3a5ac commit caaf907

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1486
-393
lines changed

debug-adapter-protocol.sha.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- This is the last commit we caught up with https://github.com/microsoft/debug-adapter-protocol/commits/gh-pages
2+
lastSha: fd7d38013c9e13e92c0ca4dfa83048d355cb057d
3+
4+
https://github.com/microsoft/debug-adapter-protocol/compare/fd7d38013c9e13e92c0ca4dfa83048d355cb057d..gh-pages

src/Dap.Client/DebugAdapterClientOptions.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Newtonsoft.Json.Linq;
55
using OmniSharp.Extensions.DebugAdapter.Protocol;
66
using OmniSharp.Extensions.DebugAdapter.Protocol.Client;
7+
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
78
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
89
using OmniSharp.Extensions.DebugAdapter.Shared;
910
using OmniSharp.Extensions.JsonRpc;
@@ -24,12 +25,13 @@ public DebugAdapterClientOptions()
2425
public string? Locale { get; set; }
2526
public bool LinesStartAt1 { get; set; }
2627
public bool ColumnsStartAt1 { get; set; }
27-
public string? PathFormat { get; set; }
28+
public PathFormat? PathFormat { get; set; }
2829
public bool SupportsVariableType { get; set; }
2930
public bool SupportsVariablePaging { get; set; }
3031
public bool SupportsRunInTerminalRequest { get; set; }
3132
public bool SupportsMemoryReferences { get; set; }
3233
public bool SupportsProgressReporting { get; set; }
34+
public bool SupportsInvalidatedEvent { get; set; }
3335

3436
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry<IDebugAdapterClientRegistry>.AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions? options) =>
3537
AddHandler(method, handler, options);

src/Dap.Protocol/Events/EventNames.cs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public static class EventNames
44
{
55
public const string Initialized = "initialized";
66
public const string Stopped = "stopped";
7+
public const string Invalidated = "invalidated";
78
public const string Continued = "continued";
89
public const string Exited = "exited";
910
public const string Terminated = "terminated";

src/Dap.Protocol/Feature/Events/BreakpointFeature.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public record Breakpoint
7777
public int? Offset { get; init; }
7878
}
7979
}
80+
8081
namespace Events
8182
{
8283
[Parallel]
@@ -92,12 +93,21 @@ public record BreakpointEvent : IRequest
9293
/// The reason for the event.
9394
/// Values: 'changed', 'new', 'removed', etc.
9495
/// </summary>
95-
public string Reason { get; init; }
96+
public BreakpointEventReason Reason { get; init; }
9697

9798
/// <summary>
9899
/// The 'id' attribute is used to find the target breakpoint and the other attributes are used as the new values.
99100
/// </summary>
100101
public Breakpoint Breakpoint { get; init; }
101102
}
103+
104+
105+
[StringEnum]
106+
public readonly partial struct BreakpointEventReason
107+
{
108+
public static BreakpointEventReason Changed { get; } = new BreakpointEventReason("changed");
109+
public static BreakpointEventReason New { get; } = new BreakpointEventReason("new");
110+
public static BreakpointEventReason Removed { get; } = new BreakpointEventReason("removed");
111+
}
102112
}
103113
}

src/Dap.Protocol/Feature/Events/CapabilitiesFeature.cs

+8
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,16 @@ public record Capabilities
221221
/// </summary>
222222
[Optional]
223223
public bool SupportsInstructionBreakpoints { get; set; }
224+
225+
/// <summary>
226+
/// The debug adapter supports 'filterOptions' as an argument on the
227+
/// 'setExceptionBreakpoints' request.
228+
/// </summary>
229+
[Optional]
230+
public bool SupportsExceptionFilterOptions { get; set; }
224231
}
225232
}
233+
226234
namespace Events
227235
{
228236
[Parallel]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Reflection;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using MediatR;
9+
using Newtonsoft.Json;
10+
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
11+
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
12+
using OmniSharp.Extensions.JsonRpc;
13+
using OmniSharp.Extensions.JsonRpc.Generation;
14+
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;
15+
16+
// ReSharper disable once CheckNamespace
17+
namespace OmniSharp.Extensions.DebugAdapter.Protocol
18+
{
19+
namespace Events
20+
{
21+
[Parallel]
22+
[Method(EventNames.Invalidated, Direction.ServerToClient)]
23+
[
24+
GenerateHandler,
25+
GenerateHandlerMethods,
26+
GenerateRequestMethods
27+
]
28+
public record InvalidatedEvent : IRequest
29+
{
30+
/// <summary>
31+
/// Optional set of logical areas that got invalidated. This property has a
32+
/// hint characteristic: a client can only be expected to make a 'best
33+
/// effort' in honouring the areas but there are no guarantees. If this
34+
/// property is missing, empty, or if values are not understand the client
35+
/// should assume a single value 'all'.
36+
/// </summary>
37+
[Optional]
38+
public Container<InvalidatedAreas>? Areas { get; init; }
39+
40+
/// <summary>
41+
/// If specified, the client only needs to refetch data related to this
42+
/// thread.
43+
/// </summary>
44+
[Optional]
45+
public int? ThreadId { get; init; }
46+
47+
/// <summary>
48+
/// If specified, the client only needs to refetch data related to this stack
49+
/// frame (and the 'threadId' is ignored).
50+
/// </summary>
51+
[Optional]
52+
public int? StackFrameId { get; init; }
53+
}
54+
}
55+
}

src/Dap.Protocol/Feature/Events/LoadedSourceFeature.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ public record LoadedSourceEvent : IRequest
3232
public Source Source { get; init; }
3333
}
3434

35-
[JsonConverter(typeof(StringEnumConverter))]
36-
public enum LoadedSourceReason
35+
[StringEnum]
36+
public readonly partial struct LoadedSourceReason
3737
{
38-
New, Changed, Removed
38+
public static LoadedSourceReason Changed { get; } = new LoadedSourceReason("changed");
39+
public static LoadedSourceReason New { get; } = new LoadedSourceReason("new");
40+
public static LoadedSourceReason Removed { get; } = new LoadedSourceReason("removed");
3941
}
4042
}
4143
}

src/Dap.Protocol/Feature/Events/ModuleFeature.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ public record ModuleEvent : IRequest
3232
public Module Module { get; init; }
3333
}
3434

35-
[JsonConverter(typeof(StringEnumConverter))]
36-
public enum ModuleEventReason
35+
[StringEnum]
36+
public readonly partial struct ModuleEventReason
3737
{
38-
New, Changed, Removed
38+
public static ModuleEventReason Changed { get; } = new ModuleEventReason("changed");
39+
public static ModuleEventReason New { get; } = new ModuleEventReason("new");
40+
public static ModuleEventReason Removed { get; } = new ModuleEventReason("removed");
3941
}
4042
}
4143
}

src/Dap.Protocol/Feature/Events/OutputFeature.cs

+41-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,37 @@ public record OutputEvent : IRequest
2626
/// Values: 'console', 'stdout', 'stderr', 'telemetry', etc.
2727
/// </summary>
2828
[Optional]
29-
public string? Category { get; init; }
29+
public OutputEventCategory Category { get; init; } = OutputEventCategory.Console;
3030

3131
/// <summary>
3232
/// The output to report.
3333
/// </summary>
3434
public string Output { get; init; }
3535

3636
/// <summary>
37-
/// If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request.
37+
/// Support for keeping an output log organized by grouping related messages.
38+
/// Values:
39+
/// 'start': Start a new group in expanded mode. Subsequent output events are
40+
/// members of the group and should be shown indented.
41+
/// The 'output' attribute becomes the name of the group and is not indented.
42+
/// 'startCollapsed': Start a new group in collapsed mode. Subsequent output
43+
/// events are members of the group and should be shown indented (as soon as
44+
/// the group is expanded).
45+
/// The 'output' attribute becomes the name of the group and is not indented.
46+
/// 'end': End the current group and decreases the indentation of subsequent
47+
/// output events.
48+
/// A non empty 'output' attribute is shown as the unindented end of the
49+
/// group.
50+
/// etc.
51+
/// </summary>
52+
[Optional]
53+
public OutputEventGroup Group { get; set; }
54+
55+
/// <summary>
56+
/// If an attribute 'variablesReference' exists and its value is > 0, the
57+
/// output contains objects which can be retrieved by passing
58+
/// 'variablesReference' to the 'variables' request. The value should be less
59+
/// than or equal to 2147483647 (2^31-1).
3860
/// </summary>
3961
[Optional]
4062
public long? VariablesReference { get; init; }
@@ -63,5 +85,22 @@ public record OutputEvent : IRequest
6385
[Optional]
6486
public JToken? Data { get; init; }
6587
}
88+
89+
[StringEnum]
90+
public readonly partial struct OutputEventCategory
91+
{
92+
public static OutputEventCategory Console { get; } = new OutputEventCategory("console");
93+
public static OutputEventCategory StandardOutput { get; } = new OutputEventCategory("stdout");
94+
public static OutputEventCategory StandardError { get; } = new OutputEventCategory("stderr");
95+
public static OutputEventCategory Telemetry { get; } = new OutputEventCategory("telemetry");
96+
}
97+
98+
[StringEnum]
99+
public readonly partial struct OutputEventGroup
100+
{
101+
public static OutputEventGroup Start { get; } = new OutputEventGroup("start");
102+
public static OutputEventGroup StartCollapsed { get; } = new OutputEventGroup("startCollapsed");
103+
public static OutputEventGroup End { get; } = new OutputEventGroup("end");
104+
}
66105
}
67106
}

src/Dap.Protocol/Feature/Events/ProcessFeature.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ public record ProcessEvent : IRequest
5454
public long? PointerSize { get; init; }
5555
}
5656

57-
[JsonConverter(typeof(StringEnumConverter))]
58-
public enum ProcessEventStartMethod
57+
[StringEnum]
58+
public readonly partial struct ProcessEventStartMethod
5959
{
60-
Launch, Attach, AttachForSuspendedLaunch
60+
public static ProcessEventStartMethod Launch { get; } = new ProcessEventStartMethod("launch");
61+
public static ProcessEventStartMethod Attach { get; } = new ProcessEventStartMethod("attach");
62+
public static ProcessEventStartMethod AttachForSuspendedLaunch { get; } = new ProcessEventStartMethod("attachForSuspendedLaunch");
6163
}
6264
}
6365
}

src/Dap.Protocol/Feature/Events/StoppedFeature.cs

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
using System.Threading;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Reflection;
6+
using System.Threading;
27
using System.Threading.Tasks;
38
using MediatR;
9+
using Newtonsoft.Json;
410
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
511
using OmniSharp.Extensions.JsonRpc;
612
using OmniSharp.Extensions.JsonRpc.Generation;
13+
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;
714

815
// ReSharper disable once CheckNamespace
916
namespace OmniSharp.Extensions.DebugAdapter.Protocol
@@ -24,7 +31,7 @@ public record StoppedEvent : IRequest
2431
/// For backward compatibility this string is shown in the UI if the 'description' attribute is missing (but it must not be translated).
2532
/// Values: 'step', 'breakpoint', 'exception', 'pause', 'entry', 'goto', 'function breakpoint', 'data breakpoint', etc.
2633
/// </summary>
27-
public string Reason { get; init; }
34+
public StoppedEventReason Reason { get; init; }
2835

2936
/// <summary>
3037
/// The full reason for the event, e.g. 'Paused on exception'. This string is shown in the UI as is and must be translated.
@@ -58,5 +65,19 @@ public record StoppedEvent : IRequest
5865
[Optional]
5966
public bool AllThreadsStopped { get; init; }
6067
}
68+
69+
[StringEnum]
70+
public readonly partial struct StoppedEventReason
71+
{
72+
public static StoppedEventReason Step { get; } = new StoppedEventReason("step");
73+
public static StoppedEventReason Breakpoint { get; } = new StoppedEventReason("breakpoint");
74+
public static StoppedEventReason Exception { get; } = new StoppedEventReason("exception");
75+
public static StoppedEventReason Pause { get; } = new StoppedEventReason("pause");
76+
public static StoppedEventReason Entry { get; } = new StoppedEventReason("entry");
77+
public static StoppedEventReason Goto { get; } = new StoppedEventReason("goto");
78+
public static StoppedEventReason FunctionBreakpoint { get; } = new StoppedEventReason("function breakpoint");
79+
public static StoppedEventReason DataBreakpoint { get; } = new StoppedEventReason("data breakpoint");
80+
public static StoppedEventReason InstructionBreakpoint { get; } = new StoppedEventReason("instruction breakpoint");
81+
}
6182
}
6283
}

src/Dap.Protocol/Feature/Events/ThreadFeature.cs

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
using System.Threading;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Reflection;
6+
using System.Threading;
27
using System.Threading.Tasks;
38
using MediatR;
9+
using Newtonsoft.Json;
10+
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
411
using OmniSharp.Extensions.JsonRpc;
512
using OmniSharp.Extensions.JsonRpc.Generation;
13+
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;
614

715
// ReSharper disable once CheckNamespace
816
namespace OmniSharp.Extensions.DebugAdapter.Protocol
@@ -22,12 +30,19 @@ public record ThreadEvent : IRequest
2230
/// The reason for the event.
2331
/// Values: 'started', 'exited', etc.
2432
/// </summary>
25-
public string Reason { get; init; }
33+
public ThreadEventReason Reason { get; init; }
2634

2735
/// <summary>
2836
/// The identifier of the thread.
2937
/// </summary>
3038
public long ThreadId { get; init; }
3139
}
40+
41+
[StringEnum]
42+
public readonly partial struct ThreadEventReason
43+
{
44+
public static ThreadEventReason Started { get; } = new ThreadEventReason("started");
45+
public static ThreadEventReason Exited { get; } = new ThreadEventReason("exited");
46+
}
3247
}
3348
}

src/Dap.Protocol/Feature/Requests/DisassembleFeature.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public record DisassembledInstruction
8585
public string Instruction { get; init; }
8686

8787
/// <summary>
88-
/// Name of the symbol that correponds with the location of this instruction, if any.
88+
/// Name of the symbol that corresponds with the location of this instruction, if any.
8989
/// </summary>
9090
[Optional]
9191
public string? Symbol { get; init; }

src/Dap.Protocol/Feature/Requests/EvaluateFeature.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public record EvaluateArguments : IRequest<EvaluateResponse>
4040
/// etc.
4141
/// </summary>
4242
[Optional]
43-
public string? Context { get; init; }
43+
public EvaluateArgumentsContext? Context { get; init; }
4444

4545
/// <summary>
4646
/// Specifies details on how to format the Evaluate result.
@@ -49,6 +49,15 @@ public record EvaluateArguments : IRequest<EvaluateResponse>
4949
public ValueFormat? Format { get; init; }
5050
}
5151

52+
[StringEnum]
53+
public readonly partial struct EvaluateArgumentsContext
54+
{
55+
public static EvaluateArgumentsContext Watch { get; } = new EvaluateArgumentsContext("watch");
56+
public static EvaluateArgumentsContext Repl { get; } = new EvaluateArgumentsContext("repl");
57+
public static EvaluateArgumentsContext Hover { get; } = new EvaluateArgumentsContext("hover");
58+
public static EvaluateArgumentsContext Clipboard { get; } = new EvaluateArgumentsContext("clipboard");
59+
}
60+
5261
public record EvaluateResponse
5362
{
5463
/// <summary>

src/Dap.Protocol/Feature/Requests/InitializeRequestFeature.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public record InitializeRequestArguments : IRequest<InitializeResponse>, IInitia
6363
/// Values: 'path', 'uri', etc.
6464
/// </summary>
6565
[Optional]
66-
public string? PathFormat { get; set; }
66+
public PathFormat? PathFormat { get; set; }
6767

6868
/// <summary>
6969
/// Client supports the optional type attribute for variables.
@@ -94,6 +94,12 @@ public record InitializeRequestArguments : IRequest<InitializeResponse>, IInitia
9494
/// </summary>
9595
[Optional]
9696
public bool SupportsProgressReporting { get; set; }
97+
98+
/// <summary>
99+
/// Client supports the invalidated event.
100+
/// </summary>
101+
[Optional]
102+
public bool SupportsInvalidatedEvent { get; set; }
97103
}
98104

99105
public record InitializeResponse : Capabilities

0 commit comments

Comments
 (0)