whatta / linqbridge

Automatically exported from code.google.com/p/linqbridge
Other
0 stars 0 forks source link

Using Distinct for collections with null element throws ArgumentNullException #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
[Test]
public void NullElementCollection()
{
            var list = new List<string>();
            list.Add(null);
            Assert.AreEqual(list.Distinct().ToList()[0], null);
}

What version of the product are you using? On what operating system?
r239    

Original issue reported on code.google.com by alec.che...@gmail.com on 22 Apr 2010 at 12:32

GoogleCodeExporter commented 9 years ago
Added suggested test (see patch) and it effectively fails with the following 
exception:

System.ArgumentNullException : Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
at System.Linq.Enumerable.<DistinctYield>d__6c`1.MoveNext() in Enumerable.cs: 
line 834
at 
LinqBridge.Tests.EnumerableFixture.Distinct_StringArrayWithOneNull_YieldsSet() 
in EnumerableFixture.cs: line 512 

Original comment by azizatif on 19 Oct 2010 at 9:17

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in r240.

Original comment by azizatif on 19 Oct 2010 at 9:49

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 16 Nov 2010 at 10:11