Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
192f131
Sample debug adapter reciever
david-driscoll Jul 19, 2019
a0dcf03
Added output handling of Debug Adapter Protocol serialization
david-driscoll Jul 20, 2019
e8801d0
Removed some comments
david-driscoll Jul 20, 2019
7ce175f
fixed failing tests
david-driscoll Jul 20, 2019
62b7cb7
Use interlocked increment
david-driscoll Jul 20, 2019
d89cb20
wip with models, requests and events
david-driscoll Jul 20, 2019
0fc3939
Added DAP models, requests and events
david-driscoll Jul 20, 2019
7286c74
Fixed casing on property names
david-driscoll Jul 20, 2019
3abbb23
Updated namespaces
david-driscoll Jul 21, 2019
460b55d
Updated events to go the correct direction (from the adapter to the c…
david-driscoll Sep 4, 2019
9d3c7cd
remove extra Reciever
TylerLeonhardt Sep 4, 2019
376a411
fix initializeresponse payload
TylerLeonhardt Sep 5, 2019
0291179
WORKAROUND: set success to true to allow messaging to work for now
TylerLeonhardt Sep 5, 2019
d7d1e8d
Merge pull request #167 from TylerLeonhardt/misc-dap-fixes
david-driscoll Sep 9, 2019
cf67cdf
Merge pull request #166 from TylerLeonhardt/patch-1
david-driscoll Sep 9, 2019
4908f44
JsonRpcServer.Dispose() works now
TylerLeonhardt Sep 11, 2019
4605713
additional changes for disposable
TylerLeonhardt Sep 11, 2019
712779f
switch null to new JObject so it can still be parsed into the right type
TylerLeonhardt Sep 14, 2019
18f046b
Merge pull request #168 from TylerLeonhardt/jsonrpcserver-now-disposable
david-driscoll Sep 14, 2019
81b7a1c
Merge pull request #169 from TylerLeonhardt/patch-1
david-driscoll Sep 14, 2019
00a71e2
Merge remote-tracking branch 'origin/master' into dap
david-driscoll Sep 23, 2019
ad627ee
fix up WriteJson for DAP error handling
TylerLeonhardt Sep 24, 2019
d3c0ae2
Merge pull request #172 from TylerLeonhardt/add-errorhandling-to-dap
david-driscoll Sep 24, 2019
a5e210a
Write request id when serializing
bjorkstromm Sep 24, 2019
c7adb13
Fix tests
TylerLeonhardt Sep 24, 2019
44bb20a
Merge pull request #174 from TylerLeonhardt/fix-tests
david-driscoll Sep 25, 2019
8872c70
bump
david-driscoll Sep 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion LSP.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29025.244
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -50,6 +50,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
cake.config = cake.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dap.Protocol", "src\Dap.Protocol\Dap.Protocol.csproj", "{F2C9D555-118E-442B-A953-9A7B58A53F33}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dap.Server", "src\Dap.Server\Dap.Server.csproj", "{E1A9123B-A236-4240-8C82-A61BD85C3BF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -156,6 +160,30 @@ Global
{E540868F-438E-4F7F-BBB7-010D6CB18A57}.Release|x64.Build.0 = Release|Any CPU
{E540868F-438E-4F7F-BBB7-010D6CB18A57}.Release|x86.ActiveCfg = Release|Any CPU
{E540868F-438E-4F7F-BBB7-010D6CB18A57}.Release|x86.Build.0 = Release|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x64.ActiveCfg = Debug|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x64.Build.0 = Debug|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x86.ActiveCfg = Debug|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x86.Build.0 = Debug|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|Any CPU.Build.0 = Release|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x64.ActiveCfg = Release|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x64.Build.0 = Release|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x86.ActiveCfg = Release|Any CPU
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x86.Build.0 = Release|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x64.ActiveCfg = Debug|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x64.Build.0 = Debug|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x86.ActiveCfg = Debug|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x86.Build.0 = Debug|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|Any CPU.Build.0 = Release|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x64.ActiveCfg = Release|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x64.Build.0 = Release|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x86.ActiveCfg = Release|Any CPU
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -169,6 +197,8 @@ Global
{97437BE1-2EC3-4F6B-AC75-C3E099040A07} = {2F323ED5-EBF8-45E1-B9D3-C014561B3DDA}
{92B331E9-5225-428D-AE82-37F5F46156A3} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
{E540868F-438E-4F7F-BBB7-010D6CB18A57} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
{F2C9D555-118E-442B-A953-9A7B58A53F33} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
{E1A9123B-A236-4240-8C82-A61BD85C3BF4} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D38DD0EC-D095-4BCD-B8AF-2D788AF3B9AE}
Expand Down
8 changes: 8 additions & 0 deletions src/Dap.Protocol/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Dap.Protocol
{
public class Class1
{
}
}
21 changes: 21 additions & 0 deletions src/Dap.Protocol/Dap.Protocol.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<AssemblyName>OmniSharp.Extensions.DebugAdapter</AssemblyName>
<RootNamespace>OmniSharp.Extensions.DebugAdapter.Protocol</RootNamespace>
<PackageDescription>Debug Adapter Protocol models, classes, interfaces and helper methods</PackageDescription>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\JsonRpc\JsonRpc.csproj" />
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>OmniSharp.Extensions.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>OmniSharp.Extensions.LanguageClient, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions src/Dap.Server/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Dap.Server
{
public class Class1
{
}
}
16 changes: 16 additions & 0 deletions src/Dap.Server/Dap.Server.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<AssemblyName>OmniSharp.Extensions.DebugAdapter.Server</AssemblyName>
<RootNamespace>OmniSharp.Extensions.DebugAdapter.Server</RootNamespace>
<PackageDescription>You can use this package to create a debug adapter, that will be consumed by many clients</PackageDescription>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Dap.Protocol\Dap.Protocol.csproj" />
<ProjectReference Include="..\DebugAdapterRpc\DebugAdapterRpc.csproj" />
</ItemGroup>

</Project>
4 changes: 0 additions & 4 deletions src/JsonRpc/Client/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@

namespace OmniSharp.Extensions.JsonRpc.Client
{
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class Notification
{
[JsonProperty("jsonrpc")]
public string ProtocolVersion { get; } = "2.0";

public string Method { get; set; }

public object Params { get; set; }
Expand Down
4 changes: 0 additions & 4 deletions src/JsonRpc/Client/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@

namespace OmniSharp.Extensions.JsonRpc.Client
{
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class Request
{
public object Id { get; set; }

[JsonProperty("jsonrpc")]
public string ProtocolVersion { get; } = "2.0";

public string Method { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
Expand Down
12 changes: 6 additions & 6 deletions src/JsonRpc/Client/Response.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using ServerRequest = OmniSharp.Extensions.JsonRpc.Server.Request;

namespace OmniSharp.Extensions.JsonRpc.Client
{
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class Response
{
public Response(object id)
public Response(object id, ServerRequest request)
{
Id = id;
Request = request;
}

public Response(object id, object result)
public Response(object id, object result, ServerRequest request)
{
Id = id;
Result = result;
Request = request;
}

[JsonProperty("jsonrpc")]
public string ProtocolVersion { get; set; } = "2.0";

public object Id { get; set; }

public object Result { get; set; }
public ServerRequest Request { get; }
}
}
92 changes: 92 additions & 0 deletions src/JsonRpc/DapReciever.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc.Server;
using OmniSharp.Extensions.JsonRpc.Server.Messages;

namespace OmniSharp.Extensions.JsonRpc
{
public class DapReciever : IReciever
{
public (IEnumerable<Renor> results, bool hasResponse) GetRequests(JToken container)
{
var result = GetRenor(container);
return (new[] { result }, result.IsResponse);
}

public bool IsValid(JToken container)
{
if (container is JObject)
{
return true;
}

return false;
}

protected virtual Renor GetRenor(JToken @object)
{
if (!( @object is JObject request ))
{
return new InvalidRequest(null, "Not an object");
}

if (!request.TryGetValue("seq", out var id))
{
return new InvalidRequest(null, "No sequence given");
}

if (!request.TryGetValue("type", out var type))
{
return new InvalidRequest(null, "No type given");
}
var sequence = id.Value<long>();
var messageType = type.Value<string>();

if (messageType == "event")
{
if (!request.TryGetValue("event", out var @event))
{
return new InvalidRequest(null, "No event given");
}
return new Notification(@event.Value<string>(), request.TryGetValue("body", out var body) ? body : null);
}
if (messageType == "request")
{
if (!request.TryGetValue("command", out var command))
{
return new InvalidRequest(null, "No command given");
}
return new Request(sequence, command.Value<string>(), request.TryGetValue("arguments", out var body) ? body : null);
}
if (messageType == "response")
{
if (!request.TryGetValue("request_seq", out var request_seq))
{
return new InvalidRequest(null, "No request_seq given");
}
if (!request.TryGetValue("command", out var command))
{
return new InvalidRequest(null, "No command given");
}
if (!request.TryGetValue("success", out var success))
{
return new InvalidRequest(null, "No success given");
}

var bodyValue = request.TryGetValue("body", out var body) ? body : null;

var requestSequence = request_seq.Value<long>();
var successValue = success.Value<bool>();

if (successValue)
{
return new ServerResponse(requestSequence, bodyValue);
}
return new ServerError(requestSequence, bodyValue);
}

throw new NotSupportedException($"Message type {messageType} is not supported");
}
}
}
1 change: 1 addition & 0 deletions src/JsonRpc/ISerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public interface ISerializer
string SerializeObject(object value);
object DeserializeObject(string json, Type type);
T DeserializeObject<T>(string json);
long GetNextId();
}
}
3 changes: 2 additions & 1 deletion src/JsonRpc/JsonRpcServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.JsonRpc.Serialization;

namespace OmniSharp.Extensions.JsonRpc
{
Expand All @@ -17,7 +18,7 @@ public JsonRpcServerOptions()
public Stream Input { get; set; }
public Stream Output { get; set; }
public ILoggerFactory LoggerFactory { get; set; } = new LoggerFactory();
public ISerializer Serializer { get; set; } = new Serializer();
public ISerializer Serializer { get; set; } = new JsonRpcSerializer();
public IRequestProcessIdentifier RequestProcessIdentifier { get; set; } = new ParallelRequestProcessIdentifier();
public IReciever Reciever { get; set; } = new Reciever();
public IServiceCollection Services { get; set; } = new ServiceCollection();
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc/RequestRouterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public virtual async Task<ErrorResponse> RouteRequest(TDescriptor descriptor, Re
_logger.LogDebug("Response value was {Type}", responseValue?.GetType().FullName);
}

return new JsonRpc.Client.Response(request.Id, responseValue);
return new JsonRpc.Client.Response(request.Id, responseValue, request);
}
catch (TaskCanceledException e)
{
Expand Down
30 changes: 3 additions & 27 deletions src/JsonRpc/RpcError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,16 @@

namespace OmniSharp.Extensions.JsonRpc
{

[JsonConverter(typeof(RpcErrorConverter))]
public class RpcError<T>
public class RpcError
{
public RpcError(object id, ErrorMessage<T> message) : this(id, message, "2.0")
{
}

[JsonConstructor]
public RpcError(object id, ErrorMessage<T> message, string protocolVersion)
public RpcError(object id, ErrorMessage message)
{
Id = id;
Error = message;
ProtocolVersion = protocolVersion;
}

[JsonProperty("jsonrpc")]
public string ProtocolVersion { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public object Id { get; }

public ErrorMessage<T> Error { get; }
}

public class RpcError : RpcError<object>
{
public RpcError(object id, ErrorMessage<object> message) : this(id, message, "2.0")
{
}

[JsonConstructor]
public RpcError(object id, ErrorMessage<object> message, string protocolVersion) : base(id, message, protocolVersion)
{
}
public ErrorMessage Error { get; }
}
}
51 changes: 0 additions & 51 deletions src/JsonRpc/RpcErrorConverter.cs

This file was deleted.

Loading