@@ -112,7 +112,8 @@ private void AssertDebuggerPaused()
112
112
113
113
private void AssertDebuggerStopped (
114
114
string scriptPath = "" ,
115
- int lineNumber = - 1 )
115
+ int lineNumber = - 1 ,
116
+ CommandBreakpointDetails commandBreakpointDetails = default )
116
117
{
117
118
var eventArgs = debuggerStoppedQueue . Take ( new CancellationTokenSource ( 5000 ) . Token ) ;
118
119
@@ -132,6 +133,11 @@ private void AssertDebuggerStopped(
132
133
{
133
134
Assert . Equal ( lineNumber , eventArgs . LineNumber ) ;
134
135
}
136
+
137
+ if ( commandBreakpointDetails is not null )
138
+ {
139
+ Assert . Equal ( commandBreakpointDetails . Name , eventArgs . OriginalEvent . InvocationInfo . MyCommand . Name ) ;
140
+ }
135
141
}
136
142
137
143
private Task < IReadOnlyList < LineBreakpoint > > GetConfirmedBreakpoints ( ScriptFile scriptFile )
@@ -210,7 +216,8 @@ public async Task DebuggerAcceptsScriptArgs()
210
216
Assert . True ( var . IsExpandable ) ;
211
217
212
218
var childVars = debugService . GetVariables ( var . Id ) ;
213
- Assert . Equal ( 9 , childVars . Length ) ;
219
+ // 2 variables plus "Raw View"
220
+ Assert . Equal ( 3 , childVars . Length ) ;
214
221
Assert . Equal ( "\" Bar\" " , childVars [ 0 ] . ValueString ) ;
215
222
Assert . Equal ( "\" Baz\" " , childVars [ 1 ] . ValueString ) ;
216
223
@@ -227,7 +234,7 @@ public async Task DebuggerAcceptsScriptArgs()
227
234
Assert . True ( var . IsExpandable ) ;
228
235
229
236
childVars = debugService . GetVariables ( var . Id ) ;
230
- Assert . Equal ( 8 , childVars . Length ) ;
237
+ Assert . Equal ( 2 , childVars . Length ) ;
231
238
Assert . Equal ( "\" Extra1\" " , childVars [ 0 ] . ValueString ) ;
232
239
}
233
240
@@ -532,14 +539,15 @@ await debugService.SetLineBreakpointsAsync(
532
539
Assert . True ( objVar . IsExpandable ) ;
533
540
534
541
var objChildren = debugService . GetVariables ( objVar . Id ) ;
535
- Assert . Equal ( 9 , objChildren . Length ) ;
542
+ // Two variables plus "Raw View"
543
+ Assert . Equal ( 3 , objChildren . Length ) ;
536
544
537
545
var arrVar = Array . Find ( variables , v => v . Name == "$arrVar" ) ;
538
546
Assert . NotNull ( arrVar ) ;
539
547
Assert . True ( arrVar . IsExpandable ) ;
540
548
541
549
var arrChildren = debugService . GetVariables ( arrVar . Id ) ;
542
- Assert . Equal ( 11 , arrChildren . Length ) ;
550
+ Assert . Equal ( 5 , arrChildren . Length ) ;
543
551
544
552
var classVar = Array . Find ( variables , v => v . Name == "$classVar" ) ;
545
553
Assert . NotNull ( classVar ) ;
@@ -709,7 +717,8 @@ await debugService.SetLineBreakpointsAsync(
709
717
Assert . True ( var . IsExpandable ) ;
710
718
711
719
VariableDetailsBase [ ] childVars = debugService . GetVariables ( var . Id ) ;
712
- Assert . Equal ( 9 , childVars . Length ) ;
720
+ // 2 variables plus "Raw View"
721
+ Assert . Equal ( 3 , childVars . Length ) ;
713
722
Assert . Equal ( "[0]" , childVars [ 0 ] . Name ) ;
714
723
Assert . Equal ( "[1]" , childVars [ 1 ] . Name ) ;
715
724
@@ -772,6 +781,107 @@ await debugService.SetLineBreakpointsAsync(
772
781
Assert . Equal ( "\" John\" " , childVars [ "Name" ] ) ;
773
782
}
774
783
784
+ [ Fact ]
785
+ public async Task DebuggerEnumerableShowsRawView ( )
786
+ {
787
+ CommandBreakpointDetails breakpoint = CommandBreakpointDetails . Create ( "__BreakDebuggerEnumerableShowsRawView" ) ;
788
+ await debugService . SetCommandBreakpointsAsync ( new [ ] { breakpoint } ) . ConfigureAwait ( true ) ;
789
+
790
+ // Execute the script and wait for the breakpoint to be hit
791
+ Task _ = ExecuteVariableScriptFile ( ) ;
792
+ AssertDebuggerStopped ( commandBreakpointDetails : breakpoint ) ;
793
+
794
+ VariableDetailsBase simpleArrayVar = Array . Find (
795
+ GetVariables ( VariableContainerDetails . ScriptScopeName ) ,
796
+ v => v . Name == "$simpleArray" ) ;
797
+ Assert . NotNull ( simpleArrayVar ) ;
798
+ VariableDetailsBase rawDetailsView = Array . Find (
799
+ simpleArrayVar . GetChildren ( NullLogger . Instance ) ,
800
+ v => v . Name == "Raw View" ) ;
801
+ Assert . NotNull ( rawDetailsView ) ;
802
+ Assert . Empty ( rawDetailsView . Type ) ;
803
+ Assert . Empty ( rawDetailsView . ValueString ) ;
804
+ VariableDetailsBase [ ] rawViewChildren = rawDetailsView . GetChildren ( NullLogger . Instance ) ;
805
+ Assert . Equal ( 7 , rawViewChildren . Length ) ;
806
+ Assert . Equal ( "Length" , rawViewChildren [ 0 ] . Name ) ;
807
+ Assert . Equal ( "4" , rawViewChildren [ 0 ] . ValueString ) ;
808
+ Assert . Equal ( "LongLength" , rawViewChildren [ 1 ] . Name ) ;
809
+ Assert . Equal ( "4" , rawViewChildren [ 1 ] . ValueString ) ;
810
+ Assert . Equal ( "Rank" , rawViewChildren [ 2 ] . Name ) ;
811
+ Assert . Equal ( "1" , rawViewChildren [ 2 ] . ValueString ) ;
812
+ Assert . Equal ( "SyncRoot" , rawViewChildren [ 3 ] . Name ) ;
813
+ Assert . Equal ( "IsReadOnly" , rawViewChildren [ 4 ] . Name ) ;
814
+ Assert . Equal ( "$false" , rawViewChildren [ 4 ] . ValueString ) ;
815
+ Assert . Equal ( "IsFixedSize" , rawViewChildren [ 5 ] . Name ) ;
816
+ Assert . Equal ( "$true" , rawViewChildren [ 5 ] . ValueString ) ;
817
+ Assert . Equal ( "IsSynchronized" , rawViewChildren [ 6 ] . Name ) ;
818
+ Assert . Equal ( "$false" , rawViewChildren [ 6 ] . ValueString ) ;
819
+ }
820
+
821
+ [ Fact ]
822
+ public async Task DebuggerDictionaryShowsRawView ( )
823
+ {
824
+ CommandBreakpointDetails breakpoint = CommandBreakpointDetails . Create ( "__BreakDebuggerDictionaryShowsRawView" ) ;
825
+ await debugService . SetCommandBreakpointsAsync ( new [ ] { breakpoint } ) . ConfigureAwait ( true ) ;
826
+
827
+ // Execute the script and wait for the breakpoint to be hit
828
+ Task _ = ExecuteVariableScriptFile ( ) ;
829
+ AssertDebuggerStopped ( commandBreakpointDetails : breakpoint ) ;
830
+
831
+ VariableDetailsBase simpleDictionaryVar = Array . Find (
832
+ GetVariables ( VariableContainerDetails . ScriptScopeName ) ,
833
+ v => v . Name == "$simpleDictionary" ) ;
834
+ Assert . NotNull ( simpleDictionaryVar ) ;
835
+ VariableDetailsBase rawDetailsView = Array . Find (
836
+ simpleDictionaryVar . GetChildren ( NullLogger . Instance ) ,
837
+ v => v . Name == "Raw View" ) ;
838
+ Assert . NotNull ( rawDetailsView ) ;
839
+ Assert . Empty ( rawDetailsView . Type ) ;
840
+ Assert . Empty ( rawDetailsView . ValueString ) ;
841
+ VariableDetailsBase [ ] rawViewChildren = rawDetailsView . GetChildren ( NullLogger . Instance ) ;
842
+ Assert . Equal ( 7 , rawViewChildren . Length ) ;
843
+ Assert . Equal ( "IsReadOnly" , rawViewChildren [ 0 ] . Name ) ;
844
+ Assert . Equal ( "$false" , rawViewChildren [ 0 ] . ValueString ) ;
845
+ Assert . Equal ( "IsFixedSize" , rawViewChildren [ 1 ] . Name ) ;
846
+ Assert . Equal ( "$false" , rawViewChildren [ 1 ] . ValueString ) ;
847
+ Assert . Equal ( "IsSynchronized" , rawViewChildren [ 2 ] . Name ) ;
848
+ Assert . Equal ( "$false" , rawViewChildren [ 2 ] . ValueString ) ;
849
+ Assert . Equal ( "Keys" , rawViewChildren [ 3 ] . Name ) ;
850
+ Assert . Equal ( "Values" , rawViewChildren [ 4 ] . Name ) ;
851
+ Assert . Equal ( "[ValueCollection: 4]" , rawViewChildren [ 4 ] . ValueString ) ;
852
+ Assert . Equal ( "SyncRoot" , rawViewChildren [ 5 ] . Name ) ;
853
+ Assert . Equal ( "Count" , rawViewChildren [ 6 ] . Name ) ;
854
+ Assert . Equal ( "4" , rawViewChildren [ 6 ] . ValueString ) ;
855
+ }
856
+
857
+ [ Fact ]
858
+ public async Task DebuggerDerivedDictionaryPropertyInRawView ( )
859
+ {
860
+ CommandBreakpointDetails breakpoint = CommandBreakpointDetails . Create ( "__BreakDebuggerDerivedDictionaryPropertyInRawView" ) ;
861
+ await debugService . SetCommandBreakpointsAsync ( new [ ] { breakpoint } ) . ConfigureAwait ( true ) ;
862
+
863
+ // Execute the script and wait for the breakpoint to be hit
864
+ Task _ = ExecuteVariableScriptFile ( ) ;
865
+ AssertDebuggerStopped ( commandBreakpointDetails : breakpoint ) ;
866
+
867
+ VariableDetailsBase sortedDictionaryVar = Array . Find (
868
+ GetVariables ( VariableContainerDetails . ScriptScopeName ) ,
869
+ v => v . Name == "$sortedDictionary" ) ;
870
+ Assert . NotNull ( sortedDictionaryVar ) ;
871
+ VariableDetailsBase [ ] simpleDictionaryChildren = sortedDictionaryVar . GetChildren ( NullLogger . Instance ) ;
872
+ // 4 items + Raw View
873
+ Assert . Equal ( 5 , simpleDictionaryChildren . Length ) ;
874
+ VariableDetailsBase rawDetailsView = Array . Find (
875
+ simpleDictionaryChildren ,
876
+ v => v . Name == "Raw View" ) ;
877
+ Assert . NotNull ( rawDetailsView ) ;
878
+ Assert . Empty ( rawDetailsView . Type ) ;
879
+ Assert . Empty ( rawDetailsView . ValueString ) ;
880
+ VariableDetailsBase [ ] rawViewChildren = rawDetailsView . GetChildren ( NullLogger . Instance ) ;
881
+ Assert . Equal ( 4 , rawViewChildren . Length ) ;
882
+ Assert . NotNull ( Array . Find ( rawViewChildren , v => v . Name == "Comparer" ) ) ;
883
+ }
884
+
775
885
[ Fact ]
776
886
public async Task DebuggerVariablePSCustomObjectDisplaysCorrectly ( )
777
887
{
0 commit comments