Reporter | Alexander Korolev (a_korolev) |
---|---|
Created | Apr 17, 2018 5:33:54 PM |
Updated | Apr 17, 2018 5:47:09 PM |
Subsystem | Code Analysis |
Assignee | Ivan Serduk (IvanSerduk) |
Priority | Critical |
State | Submitted |
Type | Bug |
Fix version | 2018.2 |
Affected versions | 2018.1 |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
Wrong inspection in Linq query on second Select of anonymous type. In First Select inspection works correctly.
Sample code:
Sample code:
using System;
using System.Collections.Generic;
using System.Linq;
namespace Test
{
class Program
{
static void Main()
{
var tmp = GetQueryable()
.Select(e => new
{
// Here has no inspection Warnings
A1 = e.A != null ? UseValue(e.A.Value) : 100500
})
.Select(x => new
{
// Here has inspection warning "Possible System.InvalidOperationException"
// VVVVVVVVVV
A2 = x.A1 != null ? UseValue(x.A1.Value) : 100500
});
Console.WriteLine(tmp.Count());
}
static int? UseValue(int value)
{
return value;
}
private class TestData
{
public int? A { get; set; }
}
static IEnumerable<TestData> GetQueryable()
{
return null;
}
}
}