Object reference not set to an instance of an object

I get an exception when I have a GroupBy and a var named 'group' and follow R# advice to convert into a LINQ expression. Simplest case example:

foreach (var group in new int[0].GroupBy(n => n))
{
    var x = group.Key;
    if (x == 1) return;
}


The 'foreach' has a squiggly under it. If I choose to convert into a LINQ expression then I will get the null reference exception.

The workaround is to rename 'group' to something else like 'group0'. Then it works fine.

This is with R# 5.1.1753.3.

1 comment
Comment actions Permalink

Hi,

Thank you for the sample. I have created a bug request and you are
welcome to vote for it and monitor its status at
http://youtrack.jetbrains.net/issue/RSRP-193811

--
Kirill Falk
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

On 10/16/2010 2:05 AM, Scott Bilas wrote:

I get an exception when I have a GroupBy and a var named 'group' and follow R# advice to convert into a LINQ expression. Simplest case example:

>

foreach (var group in new int[0].GroupBy(n =>  n))
{
     var x = group.Key;
     if (x == 1) return;
}

>

The 'foreach' has a squiggly under it. If I choose to convert into a LINQ expression then I will get the null reference exception.

>

The workaround is to rename 'group' to something else like 'group0'. Then it works fine.

>

This is with R# 5.1.1753.3.

>

---
Original message URL: http://devnet.jetbrains.net/message/5275136#5275136



0

Please sign in to leave a comment.