From: Date: January 9 2008 10:12pm Subject: Connector/NET commit: r1144 - in branches/5.1: Driver Driver/Source Driver/Source/Types Driver/Source/common TestSuite/Source List-Archive: http://lists.mysql.com/commits/40800 X-Bug: 33508 Message-Id: <200801092112.m09LCcpK030200@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/5.1/Driver/MySql.Data.CF.csproj branches/5.1/Driver/MySql.Data.csproj branches/5.1/Driver/Source/NativeDriver.cs branches/5.1/Driver/Source/Types/MySqlDateTime.cs branches/5.1/Driver/Source/command.cs branches/5.1/Driver/Source/common/SharedMemoryStream.cs branches/5.1/Driver/Source/parameter.cs branches/5.1/TestSuite/Source/AsyncTests.cs branches/5.1/TestSuite/Source/BlobTests.cs branches/5.1/TestSuite/Source/CommandBuilderTests.cs branches/5.1/TestSuite/Source/CommandTests.cs branches/5.1/TestSuite/Source/ConnectionStringBuilder.cs branches/5.1/TestSuite/Source/ConnectionTests.cs branches/5.1/TestSuite/Source/DataAdapterTests.cs Log: many more cleanups and fixes for mono compilation. This is part of the work done to handle bug #33508 Modified: branches/5.1/Driver/MySql.Data.CF.csproj =================================================================== --- branches/5.1/Driver/MySql.Data.CF.csproj 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/MySql.Data.CF.csproj 2008-01-09 21:12:37 UTC (rev 1144) @@ -56,6 +56,9 @@ + + + Component @@ -63,18 +66,15 @@ Component - - - Component Modified: branches/5.1/Driver/MySql.Data.csproj =================================================================== --- branches/5.1/Driver/MySql.Data.csproj 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/MySql.Data.csproj 2008-01-09 21:12:37 UTC (rev 1144) @@ -134,7 +134,6 @@ - Component Modified: branches/5.1/Driver/Source/NativeDriver.cs =================================================================== --- branches/5.1/Driver/Source/NativeDriver.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/Source/NativeDriver.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -304,7 +304,7 @@ } } - private static bool ServerCheckValidation(object sender, X509Certificate certificate, +/* private static bool ServerCheckValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) @@ -313,7 +313,7 @@ // Do not allow this client to communicate with unauthenticated servers. return false; } - + */ private static bool NoServerCheckValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { Modified: branches/5.1/Driver/Source/Types/MySqlDateTime.cs =================================================================== --- branches/5.1/Driver/Source/Types/MySqlDateTime.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/Source/Types/MySqlDateTime.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -481,14 +481,6 @@ return val.GetDateTime(); } - private void ComputeTicks() - { - int[] daysInMonths = new int[12] { 31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30 }; - - if (DateTime.IsLeapYear(Year)) - daysInMonths[1]++; - } - internal static void SetDSInfo(DataTable dsTable) { string[] types = new string[] { "DATE", "DATETIME", "TIMESTAMP" }; Modified: branches/5.1/Driver/Source/command.cs =================================================================== --- branches/5.1/Driver/Source/command.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/Source/command.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -46,7 +46,6 @@ long updatedRowCount; UpdateRowSource updatedRowSource; MySqlParameterCollection parameters; - private ArrayList parameterMap; private int cursorPageSize; private IAsyncResult asyncResult; private bool designTimeVisible; @@ -62,7 +61,6 @@ { designTimeVisible = true; cmdType = CommandType.Text; - parameterMap = new ArrayList(); parameters = new MySqlParameterCollection(this); updatedRowSource = UpdateRowSource.Both; cursorPageSize = 0; Modified: branches/5.1/Driver/Source/common/SharedMemoryStream.cs =================================================================== --- branches/5.1/Driver/Source/common/SharedMemoryStream.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/Source/common/SharedMemoryStream.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -74,7 +74,7 @@ AutoResetEvent connectRequest = new AutoResetEvent(false); IntPtr handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE, false, memoryName + "_" + "CONNECT_REQUEST"); -#if NET20 && !MONO +#if NET20 connectRequest.SafeWaitHandle = new SafeWaitHandle(handle, true); #else connectRequest.Handle = handle; @@ -83,7 +83,7 @@ AutoResetEvent connectAnswer = new AutoResetEvent(false); handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE, false, memoryName + "_" + "CONNECT_ANSWER"); -#if NET20 && !MONO +#if NET20 connectAnswer.SafeWaitHandle = new SafeWaitHandle(handle, true); #else connectAnswer.Handle = handle; @@ -115,7 +115,7 @@ IntPtr handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE, false, dataMemoryName + "_SERVER_WROTE"); Debug.Assert(handle != IntPtr.Zero); -#if NET20 && !MONO +#if NET20 serverWrote.SafeWaitHandle = new SafeWaitHandle(handle, true); #else serverWrote.Handle = handle; @@ -125,7 +125,7 @@ handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE, false, dataMemoryName + "_SERVER_READ"); Debug.Assert(handle != IntPtr.Zero); -#if NET20 && !MONO +#if NET20 serverRead.SafeWaitHandle = new SafeWaitHandle(handle, true); #else serverRead.Handle = handle; @@ -135,7 +135,7 @@ handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE, false, dataMemoryName + "_CLIENT_WROTE"); Debug.Assert(handle != IntPtr.Zero); -#if NET20 && !MONO +#if NET20 clientWrote.SafeWaitHandle = new SafeWaitHandle(handle, true); #else clientWrote.Handle = handle; @@ -145,7 +145,7 @@ handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE, false, dataMemoryName + "_CLIENT_READ"); Debug.Assert(handle != IntPtr.Zero); -#if NET20 && !MONO +#if NET20 clientRead.SafeWaitHandle = new SafeWaitHandle(handle, true); #else clientRead.Handle = handle; Modified: branches/5.1/Driver/Source/parameter.cs =================================================================== --- branches/5.1/Driver/Source/parameter.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/Driver/Source/parameter.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -35,7 +35,7 @@ /// Represents a parameter to a , and optionally, its mapping to columns. This class cannot be inherited. /// #if !CF - [TypeConverter(typeof (MySqlParameterConverter))] + [TypeConverter(typeof(MySqlParameterConverter))] #endif public sealed class MySqlParameter : DbParameter, IDataParameter, IDbDataParameter, ICloneable { @@ -587,64 +587,65 @@ #endregion + /// + /// Resets the DbType property to its original settings. + /// + public override void ResetDbType() + { + inferType = true; + } + + /// + /// Sets or gets a value which indicates whether the source column is nullable. + /// This allows to correctly generate Update statements + /// for nullable columns. + /// + public override bool SourceColumnNullMapping + { + get { return sourceColumnNullMapping; } + set { sourceColumnNullMapping = value; } + } + } + #if !CF - internal class MySqlParameterConverter : TypeConverter + internal class MySqlParameterConverter : TypeConverter + { + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + if (destinationType == typeof(InstanceDescriptor)) { - if (destinationType == typeof (InstanceDescriptor)) - { - return true; - } - - // Always call the base to see if it can perform the conversion. - return base.CanConvertTo(context, destinationType); + return true; } - public override object ConvertTo(ITypeDescriptorContext context, - CultureInfo culture, object value, Type destinationType) + // Always call the base to see if it can perform the conversion. + return base.CanConvertTo(context, destinationType); + } + + public override object ConvertTo(ITypeDescriptorContext context, + CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(InstanceDescriptor)) { - if (destinationType == typeof (InstanceDescriptor)) - { - ConstructorInfo ci = typeof (MySqlParameter).GetConstructor( - new Type[] + ConstructorInfo ci = typeof(MySqlParameter).GetConstructor( + new Type[] { typeof (string), typeof (MySqlDbType), typeof (int), typeof (ParameterDirection), typeof (bool), typeof (byte), typeof (byte), typeof (string), typeof (DataRowVersion), typeof (object) }); - MySqlParameter p = (MySqlParameter) value; - return new InstanceDescriptor(ci, new object[] + MySqlParameter p = (MySqlParameter)value; + return new InstanceDescriptor(ci, new object[] { p.ParameterName, p.DbType, p.Size, p.Direction, p.IsNullable, p.Precision, p.Scale, p.SourceColumn, p.SourceVersion, p.Value }); - } + } - // Always call base, even if you can't convert. - return base.ConvertTo(context, culture, value, destinationType); - } + // Always call base, even if you can't convert. + return base.ConvertTo(context, culture, value, destinationType); } + } #endif - /// - /// Resets the DbType property to its original settings. - /// - public override void ResetDbType() - { - inferType = true; - } - - /// - /// Sets or gets a value which indicates whether the source column is nullable. - /// This allows to correctly generate Update statements - /// for nullable columns. - /// - public override bool SourceColumnNullMapping - { - get { return sourceColumnNullMapping; } - set { sourceColumnNullMapping = value; } - } - } } \ No newline at end of file Modified: branches/5.1/TestSuite/Source/AsyncTests.cs =================================================================== --- branches/5.1/TestSuite/Source/AsyncTests.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/AsyncTests.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -49,7 +49,7 @@ count++; System.Threading.Thread.Sleep(20); } - int updated = proc.EndExecuteNonQuery(iar); + proc.EndExecuteNonQuery(iar); Assert.IsTrue(count > 0); proc.CommandType = CommandType.Text; Modified: branches/5.1/TestSuite/Source/BlobTests.cs =================================================================== --- branches/5.1/TestSuite/Source/BlobTests.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/BlobTests.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -277,6 +277,7 @@ dt.Clear(); da.Fill(dt); + cb.Dispose(); byte[] outBuf = (byte[])dt.Rows[0]["blob1"]; Assert.AreEqual(inBuf.Length, outBuf.Length, Modified: branches/5.1/TestSuite/Source/CommandBuilderTests.cs =================================================================== --- branches/5.1/TestSuite/Source/CommandBuilderTests.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/CommandBuilderTests.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -59,6 +59,7 @@ dt.Rows[0]["multi word"] = 3; da.Update(dt); + cb.Dispose(); Assert.AreEqual(1, dt.Rows.Count); Assert.AreEqual(3, dt.Rows[0]["multi word"]); } @@ -188,6 +189,7 @@ da.Update(changes); ds.Merge(changes); ds.AcceptChanges(); + cb.Dispose(); conn.ChangeDatabase(database0); } @@ -239,6 +241,7 @@ dt.Clear(); da.Fill(dt); + cb.Dispose(); Assert.AreEqual(1, dt.Rows.Count); Assert.AreEqual(2, dt.Rows[0]["id"]); } @@ -283,6 +286,7 @@ Assert.AreEqual(1, dt.Rows.Count); Assert.AreEqual(1, dt.Rows[0]["id"]); Assert.AreEqual("Test", dt.Rows[0]["name"]); + cb.Dispose(); } /// @@ -374,6 +378,7 @@ changes = dt.GetChanges(); da.Update(changes); dt.AcceptChanges(); + cb.Dispose(); } catch (Exception ex) { Modified: branches/5.1/TestSuite/Source/CommandTests.cs =================================================================== --- branches/5.1/TestSuite/Source/CommandTests.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/CommandTests.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -356,7 +356,7 @@ MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn); try { - object o = cmd.ExecuteScalar(); + cmd.ExecuteScalar(); } catch (Exception) { @@ -364,7 +364,7 @@ try { - IDbTransaction trans = conn.BeginTransaction(); + conn.BeginTransaction(); } catch (Exception ex) { Modified: branches/5.1/TestSuite/Source/ConnectionStringBuilder.cs =================================================================== --- branches/5.1/TestSuite/Source/ConnectionStringBuilder.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/ConnectionStringBuilder.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -51,7 +51,6 @@ Assert.IsTrue(sb.Pooling); Assert.AreEqual(33, sb.MinimumPoolSize); Assert.AreEqual(66, sb.MaximumPoolSize); - string s = sb.ConnectionString; try { Modified: branches/5.1/TestSuite/Source/ConnectionTests.cs =================================================================== --- branches/5.1/TestSuite/Source/ConnectionTests.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/ConnectionTests.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -184,8 +184,6 @@ { try { - string connStr = conn.ConnectionString; - // connect with no db string connStr2 = GetConnectionString(false); MySqlConnection c = new MySqlConnection(connStr2); Modified: branches/5.1/TestSuite/Source/DataAdapterTests.cs =================================================================== --- branches/5.1/TestSuite/Source/DataAdapterTests.cs 2008-01-09 20:43:33 UTC (rev 1143) +++ branches/5.1/TestSuite/Source/DataAdapterTests.cs 2008-01-09 21:12:37 UTC (rev 1144) @@ -125,6 +125,7 @@ dt.Rows.Clear(); da.Fill(dt); Assert.AreEqual(0, dt.Rows.Count, "checking row count"); + cb.Dispose(); } [Test] @@ -374,6 +375,7 @@ da.Fill(ds); Assert.AreEqual(1, ds.Tables[0].Rows[0]["id"]); Assert.AreEqual(2, ds.Tables[0].Rows[1]["id"]); + cb.Dispose(); } /// @@ -555,6 +557,7 @@ da.Fill(dt); Assert.IsTrue(c.State == ConnectionState.Open); Assert.AreEqual(1, dt.Rows.Count); + cb.Dispose(); } catch (Exception ex) { @@ -641,6 +644,7 @@ Assert.AreEqual(3, dt.Rows.Count); Assert.AreEqual(3, dt.Rows[2]["id"]); Assert.AreEqual("Test3", dt.Rows[2]["name"]); + cb.Dispose(); } [Test] @@ -660,7 +664,7 @@ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); DataTable dt = new DataTable(); - da.Fill(0, 10, dt); + da.Fill(0, 10, new DataTable[] { dt }); Assert.AreEqual(10, dt.Rows.Count); } @@ -692,7 +696,7 @@ { MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); DataTable dt = new DataTable(); - da.Fill(0, 2, dt); + da.Fill(0, 2, new DataTable[] { dt }); } catch (Exception ex) {