@@ -15,6 +15,13 @@ namespace DebuggerTests
1515{
1616 public class GetPropertiesTests : DebuggerTests
1717 {
18+ public enum AutoEvaluate
19+ {
20+ On ,
21+ Off ,
22+ Unset ,
23+ }
24+
1825 public GetPropertiesTests ( ITestOutputHelper testOutput ) : base ( testOutput )
1926 { }
2027
@@ -253,24 +260,8 @@ public GetPropertiesTests(ITestOutputHelper testOutput) : base(testOutput)
253260 [ MemberData ( nameof ( ClassGetPropertiesTestData ) , parameters : false ) ]
254261 [ MemberData ( nameof ( StructGetPropertiesTestData ) , parameters : true ) ]
255262 [ MemberData ( nameof ( StructGetPropertiesTestData ) , parameters : false ) ]
256- public async Task InspectTypeInheritedMembers ( string type_name , bool ? own_properties , bool ? accessors_only , string [ ] expected_names , Dictionary < string , ( JObject , bool ) > all_props , bool is_async ) => await CheckInspectLocalsAtBreakpointSite (
257- $ "DebuggerTests.GetPropertiesTests.{ type_name } ",
258- $ "InstanceMethod{ ( is_async ? "Async" : "" ) } ", 1 , $ "DebuggerTests.GetPropertiesTests.{ type_name } ." + ( is_async ? "InstanceMethodAsync" : "InstanceMethod" ) ,
259- $ "window.setTimeout(function() {{ invoke_static_method_async ('[debugger-test] DebuggerTests.GetPropertiesTests.{ type_name } :run'); }})",
260- wait_for_event_fn : async ( pause_location ) =>
261- {
262- var frame_id = pause_location [ "callFrames" ] [ 0 ] [ "callFrameId" ] . Value < string > ( ) ;
263- var frame_locals = await GetProperties ( frame_id ) ;
264- var this_obj = GetAndAssertObjectWithName ( frame_locals , "this" ) ;
265- var this_props = await GetProperties ( this_obj [ "value" ] ? [ "objectId" ] ? . Value < string > ( ) , own_properties : own_properties , accessors_only : accessors_only ) ;
266-
267- AssertHasOnlyExpectedProperties ( expected_names , this_props . Values < JObject > ( ) ) ;
268- await CheckExpectedProperties ( expected_names , name => GetAndAssertObjectWithName ( this_props , name ) , all_props ) ;
269-
270- // indexer properties shouldn't show up here
271- var item = this_props . FirstOrDefault ( jt => jt [ "name" ] ? . Value < string > ( ) == "Item" ) ;
272- Assert . Null ( item ) ;
273- } ) ;
263+ public async Task InspectTypeInheritedMembers ( string type_name , bool ? own_properties , bool ? accessors_only , string [ ] expected_names , Dictionary < string , ( JObject , bool ) > all_props , bool is_async ) =>
264+ await InspectTypeInheritedMembersInternal ( type_name , own_properties , accessors_only , expected_names , all_props , is_async , AutoEvaluate . Unset ) ;
274265
275266 public static IEnumerable < object [ ] > MembersForLocalNestedStructData ( bool is_async )
276267 => StructGetPropertiesTestData ( false ) . Select ( datum => datum [ 1 ..] ) ;
@@ -444,7 +435,7 @@ await EvaluateOnCallFrameAndCheck(frame_id,
444435 ) ;
445436 }
446437
447- private async Task CheckExpectedProperties ( string [ ] expected_names , Func < string , JToken > get_actual_prop , Dictionary < string , ( JObject , bool ) > all_props )
438+ private async Task CheckExpectedProperties ( string [ ] expected_names , Func < string , JToken > get_actual_prop , Dictionary < string , ( JObject , bool ) > all_props , bool autoEvaluate = false )
448439 {
449440 foreach ( var exp_name in expected_names )
450441 {
@@ -463,7 +454,13 @@ private async Task CheckExpectedProperties(string[] expected_names, Func<string,
463454 // from `{name: "..", value: {}, ..}
464455 // but for getters we actually have: `{name: "..", get: {..} }`
465456 // and no `value`
466- await CheckValue ( actual_prop , exp_prop , exp_name ) ;
457+ if ( ! autoEvaluate )
458+ await CheckValue ( actual_prop , exp_prop , exp_name ) ;
459+ else
460+ {
461+ if ( exp_prop [ "value" ] . Type != JTokenType . Null )
462+ await CheckValue ( actual_prop [ "value" ] , exp_prop [ "value" ] , exp_name ) ;
463+ }
467464 }
468465 else
469466 {
@@ -623,5 +620,46 @@ await CheckInspectLocalsAtBreakpointSite(
623620 await CheckProps ( pubInternalAndProtected , expectedPublicInternalAndProtected , "result" ) ;
624621 await CheckProps ( priv , expectedPriv , "private" ) ;
625622 } ) ;
623+
624+ [ ConditionalTheory ( nameof ( RunningOnChrome ) ) ]
625+ [ MemberData ( nameof ( ClassGetPropertiesTestData ) , parameters : true ) ]
626+ [ MemberData ( nameof ( ClassGetPropertiesTestData ) , parameters : false ) ]
627+ [ MemberData ( nameof ( StructGetPropertiesTestData ) , parameters : true ) ]
628+ [ MemberData ( nameof ( StructGetPropertiesTestData ) , parameters : false ) ]
629+ public async Task InspectTypeInheritedMembersAutoEvaluateOn ( string type_name , bool ? own_properties , bool ? accessors_only , string [ ] expected_names , Dictionary < string , ( JObject , bool ) > all_props , bool is_async ) =>
630+ await InspectTypeInheritedMembersInternal ( type_name , own_properties , accessors_only , expected_names , all_props , is_async , AutoEvaluate . On ) ;
631+
632+ [ ConditionalTheory ( nameof ( RunningOnChrome ) ) ]
633+ [ MemberData ( nameof ( ClassGetPropertiesTestData ) , parameters : true ) ]
634+ [ MemberData ( nameof ( ClassGetPropertiesTestData ) , parameters : false ) ]
635+ [ MemberData ( nameof ( StructGetPropertiesTestData ) , parameters : true ) ]
636+ [ MemberData ( nameof ( StructGetPropertiesTestData ) , parameters : false ) ]
637+ public async Task InspectTypeInheritedMembersAutoEvaluateOff ( string type_name , bool ? own_properties , bool ? accessors_only , string [ ] expected_names , Dictionary < string , ( JObject , bool ) > all_props , bool is_async ) =>
638+ await InspectTypeInheritedMembersInternal ( type_name , own_properties , accessors_only , expected_names , all_props , is_async , AutoEvaluate . Off ) ;
639+
640+ public async Task InspectTypeInheritedMembersInternal ( string type_name , bool ? own_properties , bool ? accessors_only , string [ ] expected_names , Dictionary < string , ( JObject , bool ) > all_props , bool is_async , AutoEvaluate auto_evaluate_status )
641+ {
642+ if ( auto_evaluate_status == AutoEvaluate . On )
643+ await cli . SendCommand ( "DotnetDebugger.setEvaluationOptions" , JObject . FromObject ( new { options = new { noFuncEval = false } } ) , token ) ;
644+ else if ( auto_evaluate_status == AutoEvaluate . Off )
645+ await cli . SendCommand ( "DotnetDebugger.setEvaluationOptions" , JObject . FromObject ( new { options = new { noFuncEval = true } } ) , token ) ;
646+ await CheckInspectLocalsAtBreakpointSite (
647+ $ "DebuggerTests.GetPropertiesTests.{ type_name } ",
648+ $ "InstanceMethod{ ( is_async ? "Async" : "" ) } ", 1 , $ "DebuggerTests.GetPropertiesTests.{ type_name } ." + ( is_async ? "InstanceMethodAsync" : "InstanceMethod" ) ,
649+ $ "window.setTimeout(function() {{ invoke_static_method_async ('[debugger-test] DebuggerTests.GetPropertiesTests.{ type_name } :run'); }})",
650+ wait_for_event_fn : async ( pause_location ) =>
651+ {
652+ var frame_id = pause_location [ "callFrames" ] [ 0 ] [ "callFrameId" ] . Value < string > ( ) ;
653+ var frame_locals = await GetProperties ( frame_id ) ;
654+ var this_obj = GetAndAssertObjectWithName ( frame_locals , "this" ) ;
655+ var this_props = await GetProperties ( this_obj [ "value" ] ? [ "objectId" ] ? . Value < string > ( ) , own_properties : own_properties , accessors_only : accessors_only ) ;
656+ AssertHasOnlyExpectedProperties ( expected_names , this_props . Values < JObject > ( ) ) ;
657+ await CheckExpectedProperties ( expected_names , name => GetAndAssertObjectWithName ( this_props , name ) , all_props , auto_evaluate_status == AutoEvaluate . On ) ;
658+
659+ // indexer properties shouldn't show up here
660+ var item = this_props . FirstOrDefault ( jt => jt [ "name" ] ? . Value < string > ( ) == "Item" ) ;
661+ Assert . Null ( item ) ;
662+ } ) ;
663+ }
626664 }
627665}
0 commit comments