From c10207ae54574512821f8f2ebf160ebb3d0b0ddb Mon Sep 17 00:00:00 2001 From: Lawrence LCI <31262254+lcheunglci@users.noreply.github.com> Date: Mon, 18 Oct 2021 12:45:23 -0700 Subject: [PATCH] Move into Shared for SqlInfoMessageEvent.cs (#1311) --- .../src/Microsoft.Data.SqlClient.csproj | 4 +- .../Data/SqlClient/SqlInfoMessageEvent.cs | 46 ------------------ .../netfx/src/Microsoft.Data.SqlClient.csproj | 4 +- .../Data/SqlClient/SqlInfoMessageEvent.cs | 47 ------------------- .../Data/SqlClient/SqlInfoMessageEvent.cs | 34 ++++++++++++++ 5 files changed, 40 insertions(+), 95 deletions(-) delete mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs delete mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs create mode 100644 src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index a45ed7c82b..b7a72a6d64 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -280,6 +280,9 @@ Microsoft\Data\SqlClient\SqlException.cs + + Microsoft\Data\SqlClient\SqlInfoMessageEvent.cs + Microsoft\Data\SqlClient\SqlInfoMessageEventHandler.cs @@ -566,7 +569,6 @@ Microsoft\Data\SqlClient\SqlEnclaveSession.cs - diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs deleted file mode 100644 index f508331743..0000000000 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Data.SqlClient -{ - /// - public sealed class SqlInfoMessageEventArgs : System.EventArgs - { - private SqlException _exception; - - internal SqlInfoMessageEventArgs(SqlException exception) - { - _exception = exception; - } - - /// - public SqlErrorCollection Errors - { - get { return _exception.Errors; } - } - - private bool ShouldSerializeErrors() - { - return (null != _exception) && (0 < _exception.Errors.Count); - } - - /// - public string Message - { - get { return _exception.Message; } - } - - /// - public string Source - { - get { return _exception.Source; } - } - - /// - override public string ToString() - { - return Message; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index 81d1011081..1cc25bdf54 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -369,6 +369,9 @@ Microsoft\Data\SqlClient\SqlException.cs + + Microsoft\Data\SqlClient\SqlInfoMessageEvent.cs + Microsoft\Data\SqlClient\SqlInfoMessageEventHandler.cs @@ -555,7 +558,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs deleted file mode 100644 index d191d6d2af..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Data.SqlClient -{ - /// - public sealed class SqlInfoMessageEventArgs : System.EventArgs - { - private SqlException exception; - - internal SqlInfoMessageEventArgs(SqlException exception) - { - this.exception = exception; - } - - /// - public SqlErrorCollection Errors - { - get { return exception.Errors; } - } - - /*virtual protected*/ - private bool ShouldSerializeErrors() - { // MDAC 65548 - return (null != exception) && (0 < exception.Errors.Count); - } - - /// - public string Message - { // MDAC 68482 - get { return exception.Message; } - } - - /// - public string Source - { // MDAC 68482 - get { return exception.Source; } - } - - /// - override public string ToString() - { // MDAC 68482 - return Message; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs new file mode 100644 index 0000000000..bca1f3d65f --- /dev/null +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Microsoft.Data.SqlClient +{ + /// + public sealed class SqlInfoMessageEventArgs : System.EventArgs + { + private readonly SqlException _exception; + + internal SqlInfoMessageEventArgs(SqlException exception) + { + _exception = exception; + } + + /// + public SqlErrorCollection Errors => _exception.Errors; + + // MDAC 65548 + private bool ShouldSerializeErrors() => (null != _exception) && (0 < _exception.Errors.Count); + + /// + public string Message => _exception.Message; + + /// + // MDAC 68482 + public string Source => _exception.Source; + + /// + // MDAC 68482 + override public string ToString() => Message; + } +}