@@ -246,7 +246,7 @@ protected override async Task<bool> AcceptCommand (MessageId id, string method,
246
246
if ( ! ( DotnetObjectId . TryParse ( args [ "objectId" ] , out var objectId ) && objectId . Scheme == "cfo_res" ) )
247
247
break ;
248
248
249
- await SendMonoCommand ( id , new MonoCommands ( $ "MONO.mono_wasm_release_object(' { objectId } ')" ) , token ) ;
249
+ await SendMonoCommand ( id , MonoCommands . ReleaseObject ( objectId ) , token ) ;
250
250
SendResponse ( id , Result . OkFromObject ( new { } ) , token ) ;
251
251
return true ;
252
252
}
@@ -325,9 +325,8 @@ protected override async Task<bool> AcceptCommand (MessageId id, string method,
325
325
}
326
326
327
327
var returnByValue = args [ "returnByValue" ] ? . Value < bool > ( ) ?? false ;
328
- var cmd = new MonoCommands ( $ "MONO.mono_wasm_call_function_on ( { args . ToString ( ) } , { ( returnByValue ? "true" : "false" ) } )" ) ;
328
+ var res = await SendMonoCommand ( id , MonoCommands . CallFunctionOn ( args ) , token ) ;
329
329
330
- var res = await SendMonoCommand ( id , cmd , token ) ;
331
330
if ( ! returnByValue &&
332
331
DotnetObjectId . TryParse ( res . Value ? [ "result" ] ? [ "value" ] ? [ "objectId" ] , out var resultObjectId ) &&
333
332
resultObjectId . Scheme == "cfo_res" )
@@ -349,7 +348,7 @@ async Task<Result> RuntimeGetProperties (MessageId id, DotnetObjectId objectId,
349
348
if ( objectId . Scheme == "scope" )
350
349
return await GetScopeProperties ( id , int . Parse ( objectId . Value ) , token ) ;
351
350
352
- var res = await SendMonoCommand ( id , new MonoCommands ( $ "MONO.mono_wasm_get_details (' { objectId } ', { args } )" ) , token ) ;
351
+ var res = await SendMonoCommand ( id , MonoCommands . GetDetails ( objectId , args ) , token ) ;
353
352
if ( res . IsErr )
354
353
return res ;
355
354
@@ -415,6 +414,9 @@ async Task<bool> OnBreakpointHit (SessionId sessionId, JObject args, Cancellatio
415
414
var method_token = mono_frame [ "method_token" ] . Value < uint > ( ) ;
416
415
var assembly_name = mono_frame [ "assembly_name" ] . Value < string > ( ) ;
417
416
417
+ // This can be different than `method.Name`, like in case of generic methods
418
+ var method_name = mono_frame [ "method_name" ] ? . Value < string > ( ) ;
419
+
418
420
var store = await LoadStore ( sessionId , token ) ;
419
421
var asm = store . GetAssemblyByName ( assembly_name ) ;
420
422
if ( asm == null ) {
@@ -440,11 +442,11 @@ async Task<bool> OnBreakpointHit (SessionId sessionId, JObject args, Cancellatio
440
442
}
441
443
442
444
Log ( "info" , $ "frame il offset: { il_pos } method token: { method_token } assembly name: { assembly_name } ") ;
443
- Log ( "info" , $ "\t method { method . Name } location: { location } ") ;
445
+ Log ( "info" , $ "\t method { method_name } location: { location } ") ;
444
446
frames . Add ( new Frame ( method , location , frame_id - 1 ) ) ;
445
447
446
448
callFrames . Add ( new {
447
- functionName = method . Name ,
449
+ functionName = method_name ,
448
450
callFrameId = $ "dotnet:scope:{ frame_id - 1 } ",
449
451
functionLocation = method . StartLocation . AsLocation ( ) ,
450
452
@@ -461,7 +463,7 @@ async Task<bool> OnBreakpointHit (SessionId sessionId, JObject args, Cancellatio
461
463
description = "Object" ,
462
464
objectId = $ "dotnet:scope:{ frame_id - 1 } ",
463
465
} ,
464
- name = method . Name ,
466
+ name = method_name ,
465
467
startLocation = method . StartLocation . AsLocation ( ) ,
466
468
endLocation = method . EndLocation . AsLocation ( ) ,
467
469
} }
@@ -558,34 +560,30 @@ internal async Task<JToken> TryGetVariableValue (MessageId msg_id, int scope_id,
558
560
return obj ;
559
561
560
562
var scope = context . CallStack . FirstOrDefault ( s => s . Id == scope_id ) ;
561
- var vars = scope . Method . GetLiveVarsAt ( scope . Location . CliLocation . Offset ) ;
563
+ var live_vars = scope . Method . GetLiveVarsAt ( scope . Location . CliLocation . Offset ) ;
562
564
//get_this
563
- int [ ] var_ids = { } ;
564
- var res = await SendMonoCommand ( msg_id , MonoCommands . GetScopeVariables ( scope . Id , var_ids ) , token ) ;
565
- var values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
566
- thisValue = values . FirstOrDefault ( v => v [ "name" ] . Value < string > ( ) == "this" ) ;
565
+ var res = await SendMonoCommand ( msg_id , MonoCommands . GetScopeVariables ( scope . Id , live_vars . Select ( lv => lv . Index ) . ToArray ( ) ) , token ) ;
566
+
567
+ var scope_values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) ? . ToArray ( ) ;
568
+ thisValue = scope_values ? . FirstOrDefault ( v => v [ "name" ] ? . Value < string > ( ) == "this" ) ;
567
569
568
570
if ( ! only_search_on_this ) {
569
- if ( thisValue != null && expression == "this" ) {
571
+ if ( thisValue != null && expression == "this" )
570
572
return thisValue ;
571
- }
572
- //search in locals
573
- var var_id = vars . SingleOrDefault ( v => v . Name == expression ) ;
574
- if ( var_id != null ) {
575
- res = await SendMonoCommand ( msg_id , MonoCommands . GetScopeVariables ( scope . Id , new int [ ] { var_id . Index } ) , token ) ;
576
- values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
577
- return values [ 0 ] ;
578
- }
573
+
574
+ var value = scope_values . SingleOrDefault ( sv => sv [ "name" ] ? . Value < string > ( ) == expression ) ;
575
+ if ( value != null )
576
+ return value ;
579
577
}
580
578
581
579
//search in scope
582
580
if ( thisValue != null ) {
583
581
if ( ! DotnetObjectId . TryParse ( thisValue [ "value" ] [ "objectId" ] , out var objectId ) )
584
582
return null ;
585
583
586
- res = await SendMonoCommand ( msg_id , MonoCommands . GetObjectProperties ( objectId , expandValueTypes : false ) , token ) ;
587
- values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
588
- var foundValue = values . FirstOrDefault ( v => v [ "name" ] . Value < string > ( ) == expression ) ;
584
+ res = await SendMonoCommand ( msg_id , MonoCommands . GetDetails ( objectId ) , token ) ;
585
+ scope_values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
586
+ var foundValue = scope_values . FirstOrDefault ( v => v [ "name" ] . Value < string > ( ) == expression ) ;
589
587
if ( foundValue != null ) {
590
588
foundValue [ "fromThis" ] = true ;
591
589
context . LocalsCache [ foundValue [ "name" ] . Value < string > ( ) ] = foundValue ;
@@ -605,7 +603,6 @@ async Task<bool> OnEvaluateOnCallFrame (MessageId msg_id, int scope_id, string e
605
603
var varValue = await TryGetVariableValue ( msg_id , scope_id , expression , false , token ) ;
606
604
607
605
if ( varValue != null ) {
608
- varValue [ "value" ] [ "description" ] = varValue [ "value" ] [ "className" ] ;
609
606
SendResponse ( msg_id , Result . OkFromObject ( new {
610
607
result = varValue [ "value" ]
611
608
} ) , token ) ;
@@ -650,11 +647,17 @@ async Task<Result> GetScopeProperties (MessageId msg_id, int scope_id, Cancellat
650
647
var var_list = new List < object > ( ) ;
651
648
int i = 0 ;
652
649
for ( ; i < vars . Length && i < values . Length ; i ++ ) {
650
+ // For async methods, we get locals with names, unlike non-async methods
651
+ // and the order may not match the var_ids, so, use the names that they
652
+ // come with
653
+ if ( values [ i ] [ "name" ] != null )
654
+ continue ;
655
+
653
656
ctx . LocalsCache [ vars [ i ] . Name ] = values [ i ] ;
654
657
var_list . Add ( new { name = vars [ i ] . Name , value = values [ i ] [ "value" ] } ) ;
655
658
}
656
659
for ( ; i < values . Length ; i ++ ) {
657
- ctx . LocalsCache [ values [ i ] [ "name" ] . ToString ( ) ] = values [ i ] [ "value" ] ;
660
+ ctx . LocalsCache [ values [ i ] [ "name" ] . ToString ( ) ] = values [ i ] ;
658
661
var_list . Add ( values [ i ] ) ;
659
662
}
660
663
0 commit comments