Prechádzať zdrojové kódy

Update Mono debug proxy code (#13053)

This is now equivalent to Mono's commit 612e064 and to the Mono binaries that we'll include in Preview 9
Steve Sanderson 6 rokov pred
rodič
commit
c6f043cb98

+ 16 - 5
src/Components/Blazor/Server/src/MonoDebugProxy/ws-proxy/MonoProxy.cs

@@ -322,8 +322,7 @@ namespace WsProxy {
 									name = method.Name,
 									startLocation = method.StartLocation.ToJObject (),
 									endLocation = method.EndLocation.ToJObject (),
-								}},
-								@this = new { }
+								}}
 						}));
 
 						++frame_id;
@@ -485,11 +484,11 @@ namespace WsProxy {
 			var values = res.Value? ["result"]? ["value"]?.Values<JObject> ().ToArray ();
 
 			var var_list = new List<JObject> ();
-
+			int i = 0;
 			// Trying to inspect the stack frame for DotNetDispatcher::InvokeSynchronously
 			// results in a "Memory access out of bounds", causing 'values' to be null,
 			// so skip returning variable values in that case.
-			for (int i = 0; values != null && i < vars.Length; ++i) {
+			while (values != null && i < var_ids.Length && i < values.Length) {
 				var value = values [i] ["value"];
 				if (((string)value ["description"]) == null)
 					value ["description"] = value ["value"]?.ToString();
@@ -498,12 +497,24 @@ namespace WsProxy {
 					name = vars [i].Name,
 					value = values [i] ["value"]
 				}));
+				i++;
+			}
+			//Async methods are special in the way that local variables can be lifted to generated class fields
+			//value of "this" comes here either
+			while (i < values.Length) {
+				String name = values [i] ["name"].ToString ();
 
+				if (name.IndexOf (">", StringComparison.Ordinal) > 0)
+					name = name.Substring (1, name.IndexOf (">", StringComparison.Ordinal) - 1);
+				var_list.Add (JObject.FromObject (new {
+					name =  name,
+					value = values [i+1] ["value"]
+				}));
+				i = i + 2;
 			}
 			o = JObject.FromObject (new {
 				result = var_list
 			});
-
 			SendResponse (msg_id, Result.Ok (o), token);
 		}