@@ -47,6 +47,17 @@ private static IEnumerable<object[]> TestDebuggerAttributes_GenericDictionaries(
47
47
new ( "[\" Two\" ]" , "2" ) ,
48
48
}
49
49
} ;
50
+ CustomKeyedCollection < string , int > collection = new ( ) ;
51
+ collection . GetKeyForItemHandler = value => ( 2 * value ) . ToString ( ) ;
52
+ collection . InsertItem ( 0 , 1 ) ;
53
+ collection . InsertItem ( 1 , 3 ) ;
54
+ yield return new object [ ] { collection ,
55
+ new KeyValuePair < string , string > [ ]
56
+ {
57
+ new ( "[\" 2\" ]" , "1" ) ,
58
+ new ( "[\" 6\" ]" , "3" ) ,
59
+ }
60
+ } ;
50
61
}
51
62
52
63
private static IEnumerable < object [ ] > TestDebuggerAttributes_NonGenericDictionaries ( )
@@ -173,7 +184,7 @@ public static IEnumerable<object[]> TestDebuggerAttributes_Inputs()
173
184
174
185
[ ConditionalTheory ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsDebuggerTypeProxyAttributeSupported ) ) ]
175
186
[ MemberData ( nameof ( TestDebuggerAttributes_InputsPresentedAsDictionary ) ) ]
176
- public static void TestDebuggerAttributes_Dictionary ( IDictionary obj , KeyValuePair < string , string > [ ] expected )
187
+ public static void TestDebuggerAttributes_Dictionary ( object obj , KeyValuePair < string , string > [ ] expected )
177
188
{
178
189
DebuggerAttributes . ValidateDebuggerDisplayReferences ( obj ) ;
179
190
DebuggerAttributeInfo info = DebuggerAttributes . ValidateDebuggerTypeProxyProperties ( obj ) ;
@@ -206,5 +217,32 @@ public static void TestDebuggerAttributes_Null(object obj)
206
217
TargetInvocationException tie = Assert . Throws < TargetInvocationException > ( ( ) => Activator . CreateInstance ( proxyType , ( object ) null ) ) ;
207
218
Assert . IsType < ArgumentNullException > ( tie . InnerException ) ;
208
219
}
220
+
221
+ private class CustomKeyedCollection < TKey , TValue > : KeyedCollection < TKey , TValue > where TKey : notnull
222
+ {
223
+ public CustomKeyedCollection ( ) : base ( )
224
+ {
225
+ }
226
+
227
+ public CustomKeyedCollection ( IEqualityComparer < TKey > comparer ) : base ( comparer )
228
+ {
229
+ }
230
+
231
+ public CustomKeyedCollection ( IEqualityComparer < TKey > comparer , int dictionaryCreationThreshold ) : base ( comparer , dictionaryCreationThreshold )
232
+ {
233
+ }
234
+
235
+ public Func < TValue , TKey > GetKeyForItemHandler { get ; set ; }
236
+
237
+ protected override TKey GetKeyForItem ( TValue item )
238
+ {
239
+ return GetKeyForItemHandler ( item ) ;
240
+ }
241
+
242
+ public new void InsertItem ( int index , TValue item )
243
+ {
244
+ base . InsertItem ( index , item ) ;
245
+ }
246
+ }
209
247
}
210
248
}
0 commit comments