I want to put some metadata in all resx files in a solution. Is seems like this could be accomplished using the metadata
element included in the embedded XSD for resx files:
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
I'm not 100% sure that the metadata
element should be used to store arbitrary metadata because I was unable to find any documentation about its intended purpose. But it works just fine as long the resx files are edited using a text editor.
The problem arises when editing the resx file in Visual Studio 2013. The default way to open the resource is the "Managed Resources Editor". Unfortunately, the Managed Resource Editor does not make a distinction between data and metadata. This causes the metadata to be silently changed to data on save. This bug (or perhaps intentional design) has existed since at least 2010.
We have also tried to add elements Managed Resources Editor wouldn't recognize, but these elements were removed on save. The same thing happened for XML comments. This behavior is more understandable, but doesn't leave us with a lot of good options.
Here are the possible solutions I'm aware of:
- Mandate that no one can use the Managed Resources Editor. This might be fine if it were just me, but I can't require this of the whole team. Managed Resources Editor is too useful a tool.
- Require that everyone manually fix the metadata after using Managed Resources Editor. This is too error prone and burdensome.
- Submit an issue to the Visual Studio team. We will be doing this, but we need a solution while we wait, and there are no guarantees a fix will ever come.
- Fork Managed Resources Editor so it behaves how we want. I was unable to find the source and this likely has licensing problems. We are also not interested in maintaining a fork.
- Write own version of Managed Resource Editor. This is like the above option, but way more work than it is worth for our use case.
- Just store the metadata in a
data
tag. This is an obvious hack.
It seems like the failure here isn't with resx files themselves, it is with the Visual Studio tools around resx files. However, we are not moving away from Visual Studio any time soon. Are there any solutions I'm missing?