Search code examples
c#expression-treesinteger-overflowdevforce

Problems with DevForce queries within a checked context


We are in the process of switching over our codebase to have the Check for arithmetic overflow/underflow option turned on by default and we've run into problems with our DevForce queries.

I'm able to reproduce the problem with a very basic query such as this against the NorthwindIB database:

var coolProducts = em.Products.Where(p => p.UnitsInStock == 42).Execute();

By doing some debugging, it looks like DevForce is trying to add that query to the cache which involves making a hash code for the query. The class that does that hash code generation (ExpressionHashCodeCalculator) is missing a switch case for the ConvertChecked ExpressionType and so it throws an ArgumentException saying "Unknown Expression type".

It seems the compiler sprinkles that ConvertChecked thing all over the place in expressions when you are running in a checked context.


Solution

  • Thanks for reporting this. It will be fixed in the next release, due in March.