Is it possible to use Rosyln or Resharper to detect possible DivideByZero cases?
问题 I'm trying to determine if there's a programmatic way to check for possible DivideByZeroException in my codebase. My codebase includes a series of relatively simple to relatively complex formulas, approximately 1500 of them (and growing). When new formulas are written, care must be taken to ensure that division is done safely to avoid exceptions during processing of these formulas. E.g. decimal val1 = 1.1m; decimal val2 = 0m; var res = val1/val2; //bad var res = val2 == 0 ? 0 : val1/val2; /