Skip to content

Commit 98f5e05

Browse files
Merge pull request #92 from OmniSharp/fix/json2
fix #75
2 parents 0bec92c + b6a751d commit 98f5e05

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

LSP.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protocol", "src\Protocol\Pr
4545
EndProject
4646
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "src\Server\Server.csproj", "{E540868F-438E-4F7F-BBB7-010D6CB18A57}"
4747
EndProject
48+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7E4A7675-45F3-4636-88AC-2C158C1A140D}"
49+
ProjectSection(SolutionItems) = preProject
50+
cake.config = cake.config
51+
EndProjectSection
52+
EndProject
4853
Global
4954
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5055
Debug|Any CPU = Debug|Any CPU

src/Protocol/Serialization/Converters/SupportsConverter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
5353
.Invoke(null, new [] { reader.Value });
5454
}
5555

56+
if (targetType == typeof(bool))
57+
{
58+
return new Supports<bool>(false, false);
59+
}
60+
5661
var target = serializer.Deserialize(reader, targetType);
5762

5863
return OfValueMethod

src/Protocol/Supports.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol
55
{
66
public struct Supports<T> : ISupports
77
{
8-
public Supports(bool isSupported, T value)
8+
private readonly bool? _isSupported;
9+
public Supports(bool? isSupported, T value)
910
{
10-
IsSupported = isSupported;
11+
_isSupported = isSupported;
1112
Value = value;
1213
}
1314

14-
public Supports(bool isSupported)
15+
public Supports(bool? isSupported)
1516
{
16-
IsSupported = isSupported;
17+
_isSupported = isSupported;
1718
Value = default(T);
1819
}
1920

2021
public T Value { get; set; }
21-
public bool IsSupported { get; set; }
22+
public bool IsSupported => _isSupported ?? false;
2223
public Type ValueType => typeof(T);
2324
object ISupports.Value => Value;
2425

@@ -41,7 +42,7 @@ public static Supports<T> OfValue<T>(T value)
4142
return new Supports<T>(value != null, value);
4243
}
4344

44-
public static Supports<T> OfBoolean<T>(bool isSupported)
45+
public static Supports<T> OfBoolean<T>(bool? isSupported)
4546
{
4647
return new Supports<T>(isSupported);
4748
}

test/Lsp.Tests/Capabilities/Client/ClientCapabilitiesTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,12 @@ public void SimpleTest(string expected)
7070
var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject<ClientCapabilities>(expected);
7171
deresult.Should().BeEquivalentTo(model, o => o.ConfigureForSupports(Logger));
7272
}
73+
74+
[Theory, JsonFixture]
75+
public void Github_Issue_75(string expected)
76+
{
77+
Action a = () => JObject.Parse(expected).ToObject(typeof(ClientCapabilities), new Serializer(ClientVersion.Lsp3).JsonSerializer);
78+
a.Should().NotThrow();
79+
}
7380
}
7481
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"textDocument": {
3+
"completion": {
4+
"completionItem": {
5+
"commitCharactersSupport": null,
6+
"documentationFormat": null,
7+
"snippetSupport": false
8+
},
9+
"dynamicRegistration": null
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)