Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 6fca192

Browse files
author
Konstantina Chremmou
committed
Temporary code change to output extra troubleshooting info for VM.get_record.
Signed-off-by: Konstantina Chremmou <[email protected]>
1 parent 21c2ef1 commit 6fca192

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

csharp/autogen/src/JsonRpc.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030

3131
using System;
3232
using System.Collections.Generic;
33+
using System.ComponentModel;
3334
using System.IO;
3435
using System.Net;
36+
using System.Text;
3537
using System.Threading;
3638
using Newtonsoft.Json;
3739
using Newtonsoft.Json.Linq;
@@ -168,6 +170,7 @@ public JsonRpcClient(string baseUrl)
168170
/// IMPORTANT: the latter may contain sensitive data, so handle it carefully.
169171
/// </summary>
170172
public event Action<string> RequestEvent;
173+
public event Action<string> ResponseEvent;
171174

172175
public JsonRpcVersion JsonRpcVersion { get; set; }
173176
public string UserAgent { get; set; }
@@ -218,9 +221,7 @@ private T Rpc<T>(string callName, JToken parameters, JsonSerializer serializer)
218221
// from the Stream rather than allocating strings inbetween
219222
// therefore the latter will be done only in DEBUG mode
220223

221-
#if DEBUG
222224
var settings = CreateSettings(serializer.Converters);
223-
#endif
224225

225226
using (var str = webRequest.GetRequestStream())
226227
using (var sw = new StreamWriter(str))
@@ -257,7 +258,31 @@ private T Rpc<T>(string callName, JToken parameters, JsonSerializer serializer)
257258
string json2 = responseReader.ReadToEnd();
258259
var res2 = JsonConvert.DeserializeObject<JsonResponseV2<T>>(json2, settings);
259260
#else
260-
var res2 = (JsonResponseV2<T>)serializer.Deserialize(responseReader, typeof(JsonResponseV2<T>));
261+
JsonResponseV2<T> res2;
262+
263+
if (callName == "VM.get_record")
264+
{
265+
string json2 = responseReader.ReadToEnd();
266+
267+
var requestProperties = TypeDescriptor.GetProperties(webRequest);
268+
var requestSb = new StringBuilder("\n*** WebRequest Properties:\n");
269+
foreach (PropertyDescriptor prop in requestProperties)
270+
requestSb.AppendFormat("{0} {1}={2}\n", prop.PropertyType, prop.Name, prop.GetValue(webRequest));
271+
272+
var responseProperties = TypeDescriptor.GetProperties(webResponse);
273+
var responseSb = new StringBuilder("*** WebResponse Properties:\n");
274+
foreach (PropertyDescriptor prop in responseProperties)
275+
responseSb.AppendFormat("{0} {1}={2}\n", prop.PropertyType, prop.Name, prop.GetValue(webResponse));
276+
277+
if (ResponseEvent != null)
278+
ResponseEvent(string.Format("{0}\n\n{1}\n\n{2}\n\n", requestSb, responseSb, json2));
279+
280+
res2 = JsonConvert.DeserializeObject<JsonResponseV2<T>>(json2, settings);
281+
}
282+
else
283+
{
284+
res2 = (JsonResponseV2<T>)serializer.Deserialize(responseReader, typeof(JsonResponseV2<T>));
285+
}
261286
#endif
262287
if (res2.Error != null)
263288
{

0 commit comments

Comments
 (0)