[Mono-list] Patch for fixing Bug 25075 and running NUnit on Linux
Duncan Mak
duncan@ximian.com
21 May 2002 22:09:25 -0400
--=-4idOAVkrR4ih9wMBcdjp
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Guys,
I think this fixes bug 25075. At least it works with his test case,
however, I don't wanna check this in immediately since this might break
all type conversion stuff (eek). Could someone look this over and tell
me whether or not this is safe?
BTW, I tried running the NUnit tests on Linux, this is what I get:
<duncan@diphthong: ~/Mono/install/bin/ > mono ./NUnitConsole_mono.exe
MonoTests.AllTests,corlib_linux_test.dll
.........................................
.........................................
...........................E.E.E.E.E.E.E.E.E.E.E.E.E.E.
E.E.E.E.E.E.E.E..F................................
...F.......F.F......F.F.........F..............
......................F...................
............F..........F..............F.....
...............F...................F.......
.........................................
.....Needed to allocate blacklisted block at 0xb6d4000
Needed to allocate blacklisted block at 0xb798000
Needed to allocate blacklisted block at 0xb7f5000
.................E..............F.....
.........................................
..........E.E...F.F.............E.E.E.E.......E...
................E.E.E.E.E.E...............E.E.E.E.E.
E.E.E.E.E.E.F..F.
Time: 16.713
There were 47 errors:
Could not create and run test suite.
<duncan@diphthong: ~/Mono/install/bin/ >
Is this to be expected?
thanks,
Duncan.
--=-4idOAVkrR4ih9wMBcdjp
Content-Disposition: attachment; filename=ConvertTypeCode.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=ConvertTypeCode.patch; charset=ISO-8859-1
Index: Convert.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/Convert.cs,v
retrieving revision 1.24
diff -u -r1.24 Convert.cs
--- Convert.cs 21 May 2002 20:57:33 -0000 1.24
+++ Convert.cs 21 May 2002 22:19:28 -0000
@@ -2299,24 +2299,24 @@
// type, and uses hardcoded array indexes.=0D
private static Type[] conversionTable =3D {=0D
// Valid ICovnertible Types=0D
- typeof (Boolean), // 0 TypeCode.Boolean=0D
- typeof (Byte), // 1 TypeCode.Byte=0D
- typeof (Char), // 2 TypeCode.Char=0D
- typeof (DateTime), // 3 TypeCode.DateTime=0D
- typeof (Decimal), // 4 TypeCode.Decimal=0D
- typeof (Double), // 5 TypeCode.Double=0D
- typeof (Int16), // 6 TypeCode.Int16=0D
- typeof (Int32), // 7 TypeCode.Int32=0D
- typeof (Int64), // 8 TypeCode.Int64=0D
- typeof (SByte), // 9 TypeCode.Sbyte=0D
- typeof (Single), // 10 TypeCode.Single=0D
- typeof (String), // 11 TypeCode.String=0D
- typeof (UInt16), // 12 TypeCode.UInt16=0D
- typeof (UInt32), // 13 TypeCode.UInt32=0D
- typeof (UInt64), // 14 TypeCode.UInt64=0D
- =20=0D
- // Invalid IConvertible Interface Types=0D
- typeof (Object) // 15 TypeCode.Object=0D
+ null, // 0 empty=0D
+ typeof (object), // 1 TypeCode.Object=0D
+ typeof (DBNull), // 2 TypeCode.DBNull=0D
+ typeof (Boolean), // 3 TypeCode.Boolean=0D
+ typeof (Char), // 4 TypeCode.Char=0D
+ typeof (SByte), // 5 TypeCode.SByte=0D
+ typeof (Byte), // 6 TypeCode.Byte=0D
+ typeof (Int16), // 7 TypeCode.Int16=0D
+ typeof (UInt16), // 8 TypeCode.UInt16=0D
+ typeof (Int32), // 9 TypeCode.Int32=0D
+ typeof (UInt32), // 10 TypeCode.UInt32=0D
+ typeof (Int64), // 11 TypeCode.Int64=0D
+ typeof (UInt64), // 12 TypeCode.UInt64=0D
+ typeof (Single), // 13 TypeCode.Single=0D
+ typeof (Double), // 14 TypeCode.Double=0D
+ typeof (Decimal), // 15 TypeCode.Decimal=0D
+ typeof (DateTime), // 16 TypeCode.DateTime=0D
+ typeof (String), // 18 TypeCode.String=0D
};=0D
=20=0D
// Function to convert an object to another type and return=0D
@@ -2331,86 +2331,67 @@
"Invalid conversion from null value"));=0D
=20=0D
if (value is IConvertible) {=0D
- IConvertible convertValue =3D (IConvertible)value;=0D
+ IConvertible convertValue =3D (IConvertible) value;=0D
=20=0D
- if (conversionType =3D=3D conversionTable[0]) {=0D
- // 0 TypeCode.Boolean=0D
- return (object)(convertValue.ToBoolean (provider));=0D
-=0D
- } else if (conversionType =3D=3D conversionTable[1]) {=0D
- // 1 TypeCode.Byte=0D
- return (object)(convertValue.ToByte (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[2]) {=0D
- // 2 TypeCode.Char=0D
- return (object)(convertValue.ToChar (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[3]) {=0D
- // 3 TypeCode.DateTime=0D
- return (object)(convertValue.ToDateTime (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[4]) {=0D
- // 4 TypeCode.Decimal=0D
- return (object)(convertValue.ToDecimal (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[5]) {=0D
- // 5 TypeCode.Double=0D
- return (object)(convertValue.ToDouble (provider));=0D
-=0D
- } else if (conversionType =3D=3D conversionTable[6]) {=0D
- // 6 TypeCode.Int16=0D
- return (object)(convertValue.ToInt16 (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[7]) {=0D
- // 7 TypeCode.Int32=0D
- return (object)(convertValue.ToInt32 (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[8]) {=0D
- // 8 TypeCode.Int64=0D
- return (object)(convertValue.ToInt64 (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[9]) {=0D
- // 9 TypeCode.Sbyte=0D
- return (object)(convertValue.ToSByte (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[10]) {=0D
- // 10 TypeCode.Single=0D
- return (object)(convertValue.ToSingle (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[11]) {=0D
- // 11 TypeCode.String=0D
- return (object)(convertValue.ToString (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[12]) { =20=0D
- // 12 TypeCode.UInt16=0D
- return (object)(convertValue.ToUInt16 (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[13]) {=0D
- // 13 TypeCode.UInt32=0D
- return (object)(convertValue.ToUInt32 (provider));=0D
- =20=0D
- } else if (conversionType =3D=3D conversionTable[14]) {=0D
- // 14 TypeCode.UInt64=0D
- return (object)(convertValue.ToUInt64 (provider));=0D
-=0D
- } else if (conversionType =3D=3D conversionTable[15]) {=0D
- // 15 TypeCode.Object=0D
- return (object)(value);=0D
-=0D
- } else { =09=0D
- // Not in the conversion table=0D
- throw new InvalidCastException (Locale.GetText (=0D
- "Unknown target conversion type"));=0D
- }=0D
- } else {=0D
- // Value is not IConvertible=0D
- throw new ArgumentException (Locale.GetText (=0D
- "Value is not a convertible object: "+ value.GetType().ToString()+" t=
o "+conversionType.ToString()));=0D
- }=0D
+ if (conversionType =3D=3D conversionTable[0]) // 0 Empty=0D
+ return null;=0D
+ =09=0D
+ else if (conversionType =3D=3D conversionTable[1]) // 1 TypeCode.Objec=
t=0D
+ return (object) value;=0D
+ =09=0D
+ // else if (conversionType =3D=3D conversionTable[2]) // 2 TypeCode.DB=
Null=0D
+ // return null; // It's not IConvertible=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[3]) // 3 TypeCode.Boole=
an=0D
+ return (object) convertValue.ToBoolean (provider);=0D
+ =09=0D
+ else if (conversionType =3D=3D conversionTable[4]) // 4 TypeCode.Char=0D
+ return (object) convertValue.ToChar (provider);=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[5]) // 5 TypeCode.SByte=0D
+ return (object) convertValue.ToSByte (provider);=0D
+=0D
+ else if (conversionType =3D=3D conversionTable[6]) // 6 TypeCode.Byte=0D
+ return (object) convertValue.ToByte (provider);=0D
+ =09=0D
+ else if (conversionType =3D=3D conversionTable[7]) // 7 TypeCode.Int16=0D
+ return (object) convertValue.ToInt16 (provider);=0D
+ =09=0D
+ else if (conversionType =3D=3D conversionTable[8]) // 8 TypeCode.UInt1=
6=0D
+ return (object) convertValue.ToUInt16 (provider);=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[9]) // 9 TypeCode.Int32=0D
+ return (object) convertValue.ToInt32 (provider);=0D
+ =09=0D
+ else if (conversionType =3D=3D conversionTable[10]) // 10 TypeCode.UIn=
t32=0D
+ return (object) convertValue.ToUInt32 (provider);=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[11]) // 11 TypeCode.Int=
64=0D
+ return (object) convertValue.ToInt64 (provider);=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[12]) // 12 TypeCode.UIn=
t64=0D
+ return (object) convertValue.ToUInt64 (provider);=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[13]) // 13 TypeCode.Sin=
gle=0D
+ return (object) convertValue.ToSingle (provider);=0D
+ =20=0D
+ else if (conversionType =3D=3D conversionTable[14]) // 14 TypeCode.Dou=
ble=0D
+ return (object) convertValue.ToDouble (provider);=0D
+=0D
+ else if (conversionType =3D=3D conversionTable[15]) // 15 TypeCode.Dec=
imal=0D
+ return (object) convertValue.ToDecimal (provider);=0D
+=0D
+ else if (conversionType =3D=3D conversionTable[16]) // 16 TypeCode.Dat=
eTime=0D
+ return (object) convertValue.ToDateTime (provider);=0D
+ =09=0D
+ else if (conversionType =3D=3D conversionTable[18]) // 18 TypeCode.Str=
ing=0D
+ return (object) convertValue.ToString (provider);=0D
+ else=0D
+ throw new InvalidCastException (Locale.GetText ("Unknown target conve=
rsion type"));=0D
+ } else=0D
+ // Not in the conversion table=0D
+ throw new ArgumentException ((Locale.GetText (=0D
+ "Value is not a convertible object: " + value.GetType().ToString() + =
" to " + conversionType.ToString())));=0D
}=0D
}=0D
}=0D
-=0D
-=0D
-=0D
-=0D
Index: ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/ChangeLog,v
retrieving revision 1.328
diff -u -r1.328 ChangeLog
--- ChangeLog 21 May 2002 20:57:33 -0000 1.328
+++ ChangeLog 21 May 2002 22:19:28 -0000
@@ -1,5 +1,15 @@
2002-05-21 Duncan Mak <duncan@ximian.com>
=20
+ * Convert.cs (ToType): Rearranged to fit the new layout of
+ conversionTable.
+
+ (conversionTable): Rearranged to fit the layout of the
+ System.TypeCode enum.
+
+ This should fix bug 25075.
+=09
+2002-05-21 Duncan Mak <duncan@ximian.com>
+
* Convert.cs (ToString): Fixed the ToString methods. Previously I had
mixed up the two code paths, one for converting to a specific base
(this case), another from converting from a foreign base to base10
--=-4idOAVkrR4ih9wMBcdjp--