[Mono-bugs] [Bug 81025][Wis] New - [System.Collections.Generic.Dictionary<TKey, TValue>] Casting to IDictionary and retrieving a non-existent value throws an exception

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Mar 3 15:29:35 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dmitchell at logos.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81025

--- shadow/81025	2007-03-03 15:29:35.000000000 -0500
+++ shadow/81025.tmp.19184	2007-03-03 15:29:35.000000000 -0500
@@ -0,0 +1,46 @@
+Bug#: 81025
+Product: Mono: Class Libraries
+Version: 1.0
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: dmitchell at logos.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [System.Collections.Generic.Dictionary<TKey,TValue>] Casting to IDictionary and retrieving a non-existent value throws an exception
+
+Please fill in this template when reporting a bug, unless you know what you are doing.
+Description of Problem:
+
+An instance of Dictionary<TKey,TValue> is supposed to throw a KeyNotFoundException when 
+the user attempts to retrieve the value associated with a key that is not in the dictionary.
+
+On the other hand, an instance of IDictionary is supposed to return null in similar circumstances.
+
+However, casting a Dictionary<TKey,TValue> to an IDictionary, and then attempting to retrieve 
+the value associated with a key that is not in the dictionary will throw a KeyNotFoundException.
+
+Steps to reproduce the problem:
+1. Create a Dictionary<TKey, TValue>
+2. Cast it to an IDictionary
+3. Attempt to retrieve the value associated with a non-existent key
+
+Actual Results:
+KeyNotFoundException is thrown
+
+Expected Results:
+null should be returned
+
+How often does this happen? 
+Always
+
+Additional Information:
+I will attach some code in a moment that will illustrate this bug: running it on Windows will work 
+fine, but on Mono, it will crash.


More information about the mono-bugs mailing list