Open rillig opened 8 years ago
Another argument against this rule is that using string.Empty
instead of ""
inevitably leads to a mixture of styles, because you can't put string.Empty
inside of an attribute, constant initializer or default parameter.
I would suggest turning this off, by default.
https://github.com/Visual-Stylecop/Visual-StyleCop/wiki/SA1122 currently says:
The rule SA1122 is in the Readability category, therefore it should not matter what code is generated by the compiler. Furthermore, when using
string.Empty
instead of""
, the compiler embeds a reference tostring.Empty
into the compiled code. I didn't check it, but it feels like that takes more bytes in the resulting binary.The C# language specification says:
This sounds like an argument in favor of using string literals directly.
All in all, what is missing is a convincing argument why using string literals is bad.