I want to put some metadata in all resx files in the solution. It looks like this can be accomplished with 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 am not 100% sure that the metadata element should be used to store arbitrary metadata, because I could not find documentation about its intended purpose. But it works fine while resx files are being edited with a text editor.
The problem occurs when editing the resx file in Visual Studio 2013. By default, the Managed Resource Editor is used to open the resource. Unfortunately, the managed resource editor does not distinguish between data and metadata. This causes the metadata to be quietly changed to save data. This error (or perhaps intentional design) has existed since at least 2010 .
We also tried to add elements. The Managed Resource Editor would not recognize it, but these elements were deleted when saved. The same thing happened with XML comments. This behavior is more understandable, but does not leave us with many good options.
Here are the possible solutions that I know of:
- The mandate is that no one can use the Managed Resource Editor. It might be good if it were just me, but I cannot demand this from the whole team. The managed resource editor is too useful for the tool.
- Require everyone to manually correct metadata after using the managed resource editor. It is too error prone and burdensome.
- Send the question to the Visual Studio team. We will do this, but we need a solution while we wait, and there is no guarantee that a correction will come.
- The Fork Managed Resource Editor, so it behaves the way we want. I could not find the source, and this probably has licensing issues. We are also not interested in supporting forks.
- Write your own version of the Managed Resource Editor. This is similar to the above option, but it is more than for our use case.
- Just save the metadata in the
data tag. This is an obvious hack.
It seems that the failure here is not in the resx files themselves, but in the Visual Studio tools around the resx files. However, we are not leaving Visual Studio any time soon. Are there any solutions that I am missing?
source share