@@ -100,29 +100,33 @@ internal static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count()
100100 ExceptionResource . ArgumentOutOfRange_Count ) ;
101101 }
102102
103- internal static void ThrowWrongKeyTypeArgumentException ( object key , Type targetType )
103+ internal static void ThrowWrongKeyTypeArgumentException < T > ( T key , Type targetType )
104104 {
105- throw GetWrongKeyTypeArgumentException ( key , targetType ) ;
105+ // Generic key to move the boxing to the right hand side of throw
106+ throw GetWrongKeyTypeArgumentException ( ( object ) key , targetType ) ;
106107 }
107108
108- internal static void ThrowWrongValueTypeArgumentException ( object value , Type targetType )
109+ internal static void ThrowWrongValueTypeArgumentException < T > ( T value , Type targetType )
109110 {
110- throw GetWrongValueTypeArgumentException ( value , targetType ) ;
111+ // Generic key to move the boxing to the right hand side of throw
112+ throw GetWrongValueTypeArgumentException ( ( object ) value , targetType ) ;
111113 }
112114
113115 private static ArgumentException GetAddingDuplicateWithKeyArgumentException ( object key )
114116 {
115117 return new ArgumentException ( SR . Format ( SR . Argument_AddingDuplicateWithKey , key ) ) ;
116118 }
117119
118- internal static void ThrowAddingDuplicateWithKeyArgumentException ( object key )
120+ internal static void ThrowAddingDuplicateWithKeyArgumentException < T > ( T key )
119121 {
120- throw GetAddingDuplicateWithKeyArgumentException ( key ) ;
122+ // Generic key to move the boxing to the right hand side of throw
123+ throw GetAddingDuplicateWithKeyArgumentException ( ( object ) key ) ;
121124 }
122125
123- internal static void ThrowKeyNotFoundException ( object key )
126+ internal static void ThrowKeyNotFoundException < T > ( T key )
124127 {
125- throw GetKeyNotFoundException ( key ) ;
128+ // Generic key to move the boxing to the right hand side of throw
129+ throw GetKeyNotFoundException ( ( object ) key ) ;
126130 }
127131
128132 internal static void ThrowArgumentException ( ExceptionResource resource )
0 commit comments