Handle windows paths in ResXFileRef, for conversion to string case
authorAnkit Jain <ankit.jain@xamarin.com>
Mon, 13 Mar 2017 17:05:50 +0000 (13:05 -0400)
committerMarek Safar <marek.safar@gmail.com>
Tue, 14 Mar 2017 08:00:59 +0000 (09:00 +0100)
- convert the path a little earlier to handle the case for conversion to
  string
- Fixes earlier commit a3195b79f6fdba3a8d59f0de5a881f90dcf7d458
- And enable the corresponding test

mcs/class/System.Windows.Forms/System.Resources/ResXFileRef.cs
mcs/class/System.Windows.Forms/Test/System.Resources/ResXFileRefTest.cs

index 5200d86426a514927bce318bda44ae3d77d0c7c4..308c92c115df4ee93de946617c2f570f32863d22 100644 (file)
@@ -68,6 +68,10 @@ namespace System.Resources {
                                if (parts.Length == 1)
                                        throw new ArgumentException ("value");
 
+                               string filename = parts [0];
+                               if (Path.DirectorySeparatorChar == '/')
+                                       filename = filename.Replace ("\\", "/");
+
                                Type type = Type.GetType (parts [1]);
                                if (type == typeof(string)) {
                                        Encoding encoding;
@@ -77,15 +81,11 @@ namespace System.Resources {
                                                encoding = Encoding.Default;
                                        }
 
-                                       using (TextReader reader = new StreamReader(parts [0], encoding)) {
+                                       using (TextReader reader = new StreamReader(filename, encoding)) {
                                                return reader.ReadToEnd();
                                        }
                                }
 
-                               string filename = parts [0];
-                               if (Path.DirectorySeparatorChar == '/')
-                                       filename = filename.Replace ("\\", "/");
-
                                using (FileStream file = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                                        buffer = new byte [file.Length];
                                        file.Read(buffer, 0, (int) file.Length);
index c09738e6da7dbe4ddba9892284502227b0a8c39e..5ea7baaaafd1b5692b9bf3a696ee0af1fda9c4ba 100644 (file)
@@ -230,7 +230,6 @@ namespace MonoTests.System.Resources
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void ConvertFrom_Type_String_FilePathWithBackslashes ()
                {
                        if (Path.DirectorySeparatorChar == '\\')