Skip to content

Commit

Permalink
Fix Debugger display of JS strings that contain Date strings
Browse files Browse the repository at this point in the history
Addresses microsoft#106. Json.net will automatically try to parse strings that look like date strings. If one of these is recieved as the value in a Node debug message, we end up displaying the wrong value in the debugger.

Fix, make sure we always use DateTimeParse.None when dealing with messages from the debugger. If we do need to parse a date string, we should handle those cases explicitly.

closes microsoft#106
  • Loading branch information
mjbvz committed Apr 26, 2016
1 parent 409b772 commit c217961
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ sealed class DebuggerClient : IDebuggerClient {
private ConcurrentDictionary<int, TaskCompletionSource<JObject>> _messages =
new ConcurrentDictionary<int, TaskCompletionSource<JObject>>();

private readonly static Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings() {
DateParseHandling = Newtonsoft.Json.DateParseHandling.None
};

public DebuggerClient(IDebuggerConnection connection) {
Utilities.ArgumentNotNull("connection", connection);

Expand Down Expand Up @@ -116,7 +120,7 @@ private void OnConnectionClosed(object sender, EventArgs e) {
/// <param name="sender">Sender.</param>
/// <param name="args">Event arguments.</param>
private void OnOutputMessage(object sender, MessageEventArgs args) {
JObject message = JObject.Parse(args.Message);
var message = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(args.Message, jsonSettings);
var messageType = (string)message["type"];

switch (messageType) {
Expand Down

0 comments on commit c217961

Please sign in to comment.