Skip to content

Updated to latest DAP spec #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 1, 2020
Merged
4 changes: 4 additions & 0 deletions debug-adapter-protocol.sha.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This is the last commit we caught up with https://github.com/microsoft/debug-adapter-protocol/commits/gh-pages
lastSha: fd7d38013c9e13e92c0ca4dfa83048d355cb057d

https://github.com/microsoft/debug-adapter-protocol/compare/fd7d38013c9e13e92c0ca4dfa83048d355cb057d..gh-pages
4 changes: 3 additions & 1 deletion src/Dap.Client/DebugAdapterClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.DebugAdapter.Protocol;
using OmniSharp.Extensions.DebugAdapter.Protocol.Client;
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
using OmniSharp.Extensions.DebugAdapter.Shared;
using OmniSharp.Extensions.JsonRpc;
Expand All @@ -24,12 +25,13 @@ public DebugAdapterClientOptions()
public string? Locale { get; set; }
public bool LinesStartAt1 { get; set; }
public bool ColumnsStartAt1 { get; set; }
public string? PathFormat { get; set; }
public PathFormat? PathFormat { get; set; }
public bool SupportsVariableType { get; set; }
public bool SupportsVariablePaging { get; set; }
public bool SupportsRunInTerminalRequest { get; set; }
public bool SupportsMemoryReferences { get; set; }
public bool SupportsProgressReporting { get; set; }
public bool SupportsInvalidatedEvent { get; set; }

IDebugAdapterClientRegistry IJsonRpcHandlerRegistry<IDebugAdapterClientRegistry>.AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions? options) =>
AddHandler(method, handler, options);
Expand Down
1 change: 1 addition & 0 deletions src/Dap.Protocol/Events/EventNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public static class EventNames
{
public const string Initialized = "initialized";
public const string Stopped = "stopped";
public const string Invalidated = "invalidated";
public const string Continued = "continued";
public const string Exited = "exited";
public const string Terminated = "terminated";
Expand Down
12 changes: 11 additions & 1 deletion src/Dap.Protocol/Feature/Events/BreakpointFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public record Breakpoint
public int? Offset { get; init; }
}
}

namespace Events
{
[Parallel]
Expand All @@ -92,12 +93,21 @@ public record BreakpointEvent : IRequest
/// The reason for the event.
/// Values: 'changed', 'new', 'removed', etc.
/// </summary>
public string Reason { get; init; }
public BreakpointEventReason Reason { get; init; }

/// <summary>
/// The 'id' attribute is used to find the target breakpoint and the other attributes are used as the new values.
/// </summary>
public Breakpoint Breakpoint { get; init; }
}


[StringEnum]
public readonly partial struct BreakpointEventReason
{
public static BreakpointEventReason Changed { get; } = new BreakpointEventReason("changed");
public static BreakpointEventReason New { get; } = new BreakpointEventReason("new");
public static BreakpointEventReason Removed { get; } = new BreakpointEventReason("removed");
}
}
}
8 changes: 8 additions & 0 deletions src/Dap.Protocol/Feature/Events/CapabilitiesFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,16 @@ public record Capabilities
/// </summary>
[Optional]
public bool SupportsInstructionBreakpoints { get; set; }

/// <summary>
/// The debug adapter supports 'filterOptions' as an argument on the
/// 'setExceptionBreakpoints' request.
/// </summary>
[Optional]
public bool SupportsExceptionFilterOptions { get; set; }
}
}

namespace Events
{
[Parallel]
Expand Down
55 changes: 55 additions & 0 deletions src/Dap.Protocol/Feature/Events/InvalidatedFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;

// ReSharper disable once CheckNamespace
namespace OmniSharp.Extensions.DebugAdapter.Protocol
{
namespace Events
{
[Parallel]
[Method(EventNames.Invalidated, Direction.ServerToClient)]
[
GenerateHandler,
GenerateHandlerMethods,
GenerateRequestMethods
]
public record InvalidatedEvent : IRequest
{
/// <summary>
/// Optional set of logical areas that got invalidated. This property has a
/// hint characteristic: a client can only be expected to make a 'best
/// effort' in honouring the areas but there are no guarantees. If this
/// property is missing, empty, or if values are not understand the client
/// should assume a single value 'all'.
/// </summary>
[Optional]
public Container<InvalidatedAreas>? Areas { get; init; }

/// <summary>
/// If specified, the client only needs to refetch data related to this
/// thread.
/// </summary>
[Optional]
public int? ThreadId { get; init; }

/// <summary>
/// If specified, the client only needs to refetch data related to this stack
/// frame (and the 'threadId' is ignored).
/// </summary>
[Optional]
public int? StackFrameId { get; init; }
}
}
}
8 changes: 5 additions & 3 deletions src/Dap.Protocol/Feature/Events/LoadedSourceFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public record LoadedSourceEvent : IRequest
public Source Source { get; init; }
}

