-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use local Newtonsoft settings when serializing/deserializing instead …
…of assigning global settings (#3402) By assigning global settings, this SDK would affect Json serialization done by users with Newtonsoft outside of this SDK. Now we use the same settings as before (to avoid regressing on #3903), but without assigning them globally. Addresses #3358
- Loading branch information
1 parent
005260a
commit 12a737a
Showing
43 changed files
with
328 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Microsoft.Azure.Devices.E2ETests | ||
{ | ||
/// <summary> | ||
/// A class to initialize JsonSerializerSettings which can be applied to the project. | ||
/// </summary> | ||
internal static class JsonSerializerSettingsInitializer | ||
{ | ||
/// <summary> | ||
/// A static instance of JsonSerializerSettings which sets DateParseHandling to None. | ||
/// </summary> | ||
/// <remarks> | ||
/// By default, serializing/deserializing with Newtonsoft.Json will try to parse date-formatted | ||
/// strings to a date type, which drops trailing zeros in the microseconds date portion. By | ||
/// specifying DateParseHandling with None, the original string will be read as-is. For more details | ||
/// about the known issue, see https://github.com/JamesNK/Newtonsoft.Json/issues/1511. | ||
/// </remarks> | ||
private static readonly JsonSerializerSettings s_settings = new JsonSerializerSettings | ||
{ | ||
DateParseHandling = DateParseHandling.None | ||
}; | ||
|
||
/// <summary> | ||
/// Returns JsonSerializerSettings Func delegate | ||
/// </summary> | ||
internal static JsonSerializerSettings GetJsonSerializerSettings() | ||
{ | ||
return s_settings; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.