Fixed Guid.Guid(string)
authorDuco Fijma <duco@mono-cvs.ximian.com>
Thu, 21 Feb 2002 08:35:07 +0000 (08:35 -0000)
committerDuco Fijma <duco@mono-cvs.ximian.com>
Thu, 21 Feb 2002 08:35:07 +0000 (08:35 -0000)
svn path=/trunk/mcs/; revision=2558

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Guid.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/GuidTest.cs

index 5ace9096b84aaba0d1b08374367f9db02b260643..2f260f5c9b606648094980a0ac575227e856fd2f 100644 (file)
@@ -1,3 +1,19 @@
+2002-02-21  Duco Fijma <duco@lorentz.xs4all.nl>
+       * Guid.cs: fixed Guid.Guid(string) ctor. Changed format:
+       "{0xdddddddd,0xdddd,0xdddd,{0xdd},{0xdd},{0xdd},{0xdd},{0xdd},{0xdd}}" 
+       to "{0xdddddddd,0xdddd,0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}}" 
+       The former is documented by Microsoft. The latter is how they
+       actually implemented it in mscorlib:-)
+
+Tue Feb 19 20:34:35 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+       * MonoCustomAttrs.cs: hooks to get the custom attributes from the
+       runtime.
+       * MonoType.cs: Implemented custom attributes methods.
+
+
+2002-02-21  Duco Fijma <duco@lorentz.xs4all.nl>
+       * Guid.cs: 
 
 Tue Feb 19 20:34:35 CET 2002 Paolo Molaro <lupus@ximian.com>
 
