New issue 21 by ilya.ind...@gmail.com: GroupBy fails on null keys
http://code.google.com/p/linqbridge/issues/detail?id=21
The following test fails with LINQBridge and passes with System.Core:
[Test]
public void GroupBy_NullKey()
{
var arr = new[] { "notnull", null };
var groups = arr.GroupBy(s => s);
foreach (var @group in groups)
{
Console.WriteLine(@group.Key ?? "[null]");
}
}
Proposed solution:
Use as a backing store for Lookup<TKey, TElement> not Dictionary<TKey, ...>
but Dictionary<Wrapped<TKey>, ...>, where Wrapped<TKey> is some wrapper
structure that would never be null.
Here is a proof-of-concept implementation of this Wrapped<> structure and
it's equality comparer.
Attachments:
Wrapped.cs 1.7 KB
Comment #3 on issue 21 by azizatif: GroupBy fails on null keys
http://code.google.com/p/linqbridge/issues/detail?id=21
(No comment was entered for this change.)
Comment #4 on issue 21 by azizatif: GroupBy fails on null keys
Comment #5 on issue 21 by azizatif: GroupBy fails on null keys
http://code.google.com/p/linqbridge/issues/detail?id=21
Fixed in changeset c74eb37b988b[1]
[1]
http://code.google.com/p/linqbridge/source/detail?r=c74eb37b988be35a8a62b703218414dc889b5372
The Count property of the Lookup is now broken.
What do you have against wrapping dictionary key in the non-nullable
structure? This seems to be more "straight solution".
Please, take a look at my solution:
http://code.google.com/r/ilyaindustry-linqbridge-issue21/source/detail?r=00f4036bafdf260f69e4910006c8c62b931ea18d
PS: Thanks for migrating to mercurial.