Fix empty strings in ThrowHelper#58733
Conversation
|
I don't really get the purpose of this rule. |
As far as I know, it's supposed to reduce string allocations. |
|
String literals are already interned. So using "" is not going to be an allocation problem :-) |
|
Based on my reading, the advantage is in readability and to reduce the chance of a hidden zero width space character. There was acutally one disadvantage that I saw: It also isn't a constant: I will take this to MSBuild and Stylecop and see if this Analyzer is still needed. Please let me know if any of the above is incorrect and thank you for your help and explanation. |
I personally think the readability is fine :-). The zwsp is interesting. But it hasn't ever been an issue for us, so I don't think it's really needed to change here. |
|
Agreed. I will suggest msbuild doesn't take on this analyzer. I might look at an analyzer for zwsp to highlight any usages to help detect issues. Thank you for your help @CyrusNajmabadi it is much appreciated. |
Replacing empty strings with string.Empty
I ran into this as msbuild relies on Microsoft.CodeAnalysis.Collections and the stylecop analyzer highlighted this problem when we turned on the rule SA1122.
The associated msbuild PR is dotnet/msbuild#7239