index 2185226d567e72f30c58531d82ca54f5a8fa6266..7dcd8e85777c210474db168eb9db7fa93a83c475 100755 (executable)
@@ -238,14 +238,18 @@ public struct Guid  : IFormattable, IComparable  {
                        ParseChar (',');
                        ParseHexPrefix ();
                        c = (short) ParseHex (4, false);
+                       ParseChar (',');
+                       ParseChar ('{');
                        for (i=0; i<8; ++i) {
-                               ParseChar (',');
-                               ParseChar ('{');
                                ParseHexPrefix ();
                                d[i] = (byte) ParseHex (2, false);
-                               ParseChar ('}');
+                               if (i != 7) {
+                                       ParseChar(',');
+                               }
+
                        }       
                        ParseChar ('}');
+                       ParseChar ('}');
        
                        return new Guid (a,b,c,d);                      
                        
index 324c6aa948cf925bd9ff906a985fa21e72fb5787..5d9eb2f08ffb2a2df7a079264ae1dd88820ebc39 100644 (file)
@@ -1,3 +1,6 @@
+2002-02-21  Duco Fijma <duco@lorentz.xs4all.nl>
+       * GuidTest.cs: changed according to fix in System.Guid
+
 2002-02-20  Nick Drochak  <ndrochak@gol.com>\r
 \r
        * Int64Test.cs: One array was giving us trouble.  Not sure why, but\r
index c68db2e04f234e2b1000a88a5772a6786e8e5524..4de1aac7392ecfdce044c55dee31e05eb5e08304 100755 (executable)
@@ -29,10 +29,10 @@ public class GuidTest : TestCase
                bool exception;
                
                if (BitConverter.IsLittleEndian) {
-                       AssertEquals("A1", g.ToString(), "03020100-0504-0706-0809-0a0b0c0d0e0f");
+                       AssertEquals("A1", "03020100-0504-0706-0809-0a0b0c0d0e0f", g.ToString());
                }
                else {
-                       AssertEquals("A1", g.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f");
+                       AssertEquals("A1", "00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString());
                }
 
                try {
@@ -42,7 +42,7 @@ public class GuidTest : TestCase
                catch (ArgumentNullException) {
                        exception = true;
                }
-               AssertEquals("A2", exception, true);
+               AssertEquals("A2", true, exception);
 
                try {
                        Guid g1 = new Guid(new byte[] {0x00, 0x01, 0x02});
@@ -51,21 +51,21 @@ public class GuidTest : TestCase
                catch (ArgumentException) {
                        exception = true;
                }
-               AssertEquals("A3", exception, true);
+               AssertEquals("A3", true, exception);
        }
 
        public void TestCtor2() {
                Guid g1 = new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0f"); 
                Guid g2 = new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}"); 
-               Guid g3 = new Guid ("{0x00010203,0x0405,0x0607,{0x08},{0x09},{0x0a},{0x0b},{0x0c},{0x0d},{0x0e},{0x0f}}");
+               Guid g3 = new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}");
                Guid g4;
                Guid g5;
 
                bool exception;
 
-               AssertEquals("A1", g1.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f"); 
-               AssertEquals("A2", g2.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f"); 
-               AssertEquals("A3", g3.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f"); 
+               AssertEquals("A1", "00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString()); 
+               AssertEquals("A2", "00010203-0405-0607-0809-0a0b0c0d0e0f", g2.ToString()); 
+               AssertEquals("A3", "00010203-0405-0607-0809-0a0b0c0d0e0f", g3.ToString()); 
 
                try {
                        g4 = new Guid((string) null);
@@ -74,7 +74,7 @@ public class GuidTest : TestCase
                catch (ArgumentNullException) {
                        exception = true;
                }
-               AssertEquals("A4", exception, true);
+               AssertEquals("A4", true, exception);
 
                try {
                        g5 = new Guid("invalid");
@@ -83,7 +83,7 @@ public class GuidTest : TestCase
                catch (FormatException) {
                        exception = true;
                }
-               AssertEquals("A5", exception, true);
+               AssertEquals("A5", true, exception);
                
        }
 
@@ -91,8 +91,8 @@ public class GuidTest : TestCase
                Guid g1 = new Guid(0x00010203, (short) 0x0405, (short) 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
                Guid g2 = new Guid(unchecked((int) 0xffffffff), unchecked((short) 0xffff), unchecked((short) 0xffff), 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
                
-               AssertEquals("A1", g1.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f");
-               AssertEquals("A2", g2.ToString(), "ffffffff-ffff-ffff-ffff-ffffffffffff");
+               AssertEquals("A1", "00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString());
+               AssertEquals("A2", "ffffffff-ffff-ffff-ffff-ffffffffffff", g2.ToString());
 
        }
 
@@ -100,13 +100,13 @@ public class GuidTest : TestCase
                Guid g1 = new Guid(0x00010203u, (ushort) 0x0405u, (ushort) 0x0607u, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
                Guid g2 = new Guid(0xffffffffu, (ushort) 0xffffu, (ushort) 0xffffu, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
                
-               AssertEquals("A1", g1.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f");
-               AssertEquals("A2", g2.ToString(), "ffffffff-ffff-ffff-ffff-ffffffffffff");
+               AssertEquals("A1", "00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString());
+               AssertEquals("A2", "ffffffff-ffff-ffff-ffff-ffffffffffff", g2.ToString());
 
        }
 
        public void TestEmpty() {
-               AssertEquals("A1", Guid.Empty.ToString(), "00000000-0000-0000-0000-000000000000");
+               AssertEquals("A1", "00000000-0000-0000-0000-000000000000", Guid.Empty.ToString());
        }
 
        public void TestEquals() {
@@ -115,24 +115,24 @@ public class GuidTest : TestCase
                Guid g3 = new Guid(0x11223344, 0x5566, 0x6677, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
                string s = "Thus is not a Guid!";
 
-               AssertEquals("A1", g1.Equals(g1), true);
-               AssertEquals("A2", g1.Equals(g2), true);
-               AssertEquals("A3", g1.Equals(g3), false);
-               AssertEquals("A4", g1.Equals(null), false);
-               AssertEquals("A5", g1.Equals(s), false);
+               AssertEquals("A1", true, g1.Equals(g1));
+               AssertEquals("A2", true, g1.Equals(g2));
+               AssertEquals("A3", false, g1.Equals(g3));
+               AssertEquals("A4", false, g1.Equals(null));
+               AssertEquals("A5", false, g1.Equals(s));
        }
 
        public void TestToString() {
                Guid g = new Guid(0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
                bool exception;
                
-               AssertEquals("A1", g.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f");
-               AssertEquals("A2", g.ToString("N"), "000102030405060708090a0b0c0d0e0f");
-               AssertEquals("A3", g.ToString("D"), "00010203-0405-0607-0809-0a0b0c0d0e0f");
-               AssertEquals("A4", g.ToString("B"), "{00010203-0405-0607-0809-0a0b0c0d0e0f}");
-               AssertEquals("A5", g.ToString("P"), "(00010203-0405-0607-0809-0a0b0c0d0e0f)");
-               AssertEquals("A6", g.ToString(""), "000102030405060708090a0b0c0d0e0f");
-               AssertEquals("A7", g.ToString(null), "000102030405060708090a0b0c0d0e0f");
+               AssertEquals("A1", "00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString() );
+               AssertEquals("A2", "000102030405060708090a0b0c0d0e0f", g.ToString("N") );
+               AssertEquals("A3", "00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString("D") );
+               AssertEquals("A4", "{00010203-0405-0607-0809-0a0b0c0d0e0f}", g.ToString("B") );
+               AssertEquals("A5", "(00010203-0405-0607-0809-0a0b0c0d0e0f)", g.ToString("P") );
+               AssertEquals("A6", "000102030405060708090a0b0c0d0e0f", g.ToString("") );
+               AssertEquals("A7", "000102030405060708090a0b0c0d0e0f", g.ToString((string)null));
 
                try {
                        g.ToString("X");
@@ -141,7 +141,7 @@ public class GuidTest : TestCase
                catch ( FormatException ) {
                        exception = true;
                }
-               AssertEquals("A8", exception, true);
+               AssertEquals("A8", true, exception);
 
                try {
                        g.ToString("This is invalid");
@@ -150,9 +150,9 @@ public class GuidTest : TestCase
                catch ( FormatException ) {
                        exception = true;
                }
-               AssertEquals("A9", exception, true);
+               AssertEquals("A9", true, exception);
 
-               AssertEquals("A10", g.ToString("B", null), "{00010203-0405-0607-0809-0a0b0c0d0e0f}");
+               AssertEquals("A10", "{00010203-0405-0607-0809-0a0b0c0d0e0f}", g.ToString("B", null));
 
                
        }