Change case-insensitive Json default in SignalR (#10814)

This commit is contained in:
Brennan 2019-06-05 21:57:18 -07:00 committed by GitHub
parent 81f2d46660
commit 5b56de966e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -762,7 +762,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
options.IgnoreNullValues = false;
options.IgnoreReadOnlyProperties = false;
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.PropertyNameCaseInsensitive = false;
options.PropertyNameCaseInsensitive = true;
options.MaxDepth = 64;
options.DictionaryKeyPolicy = null;
options.DefaultBufferSize = 16 * 1024;

View File

@ -101,6 +101,26 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
Assert.Equal(expectedMessage, message);
}
[Fact]
public void ReadCaseInsensitivePropertiesByDefault()
{
var input = Frame("{\"type\":2,\"invocationId\":\"123\",\"item\":{\"StrIngProp\":\"test\",\"DoublePrOp\":3.14159,\"IntProp\":43,\"DateTimeProp\":\"2019-06-03T22:00:00\",\"NuLLProp\":null,\"ByteARRProp\":\"AgQG\"}}");
var binder = new TestBinder(null, typeof(TemporaryCustomObject));
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
JsonHubProtocol.TryParseMessage(ref data, binder, out var message);
var streamItemMessage = Assert.IsType<StreamItemMessage>(message);
Assert.Equal(new TemporaryCustomObject()
{
ByteArrProp = new byte[] { 2, 4, 6 },
IntProp = 43,
DoubleProp = 3.14159,
StringProp = "test",
DateTimeProp = DateTime.Parse("6/3/2019 10:00:00 PM")
}, streamItemMessage.Item);
}
public static IDictionary<string, JsonProtocolTestData> CustomProtocolTestData => new[]
{
new JsonProtocolTestData("InvocationMessage_HasFloatArgument", new InvocationMessage(null, "Target", new object[] { 1, "Foo", 2.0f }), true, true, "{\"type\":1,\"target\":\"Target\",\"arguments\":[1,\"Foo\",2]}"),