diff --git a/Octokit.Tests/SimpleJsonSerializerTests.cs b/Octokit.Tests/SimpleJsonSerializerTests.cs index 9586899e24..36fb12705d 100644 --- a/Octokit.Tests/SimpleJsonSerializerTests.cs +++ b/Octokit.Tests/SimpleJsonSerializerTests.cs @@ -1,5 +1,6 @@ using Octokit.Helpers; using Octokit.Internal; +using System.Collections.Generic; using System.Linq; using System.Text; using Xunit; @@ -119,6 +120,34 @@ public void DeserializesEventInfosWithUnderscoresInName() new SimpleJsonSerializer().Deserialize(json); } + public class MessageSingle + { + public string Message { get; private set; } + } + + [Fact] + public void DeserializesStringsWithHyphensAndUnderscoresIntoString() + { + const string json = @"{""message"":""-my-test-string_with_underscores_""}"; + + var response = new SimpleJsonSerializer().Deserialize(json); + Assert.Equal("-my-test-string_with_underscores_", response.Message); + } + + public class MessageList + { + public IReadOnlyList Message { get; private set; } + } + + [Fact] + public void DeserializesStringsWithHyphensAndUnderscoresIntoStringList() + { + const string json = @"{""message"":""-my-test-string_with_underscores_""}"; + + var response = new SimpleJsonSerializer().Deserialize(json); + Assert.Equal("-my-test-string_with_underscores_", response.Message[0]); + } + [Fact] public void UnderstandsRubyCasing() { diff --git a/Octokit/Http/SimpleJsonSerializer.cs b/Octokit/Http/SimpleJsonSerializer.cs index a6750e8c3c..5835bcac3b 100644 --- a/Octokit/Http/SimpleJsonSerializer.cs +++ b/Octokit/Http/SimpleJsonSerializer.cs @@ -90,7 +90,6 @@ public override object DeserializeObject(object value, Type type) var jsonValue = value as JsonObject; if (stringValue != null) { - stringValue = stringValue.Replace("-", ""); if (ReflectionUtils.GetTypeInfo(type).IsEnum) { // remove '-' from values coming in to be able to enum utf-8