Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String var containing time, not displayed correctly #303

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 75 additions & 54 deletions Nodejs/Product/Nodejs/Debugger/Serialization/NodeBacktraceVariable.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,76 @@
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//

using System;
using Microsoft.VisualStudioTools.Project;
using Newtonsoft.Json.Linq;

namespace Microsoft.NodejsTools.Debugger.Serialization {
sealed class NodeBacktraceVariable : INodeVariable {
public NodeBacktraceVariable(NodeStackFrame stackFrame, JToken parameter) {
Utilities.ArgumentNotNull("stackFrame", stackFrame);
Utilities.ArgumentNotNull("parameter", parameter);

JToken value = parameter["value"];
Id = (int)value["ref"];
Parent = null;
StackFrame = stackFrame;
Name = (string)parameter["name"] ?? NodeVariableType.AnonymousVariable;
TypeName = (string)value["type"];
Value = (string)value["value"];
Class = (string)value["className"];
try {
Text = (string)value["text"];
} catch (ArgumentException) {
Text = String.Empty;
}
Attributes = NodePropertyAttributes.None;
Type = NodePropertyType.Normal;
}

public int Id { get; private set; }
public NodeEvaluationResult Parent { get; private set; }
public string Name { get; private set; }
public string TypeName { get; private set; }
public string Value { get; private set; }
public string Class { get; private set; }
public string Text { get; private set; }
public NodePropertyAttributes Attributes { get; private set; }
public NodePropertyType Type { get; private set; }
public NodeStackFrame StackFrame { get; private set; }
}
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//

using System;
using Microsoft.VisualStudioTools.Project;
using Newtonsoft.Json.Linq;

namespace Microsoft.NodejsTools.Debugger.Serialization {
sealed class NodeBacktraceVariable : INodeVariable {
public NodeBacktraceVariable(NodeStackFrame stackFrame, JToken parameter) {
Utilities.ArgumentNotNull("stackFrame", stackFrame);
Utilities.ArgumentNotNull("parameter", parameter);

JToken value = parameter["value"];
Id = (int)value["ref"];
Parent = null;
StackFrame = stackFrame;
Name = (string)parameter["name"] ?? NodeVariableType.AnonymousVariable;
TypeName = (string)value["type"];
Value = GetValue((JValue)value["value"]);
Class = (string)value["className"];
try {
Text = (string)value["text"];
} catch (ArgumentException) {
Text = String.Empty;
}
Attributes = NodePropertyAttributes.None;
Type = NodePropertyType.Normal;
}

public int Id { get; private set; }
public NodeEvaluationResult Parent { get; private set; }
public string Name { get; private set; }
public string TypeName { get; private set; }
public string Value { get; private set; }
public string Class { get; private set; }
public string Text { get; private set; }
public NodePropertyAttributes Attributes { get; private set; }
public NodePropertyType Type { get; private set; }
public NodeStackFrame StackFrame { get; private set; }

/// <summary>
/// Converts the JValue to string.
/// </summary>
/// <param name="value">Value which has to be converted to string representation.</param>
/// <returns>String which represents the value.</returns>
private static string GetValue(JValue value) {
if (value == null) {
return null;
}

if (value.Type == JTokenType.Date) {
var parentValue = value.Parent.ToString();
return parentValue.Replace("\"value\": \"", string.Empty)
.Replace("\"", string.Empty);
// var dateTimeValue = (DateTime)value.Value;
// return dateTimeValue.ToUniversalTime().ToString("s") + "Z";
}

return (string)value;
}
}
}
Loading