This is why I think you should treat warnings as errors:
When you have a long chain of methods where something can turn out null:
var amount = _client.SnatchLeftoverOrders( _username, _password, "pepperoni").Where( o => o.Ingredients.Any("mushrooms").Where( o => o.Ownersname.ToUpper == _incomingName ).Amount();
Or something like this - there are many places where zero exceptions can occur.
The code is much simpler when you put these lines in a try / catch than add FirstOrDefaults () and then paste in! null
If you have a catch, you have to do something with the Exception object or this is an error (if you treat warnings as errors.
This is not a way to win the “polished programming” medal, but it simplifies things. There is too much stuff for nannies in programming these days.
source share