2010-07-23 Veerapuram Varadhan <[email protected]>

** Fixes #565616 - Based on Patch by Hubert FONGARNAND
	* DataContainer.cs (GetContainerData): If typecode is string,
	call Convert.ToString() irrespective of whether value is
	IConvertible or not.
This commit is contained in:
Veerapuram Varadhan committed 2010-07-23 18:55:50 +05:30
1 parent ef8bb0b9b4
commit 2ec0a00139
4 files changed
+30 -3

No files matched your search

@@ -1,3 +1,10 @@
2010-07-23 Veerapuram Varadhan <[email protected]>
** Fixes #565616 - Based on Patch by Hubert FONGARNAND
* DataContainer.cs (GetContainerData): If typecode is string,
call Convert.ToString() irrespective of whether value is
IConvertible or not.
2010-03-26 Veerapuram Varadhan <[email protected]>
** Fixes #564833/580736
@@ -157,19 +157,20 @@ namespace System.Data.Common
internal object GetContainerData (object value)
{
object obj;
TypeCode tc;
if (_type.IsInstanceOfType (value)) {
return value;
} else if ((tc = Type.GetTypeCode (_type)) == TypeCode.String) {
return (Convert.ToString (value));
} else if (value is IConvertible) {
switch (Type.GetTypeCode(_type)) {
switch (tc) {
case TypeCode.Int16:
return (Convert.ToInt16 (value));
case TypeCode.Int32:
return (Convert.ToInt32 (value));
case TypeCode.Int64:
return (Convert.ToInt64 (value));
case TypeCode.String:
return (Convert.ToString (value));
case TypeCode.Boolean:
return (Convert.ToBoolean (value));
case TypeCode.Byte:
@@ -1,3 +1,7 @@
2010-07-23 Veerapuram Varadhan <[email protected]>
* DataColumnTest.cs (B565616_NonIConvertibleTypeTest): Added new.
2010-01-21 Jonathan Pobst <[email protected]>
* DataTableTest2.cs: Mark PrimaryKey test as NotWorking.
@@ -872,5 +872,20 @@ namespace MonoTests.System.Data
Assert.AreEqual (-1, col2.Ordinal, "#D1");
Assert.IsNull (col2.Table, "#D2");
}
[Test]
public void B565616_NonIConvertibleTypeTest ()
{
try {
DataTable dt = new DataTable ();
Guid id = Guid.NewGuid();
dt.Columns.Add ("ID", typeof(string));
DataRow row = dt.NewRow ();
row["ID"]= id;
Assert.AreEqual (id.ToString(), row["ID"], "#N1");
} catch (InvalidCastException ex) {
Assert.Fail ("#NonIConvertibleType Test");
}
}
}
}