Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThays Grazia <thaystg@gmail.com>2020-08-15 20:03:15 +0300
committerGitHub <noreply@github.com>2020-08-15 20:03:15 +0300
commit70219cc2b54ebc52a54d24f8973802370bfdcc76 (patch)
tree8bab043b6415e7bad180625b257793f8508d3d6b /sdks/wasm/DebuggerTestSuite/InspectorClient.cs
parent0161714a5adbb8738f1d6227662b6b5aadf90405 (diff)
[wasm] Merge dotnet/runtime changes to mono/mono. (#20249)
* Reformatting files. Merging dotnet/runtime to mono/mono * Removing testharnessstartup from browserdebughost. Fix format of EvaluateOnCallFrameTests. * Fix package.
Diffstat (limited to 'sdks/wasm/DebuggerTestSuite/InspectorClient.cs')
-rw-r--r--sdks/wasm/DebuggerTestSuite/InspectorClient.cs125
1 files changed, 66 insertions, 59 deletions
diff --git a/sdks/wasm/DebuggerTestSuite/InspectorClient.cs b/sdks/wasm/DebuggerTestSuite/InspectorClient.cs
index 84b9414d9c6..7a8e1c87168 100644
--- a/sdks/wasm/DebuggerTestSuite/InspectorClient.cs
+++ b/sdks/wasm/DebuggerTestSuite/InspectorClient.cs
@@ -1,74 +1,81 @@
-using System;
-using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
-using System.Threading;
-using System.Text;
+using System;
using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
+using Newtonsoft.Json.Linq;
-namespace WebAssembly.Net.Debugging {
- internal class InspectorClient : DevToolsClient {
- List<(int, TaskCompletionSource<Result>)> pending_cmds = new List<(int, TaskCompletionSource<Result>)> ();
- Func<string, JObject, CancellationToken, Task> onEvent;
- int next_cmd_id;
+namespace Microsoft.WebAssembly.Diagnostics
+{
+ internal class InspectorClient : DevToolsClient
+ {
+ List<(int, TaskCompletionSource<Result>)> pending_cmds = new List<(int, TaskCompletionSource<Result>)>();
+ Func<string, JObject, CancellationToken, Task> onEvent;
+ int next_cmd_id;
- public InspectorClient (ILogger logger) : base(logger) {}
+ public InspectorClient(ILogger logger) : base(logger) { }
- Task HandleMessage (string msg, CancellationToken token)
- {
- var res = JObject.Parse (msg);
- if (res ["id"] == null)
- DumpProtocol (string.Format("Event method: {0} params: {1}", res ["method"], res ["params"]));
- else
- DumpProtocol (string.Format ("Response id: {0} res: {1}", res ["id"], res));
+ Task HandleMessage(string msg, CancellationToken token)
+ {
+ var res = JObject.Parse(msg);
+ if (res["id"] == null)
+ DumpProtocol(string.Format("Event method: {0} params: {1}", res["method"], res["params"]));
+ else
+ DumpProtocol(string.Format("Response id: {0} res: {1}", res["id"], res));
- if (res ["id"] == null)
- return onEvent (res ["method"].Value<string> (), res ["params"] as JObject, token);
- var id = res ["id"].Value<int> ();
- var idx = pending_cmds.FindIndex (e => e.Item1 == id);
- var item = pending_cmds [idx];
- pending_cmds.RemoveAt (idx);
- item.Item2.SetResult (Result.FromJson (res));
- return null;
- }
+ if (res["id"] == null)
+ return onEvent(res["method"].Value<string>(), res["params"] as JObject, token);
+ var id = res["id"].Value<int>();
+ var idx = pending_cmds.FindIndex(e => e.Item1 == id);
+ var item = pending_cmds[idx];
+ pending_cmds.RemoveAt(idx);
+ item.Item2.SetResult(Result.FromJson(res));
+ return null;
+ }
- public async Task Connect(
- Uri uri,
- Func<string, JObject, CancellationToken, Task> onEvent,
- Func<CancellationToken, Task> send,
- CancellationToken token) {
+ public async Task Connect(
+ Uri uri,
+ Func<string, JObject, CancellationToken, Task> onEvent,
+ Func<CancellationToken, Task> send,
+ CancellationToken token)
+ {
- this.onEvent = onEvent;
- await ConnectWithMainLoops (uri, HandleMessage, send, token);
- }
+ this.onEvent = onEvent;
+ await ConnectWithMainLoops(uri, HandleMessage, send, token);
+ }
- public Task<Result> SendCommand (string method, JObject args, CancellationToken token)
- {
- int id = ++next_cmd_id;
- if (args == null)
- args = new JObject ();
+ public Task<Result> SendCommand(string method, JObject args, CancellationToken token)
+ {
+ int id = ++next_cmd_id;
+ if (args == null)
+ args = new JObject();
- var o = JObject.FromObject (new {
- id = id,
- method = method,
- @params = args
- });
+ var o = JObject.FromObject(new
+ {
+ id = id,
+ method = method,
+ @params = args
+ });
- var tcs = new TaskCompletionSource<Result> ();
- pending_cmds.Add ((id, tcs));
+ var tcs = new TaskCompletionSource<Result>();
+ pending_cmds.Add((id, tcs));
- var str = o.ToString ();
- //Log ("protocol", $"SendCommand: id: {id} method: {method} params: {args}");
+ var str = o.ToString();
+ //Log ("protocol", $"SendCommand: id: {id} method: {method} params: {args}");
- var bytes = Encoding.UTF8.GetBytes (str);
- Send (bytes, token);
- return tcs.Task;
- }
+ var bytes = Encoding.UTF8.GetBytes(str);
+ Send(bytes, token);
+ return tcs.Task;
+ }
- protected virtual void DumpProtocol (string msg){
- // Console.WriteLine (msg);
- //XXX make logging not stupid
- }
- }
-}
+ protected virtual void DumpProtocol(string msg)
+ {
+ // Console.WriteLine (msg);
+ //XXX make logging not stupid
+ }
+ }
+}