EvilRoslynAnalyzers
EvilRoslynAnalyzers copied to clipboard
Feature idea: every number should be a constant in one single class
Magic numbers are evil, therefore a constant should be introduced for each. A codefixer should create a constant for each number that is not. All the constants should be created in one single class called Constants and the created name should be the written name of the number.
E.g.
Console.WriteLine(5);
Becomes
Console.WriteLine(Constants.Five);
Instead of single class with multiple constants, I'd prefere one class per value.
Usage:
Console.WriteLine((new Universe.Mathematics.Numbers.Integers.Five()).IntegerOfFive);
// prints 5.0123
Console.WriteLine((new Universe.Mathematics.Numbers.Decimals.Five.Zero.One.Two.Three()).FloatOfFiveDotZeroOneTwentyThree);
The class shall implement own interface, so mocking and IoC could be easy.