[JsonConverter(typeof(StringEnumConverter))]
public enum LoadedSourceReason
[StringEnum]
public readonly partial struct LoadedSourceReason
{
New, Changed, Removed
public static LoadedSourceReason Changed { get; } = new LoadedSourceReason("changed");
public static LoadedSourceReason New { get; } = new LoadedSourceReason("new");
public static LoadedSourceReason Removed { get; } = new LoadedSourceReason("removed");
}
}
}
8 changes: 5 additions & 3 deletions src/Dap.Protocol/Feature/Events/ModuleFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public record ModuleEvent : IRequest
public Module Module { get; init; }
}

[JsonConverter(typeof(StringEnumConverter))]
public enum ModuleEventReason
[StringEnum]
public readonly partial struct ModuleEventReason
{
New, Changed, Removed
public static ModuleEventReason Changed { get; } = new ModuleEventReason("changed");
public static ModuleEventReason New { get; } = new ModuleEventReason("new");
public static ModuleEventReason Removed { get; } = new ModuleEventReason("removed");
}
}
}
43 changes: 41 additions & 2 deletions src/Dap.Protocol/Feature/Events/OutputFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,37 @@ public record OutputEvent : IRequest
/// Values: 'console', 'stdout', 'stderr', 'telemetry', etc.
/// </summary>
[Optional]
public string? Category { get; init; }
public OutputEventCategory Category { get; init; } = OutputEventCategory.Console;

/// <summary>
/// The output to report.
/// </summary>
public string Output { get; init; }

/// <summary>
/// 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.
/// Support for keeping an output log organized by grouping related messages.
/// Values:
/// 'start': Start a new group in expanded mode. Subsequent output events are
/// members of the group and should be shown indented.
/// The 'output' attribute becomes the name of the group and is not indented.
/// 'startCollapsed': Start a new group in collapsed mode. Subsequent output
/// events are members of the group and should be shown indented (as soon as
/// the group is expanded).
/// The 'output' attribute becomes the name of the group and is not indented.
/// 'end': End the current group and decreases the indentation of subsequent
/// output events.
/// A non empty 'output' attribute is shown as the unindented end of the
/// group.
/// etc.
/// </summary>
[Optional]
public OutputEventGroup Group { get; set; }

/// <summary>
/// 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. The value should be less
/// than or equal to 2147483647 (2^31-1).
/// </summary>
[Optional]
public long? VariablesReference { get; init; }
Expand Down Expand Up @@ -63,5 +85,22 @@ public record OutputEvent : IRequest
[Optional]
public JToken? Data { get; init; }
}

[StringEnum]
public readonly partial struct OutputEventCategory
{
public static OutputEventCategory Console { get; } = new OutputEventCategory("console");
public static OutputEventCategory StandardOutput { get; } = new OutputEventCategory("stdout");
public static OutputEventCategory StandardError { get; } = new OutputEventCategory("stderr");
public static OutputEventCategory Telemetry { get; } = new OutputEventCategory("telemetry");
}

[StringEnum]
public readonly partial struct OutputEventGroup
{
public static OutputEventGroup Start { get; } = new OutputEventGroup("start");
public static OutputEventGroup StartCollapsed { get; } = new OutputEventGroup("startCollapsed");
public static OutputEventGroup End { get; } = new OutputEventGroup("end");
}
}
}
8 changes: 5 additions & 3 deletions src/Dap.Protocol/Feature/Events/ProcessFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ public record ProcessEvent : IRequest
public long? PointerSize { get; init; }
}

