You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will cause the compiler to embed an empty string into the compiled code.
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 to string.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:
Each string literal does not necessarily result in a new string instance. When two or more string literals that are equivalent according to the string equality operator (§7.10.7) appear in the same program, these string literals refer to the same string instance.
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: