Method group messes up ItemNotNull

I seem to have a collision between method groups and the (Item)NotNull check by Resharper.

The methods TransActionIsSomething and TransactionIsAnotherThing both have a NotNull annotation on the argument, and return a boolean. The original list 'transactions' is annotated with ItemNotNull, so it is impossible for a null value to reach the Sum. Still, Resharper thinks the 't.DecimalValue' can result in a null reference exception!

When I rewrite the Where so it explicitly calls the method with the (not null) item, Resharper doesn't think there is a possible null reference exception anymore.

public decimal CalculateValue(
[NotNull] [ItemNotNull] IList<ITransaction> transactions)
{
// this line correctly detects t cannot be null, but tells TransactionIsSomething should be converted to method group..
decimal sumA = -1 * transactions.Where(t => TransactionIsSomething(t)).Sum(t => t.DecimalValue);
// but when I convert it to method group like this, it gives a possible null reference exception on t
decimal sumB = 1 * transactions.Where(TransactionIsAnotherThing).Sum(t => t.DecimalValue);
......
}

Am I overlooking something? It looks like a bug to me..

0

Please sign in to leave a comment.