ResGen.exe properly handles CDATA sections in value nodes
of .resx files. monoresgen.exe doesn't properly return
these values within CDATA sections.

the attached 1 line patch fixes the problem.
sample testing files also included.

to compile & run test with and w/o patch:
monoresgen sample.resx && mcs temp.cs && ./temp.exe

jr

-- 
------------------------------------------------------------
Joel W. Reed                                    412-257-3881
----------   http://home.comcast.net/~joelwreed/  ----------
--- class/System.Windows.Forms/System.Resources/ResXResourceReader.cs.orig      
2004-09-14 22:14:00.000000000 -0400
+++ class/System.Windows.Forms/System.Resources/ResXResourceReader.cs   2004-09-14 
21:58:53.000000000 -0400
@@ -87,7 +87,7 @@ namespace System.Resources
                        if (!gotelement)
                                return null;
                        while (reader.Read ()) {
-                               if (reader.NodeType == XmlNodeType.Text) {
+                               if (reader.NodeType == XmlNodeType.Text || 
reader.NodeType == XmlNodeType.CDATA) {
                                        string v = reader.Value;
                                        return v;
                                }
namespace test
{
                using System; 
    using System.Collections;
                using System.Reflection;
                using System.Resources;

                public class Test
                {
                                public static int Main(string [] args) 
                                {
          // Opens a resource reader and gets an enumerator from it.
          IResourceReader reader = new ResourceReader("sample.resources");
          IDictionaryEnumerator en = reader.GetEnumerator();
      
          // Goes through the enumerator, printing out the key and value pairs.
          while (en.MoveNext()) {
            Console.WriteLine();
            Console.WriteLine("Name: {0}", en.Key);
            Console.WriteLine("Value: {0}", en.Value);
          }
          reader.Close();

          return 0;
                                }
                }
}
<?xml version="1.0" encoding="utf-8" ?>
<root>
  <resheader name="ResMimeType">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="Version">
    <value>1.0.0.0</value>
  </resheader>
  <resheader name="Reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, 
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="Writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, 
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
        <data name="joel">
                <value><![CDATA[reed]]></value>
        </data>
</root>

Reply via email to