I've got code similar to this:
string s = CreateString();
if (s == "") foo(s);
If s equals "", foo should be called. If string is null, which should never happen, then a NullReferenceException is fine (as this is, after all, an exceptional situation).
CodeAnalysis tells me to test for s.IsNullOrEmpty. This would alter the functionality in a nunintended way.
Performance is not an issue.
Is it safe to suppress the associated CA1820 warning?
Edit: Updated code sample and text to better reflect my case.
Edit: This is the (slightly altered) actual code (it's in a standard IXmlSerializable implementation):
public void ReadXml (XmlReader reader)
// ...
string img = reader.ReadElementString ("Image");
if (img != "") {
Image = Image.FromFile(img);
}
// ...