I found this bug in my current project and then I reproduced in a very simple code, which I share here.
I'm using ReSharper 8.0.2 and Visual Studio 2013.
class Program
{
static void Main(string[] args)
{
var orders = new List<Order> { new Order {ClientId = 10}, new Order()};
var firstOrder = orders.FirstOrDefault();
if ( firstOrder != null && firstOrder.ClientId.HasValue)
{
// In this line resharper suggests that t.ClientId.HasValue is always true. This is wrong.
var ordersWithClient = orders.Where(t => t.ClientId.HasValue).ToList();
}
}
}
class Order
{
public int? ClientId { get; set; }
}