mercredi 31 août 2016

Catch calls to decimal.ToString at compile time

I would like to catch all calls to decimal.ToString() in my solution. At compile time.

Is there any trick for this? like overloading ToString and using ObsoleteAttribute?

I can resolve to running a scan (by reflection) once a week through code like this or install and configure some sort of program with static code checking. But this question is about compile time.

The reason for this is that decimal.ToString is culture aware and which in my case might be trouble; i.e. if someone installs the solution on a localised server output might change.
We have a rule not to call decimal.ToString without making it CultureInvariant but it is not always heeded.





Aucun commentaire:

Enregistrer un commentaire