mail-archives/mono-bugs/2009-March/086870.html

267 строки
8.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 483985] New: Wrong behavior of generic SortedList compared to .Net behavior
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20483985%5D%20New%3A%20Wrong%20behavior%20of%20generic%20SortedList%0A%20compared%20to%20.Net%20behavior&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="087047.html">
<LINK REL="Next" HREF="086877.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 483985] New: Wrong behavior of generic SortedList compared to .Net behavior</H1>
<B>bugzilla_noreply at novell.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20483985%5D%20New%3A%20Wrong%20behavior%20of%20generic%20SortedList%0A%20compared%20to%20.Net%20behavior&In-Reply-To="
TITLE="[Mono-bugs] [Bug 483985] New: Wrong behavior of generic SortedList compared to .Net behavior">bugzilla_noreply at novell.com
</A><BR>
<I>Tue Mar 10 12:39:01 EDT 2009</I>
<P><UL>
<LI>Previous message: <A HREF="087047.html">[Mono-bugs] [Bug 483950] Console.In.ReadLine doesn't deal with EOF
</A></li>
<LI>Next message: <A HREF="086877.html">[Mono-bugs] [Bug 483985] Wrong behavior of generic SortedList compared to .Net behavior
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#86870">[ date ]</a>
<a href="thread.html#86870">[ thread ]</a>
<a href="subject.html#86870">[ subject ]</a>
<a href="author.html#86870">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE><A HREF="https://bugzilla.novell.com/show_bug.cgi?id=483985">https://bugzilla.novell.com/show_bug.cgi?id=483985</A>
Summary: Wrong behavior of generic SortedList compared to .Net
behavior
Classification: Mono
Product: Mono: Class Libraries
Version: SVN
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">tquerci at gmail.com</A>
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
Found By: ---
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; it; rv:1.9.0.7)
Gecko/2009022800 SUSE/3.0.7-1.2 Firefox/3.0.7
Hi,
the behavior of generic SortedList between .Net and Mono are different.
In depth when you use enumerator from Keys and Values you are able to remove an
element from the sorted list and go on in the enumerator without have any
exception. Moreover you not able to reset the enumerator where is possible on
Net.
THis behavior is tested on VS C# Express
Changes on UnitTest are also provided.
Reproducible: Always
Steps to Reproduce:
// This code show the bug
// The only exception that need to be generated is capture.
// If you run this application without fix you got a uncaptured exception
//
using System;
using System.Collections.Generic;
namespace SortedListTest
{
class Program
{
static void Main(string[] args)
{
SortedList&lt;String, String&gt; contents = new SortedList&lt;string,
string&gt;();
int i;
contents.Add(&quot;key 01&quot;, &quot;key 01&quot;);
contents.Add(&quot;key 02&quot;, &quot;key 02&quot;);
contents.Add(&quot;key 03&quot;, &quot;key 03&quot;);
contents.Add(&quot;key 04&quot;, &quot;key 04&quot;);
contents.Add(&quot;key 05&quot;, &quot;key 05&quot;);
contents.Add(&quot;key 06&quot;, &quot;key 06&quot;);
contents.Add(&quot;key 07&quot;, &quot;key 07&quot;);
contents.Add(&quot;key 08&quot;, &quot;key 08&quot;);
contents.Add(&quot;key 09&quot;, &quot;key 09&quot;);
contents.Add(&quot;key 10&quot;, &quot;key 10&quot;);
IEnumerator&lt;string&gt; en = contents.Keys.GetEnumerator();
string key;
System.Console.Out.WriteLine(&quot;CHECK FOR REMOVE KEY IN THE
SortedList----------------&quot;);
try
{
i = 0;
while (en.MoveNext())
{
key = en.Current;
System.Console.Out.Write(&quot;Key=&quot; + key);
if (i == 4)
{
contents.Remove(key);
System.Console.Out.Write(&quot;\tdeleted&quot;);
}
System.Console.Out.WriteLine(&quot;&quot;);
i++;
}
}
catch (Exception ex)
{
System.Console.Out.WriteLine(&quot;Exception:
&quot;+ex.GetType().ToString()+&quot; - &quot;+ex.Message);
}
System.Console.Out.WriteLine(&quot;&quot;);
System.Console.Out.WriteLine(&quot;CHECK FOR RESET KEY ENUMERATOR IN THE
SortedList----------------&quot;);
en = contents.Keys.GetEnumerator();
i=0;
while (en.MoveNext())
{
key = en.Current;
System.Console.Out.WriteLine(&quot;Key=&quot; + key+&quot; present&quot;);
if (i==4) {
en.Reset();
}
i++;
}
IEnumerator&lt;string&gt; env = contents.Values.GetEnumerator();
string val;
System.Console.Out.WriteLine(&quot;========================================================&quot;);
System.Console.Out.WriteLine(&quot;CHECK FOR REMOVE VALUE IN THE
SortedList----------------&quot;);
try
{
i = 0;
while (env.MoveNext())
{
val = env.Current;
System.Console.Out.Write(&quot;Value=&quot; + val);
if (i == 4)
{
contents.RemoveAt(i);
System.Console.Out.Write(&quot;\tdeleted&quot;);
}
System.Console.Out.WriteLine(&quot;&quot;);
i++;
}
}
catch (Exception ex)
{
System.Console.Out.WriteLine(&quot;Exception:
&quot;+ex.GetType().ToString()+&quot; - &quot;+ex.Message);
}
System.Console.Out.WriteLine(&quot;&quot;);
System.Console.Out.WriteLine(&quot;CHECK FOR RESET VALUE ENUMERATOR IN
THE SortedList----------------&quot;);
env = contents.Keys.GetEnumerator();
i=0;
while (env.MoveNext())
{
val = env.Current;
System.Console.Out.WriteLine(&quot;value=&quot; + val+&quot; present&quot;);
if (i==4) {
env.Reset();
}
i++;
}
System.Console.In.ReadLine();
}
}
}
--
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="087047.html">[Mono-bugs] [Bug 483950] Console.In.ReadLine doesn't deal with EOF
</A></li>
<LI>Next message: <A HREF="086877.html">[Mono-bugs] [Bug 483985] Wrong behavior of generic SortedList compared to .Net behavior
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#86870">[ date ]</a>
<a href="thread.html#86870">[ thread ]</a>
<a href="subject.html#86870">[ subject ]</a>
<a href="author.html#86870">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>