mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Design review: Explicitly disable TypeNameHandling in all Json.NET usage
This commit is contained in:
@@ -25,9 +25,10 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
|||||||
private static readonly Regex PortMessageRegex =
|
private static readonly Regex PortMessageRegex =
|
||||||
new Regex(@"^\[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port (\d+)\]$");
|
new Regex(@"^\[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port (\d+)\]$");
|
||||||
|
|
||||||
private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings
|
private static readonly JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||||
|
TypeNameHandling = TypeNameHandling.None
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly HttpClient _client;
|
private readonly HttpClient _client;
|
||||||
@@ -58,7 +59,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
|||||||
|
|
||||||
protected override async Task<T> InvokeExportAsync<T>(NodeInvocationInfo invocationInfo)
|
protected override async Task<T> InvokeExportAsync<T>(NodeInvocationInfo invocationInfo)
|
||||||
{
|
{
|
||||||
var payloadJson = JsonConvert.SerializeObject(invocationInfo, JsonSerializerSettings);
|
var payloadJson = JsonConvert.SerializeObject(invocationInfo, jsonSerializerSettings);
|
||||||
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
|
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
|
||||||
var response = await _client.PostAsync("http://localhost:" + _portNumber, payload);
|
var response = await _client.PostAsync("http://localhost:" + _portNumber, payload);
|
||||||
|
|
||||||
@@ -85,7 +86,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
|||||||
|
|
||||||
case "application/json":
|
case "application/json":
|
||||||
var responseJson = await response.Content.ReadAsStringAsync();
|
var responseJson = await response.Content.ReadAsStringAsync();
|
||||||
return JsonConvert.DeserializeObject<T>(responseJson);
|
return JsonConvert.DeserializeObject<T>(responseJson, jsonSerializerSettings);
|
||||||
|
|
||||||
case "application/octet-stream":
|
case "application/octet-stream":
|
||||||
// Streamed responses have to be received as System.IO.Stream instances
|
// Streamed responses have to be received as System.IO.Stream instances
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
|||||||
{
|
{
|
||||||
private readonly static JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
private readonly static JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||||
|
TypeNameHandling = TypeNameHandling.None
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly SemaphoreSlim _connectionCreationSemaphore = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim _connectionCreationSemaphore = new SemaphoreSlim(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user