I am wondering why CA1305 code analysis rule - specify IFormatProvider does not work for TryParse methods?
For example, using the "All Microsoft Rules" rule set, Code Analysis gives CA1305 a warning for the following code:
static void Main(string[] args) { string text = args[0]; double value = double.Parse(text); }
but does not give CA1305 warning for the following code:
static void Main(string[] args) { string text = args[0]; double value; if (!double.TryParse(text, out value)) value = 0; }
I find this very unfortunate because TryParse methods are the right way to do parsing if the input line is not reliable.
Does anyone know if the CA1305 rule applies to TryParse methods in some new version of the code analysis tool or some third party?
Stipo source share