.NET project file analyzers community

Proj2005: Escape XML nodes of resource values

In some scenarios it can be useful to have some XML (HTML) based markup in resources files. It is strongly recommended to escape that XML using either <![CDATA[/]]> or &lt;/@gt; escaping sequences.

Non-compliant

<?xml version="1.0" encoding="utf-8"?>
<root>
 <data name="King" xml:space="preserve">
    <value><b>Koning</b></value>
  </data>
  <data name="Queen" xml:space="preserve">
    <value><b>Koningin</b></value>
  </data>
</root>

Compliant

<?xml version="1.0" encoding="utf-8"?>
<root>
 <data name="King" xml:space="preserve">
    <value><![CDATA[[<b>Koning</b>]]></value>
  </data>
  <data name="Queen" xml:space="preserve">
    <value>&lt;b&gt;Koningin&lt;/b&gt;</value>
  </data>
</root>