[JsonConverter(typeof(StringEnumConverter))]
public enum ProcessEventStartMethod
[StringEnum]
public readonly partial struct ProcessEventStartMethod
{
Launch, Attach, AttachForSuspendedLaunch
public static ProcessEventStartMethod Launch { get; } = new ProcessEventStartMethod("launch");
public static ProcessEventStartMethod Attach { get; } = new ProcessEventStartMethod("attach");
public static ProcessEventStartMethod AttachForSuspendedLaunch { get; } = new ProcessEventStartMethod("attachForSuspendedLaunch");
}
}
}
25 changes: 23 additions & 2 deletions src/Dap.Protocol/Feature/Events/StoppedFeature.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
using System.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;

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

/// <summary>
/// The full reason for the event, e.g. 'Paused on exception'. This string is shown in the UI as is and must be translated.
Expand Down Expand Up @@ -58,5 +65,19 @@ public record StoppedEvent : IRequest
[Optional]
public bool AllThreadsStopped { get; init; }
}

[StringEnum]
public readonly partial struct StoppedEventReason
{
public static StoppedEventReason Step { get; } = new StoppedEventReason("step");
public static StoppedEventReason Breakpoint { get; } = new StoppedEventReason("breakpoint");
public static StoppedEventReason Exception { get; } = new StoppedEventReason("exception");
public static StoppedEventReason Pause { get; } = new StoppedEventReason("pause");
public static StoppedEventReason Entry { get; } = new StoppedEventReason("entry");
public static StoppedEventReason Goto { get; } = new StoppedEventReason("goto");
public static StoppedEventReason FunctionBreakpoint { get; } = new StoppedEventReason("function breakpoint");
public static StoppedEventReason DataBreakpoint { get; } = new StoppedEventReason("data breakpoint");
public static StoppedEventReason InstructionBreakpoint { get; } = new StoppedEventReason("instruction breakpoint");
}
}
}
19 changes: 17 additions & 2 deletions src/Dap.Protocol/Feature/Events/ThreadFeature.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
using System.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json;
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Generation;
using OmniSharp.Extensions.JsonRpc.Serialization.Converters;

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

/// <summary>
/// The identifier of the thread.
/// </summary>
public long ThreadId { get; init; }
}

[StringEnum]
public readonly partial struct ThreadEventReason
{
public static ThreadEventReason Started { get; } = new ThreadEventReason("started");
public static ThreadEventReason Exited { get; } = new ThreadEventReason("exited");
}
}
}
2 changes: 1 addition & 1 deletion src/Dap.Protocol/Feature/Requests/DisassembleFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public record DisassembledInstruction
public string Instruction { get; init; }

/// <summary>
/// Name of the symbol that correponds with the location of this instruction, if any.
/// Name of the symbol that corresponds with the location of this instruction, if any.
/// </summary>
[Optional]
public string? Symbol { get; init; }
Expand Down
11 changes: 10 additions & 1 deletion src/Dap.Protocol/Feature/Requests/EvaluateFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public record EvaluateArguments : IRequest<EvaluateResponse>
/// etc.
/// </summary>
[Optional]
public string? Context { get; init; }
public EvaluateArgumentsContext? Context { get; init; }

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

[StringEnum]
public readonly partial struct EvaluateArgumentsContext
{
public static EvaluateArgumentsContext Watch { get; } = new EvaluateArgumentsContext("watch");
public static EvaluateArgumentsContext Repl { get; } = new EvaluateArgumentsContext("repl");
public static EvaluateArgumentsContext Hover { get; } = new EvaluateArgumentsContext("hover");
public static EvaluateArgumentsContext Clipboard { get; } = new EvaluateArgumentsContext("clipboard");
}

public record EvaluateResponse
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public record InitializeRequestArguments : IRequest<InitializeResponse>, IInitia
/// Values: 'path', 'uri', etc.
/// </summary>
[Optional]
public string? PathFormat { get; set; }
public PathFormat? PathFormat { get; set; }

/// <summary>
/// Client supports the optional type attribute for variables.
Expand Down Expand Up @@ -94,6 +94,12 @@ public record InitializeRequestArguments : IRequest<InitializeResponse>, IInitia
/// </summary>
[Optional]
public bool SupportsProgressReporting { get; set; }

/// <summary>
/// Client supports the invalidated event.
/// </summary>
[Optional]
public bool SupportsInvalidatedEvent { get; set; }
}

public record InitializeResponse : Capabilities
Expand Down
Loading