[Mono-bugs] [Bug 520760] New: HashSet<T> implementation of ICollection<T>.Add method throws exception when item already in HashSet
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Jul 9 14:26:19 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=520760
Summary: HashSet<T> implementation of ICollection<T>.Add method
throws exception when item already in HashSet
Classification: Mono
Product: Mono: Class Libraries
Version: 2.2.x
Platform: Macintosh
OS/Version: Mac OS X 10.5
Status: NEW
Severity: Normal
Priority: P5 - None
Component: CORLIB
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: glenn.gervais at logos.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.1) Gecko/20090624 Firefox/3.5
Sample run from csharp shell...
[11:10:27][~]$csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> using System.Collections.Generic;
csharp> ICollection<string> foo = new HashSet<string>();
csharp> foo.Add("a");
csharp> foo.Add("b");
csharp> foo.Add("c");
csharp> foo.Add("c");
System.ArgumentException: Value does not fall within the expected range.
at
System.Collections.Generic.HashSet`1[System.Object].System.Collections.Generic.ICollection<T>.Add
(System.Object item) [0x00000]
at Class4.Host (System.Object& $retval) [0x00000]
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object&
result, System.Boolean& result_set) [0x00000]
at Mono.CSharpShell.Evaluate (System.String input) [0x00000]
csharp> quit;
Adding an item twice on Microsofts implementation does not throw an exception
Reproducible: Always
Steps to Reproduce:
Run code similar to csharp code shown in details
Actual Results:
ArgumentException is thrown
Expected Results:
ArgumentException is not thrown
As a workaround don't cast to an ICollection<T>, use HashSet<T>
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list