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 797d433b2f..8c247c1ccd 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -243,6 +243,18 @@ Microsoft\Data\SqlClient\SignatureVerificationCache.cs + + Microsoft\Data\SqlClient\TdsValueSetter.cs + + + Microsoft\Data\SqlClient\TdsParameterSetter.cs + + + Microsoft\Data\SqlClient\TdsRecordBufferSetter.cs + + + Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs + @@ -284,7 +296,6 @@ - @@ -398,15 +409,12 @@ - - - Microsoft\Data\SQLTypes\SQLResource.cs 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 39a7e2b45c..6e6a8a2dff 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -295,6 +295,18 @@ Microsoft\Data\SqlClient\SignatureVerificationCache.cs + + Microsoft\Data\SqlClient\TdsValueSetter.cs + + + Microsoft\Data\SqlClient\TdsParameterSetter.cs + + + Microsoft\Data\SqlClient\TdsRecordBufferSetter.cs + + + Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs + @@ -380,15 +392,12 @@ - - - @@ -439,7 +448,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs deleted file mode 100644 index d9d19e6bfa..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs +++ /dev/null @@ -1,877 +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. - -using System; -using System.Data; -using System.Data.SqlTypes; - -namespace Microsoft.Data.SqlClient.Server -{ - - // Class for implementing a record object that could take advantage of the - // environment available to a particular protocol level (such as storing data - // in native structures for in-proc data access). Includes methods to send - // the record to a context pipe (useful for in-proc scenarios). - internal abstract class SmiRecordBuffer : SmiTypedGetterSetter, ITypedGettersV3, ITypedSettersV3, ITypedGetters, ITypedSetters, IDisposable - { - - #region SMI active methods as of V200 - - #region control methods - public virtual void Close( - SmiEventSink eventSink - ) - { - // Adding as of V3 - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V2- and hasn't implemented V3 yet. - // 2) Server didn't implement V3 on some interface, but negotiated V3+. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - #endregion - - #region Supported access method types (Get] vs. Set) - - // SmiRecordBuffer defaults both CanGet and CanSet to true to support - // already-shipped SMIV3 record buffer classes. Sub-classes are free to override. - internal override bool CanGet - { - get - { - return true; - } - } - - internal override bool CanSet - { - get - { - return true; - } - } - #endregion - - - - #region Value getters - - // SmiRecordBuffer subclasses that expose CanGet == true must implement all Getters from SmiTypedGetterSetter - // SmiRecordBuffer itself does not need to implement these, since it inherits the default implementation from - // SmiTypedGetterSetter - - #endregion - - #region Value setters - - // SmiRecordBuffer subclasses that expose CanSet == true must implement all Setters from SmiTypedGetterSetter - // SmiRecordBuffer itself does not need to implement these, since it inherits the default implementation from - // SmiTypedGetterSetter - - #endregion - - #endregion - - #region OBSOLETE STUFF than never shipped without obsolete attribute - - // - // IDisposable - // - public virtual void Dispose() - { - // ******** OBSOLETING from SMI -- use Close instead - // Intended to be removed (along with inheriting IDisposable) prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - // - // ITypedGetters methods - // - public virtual bool IsDBNull(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlDbType GetVariantType(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Boolean GetBoolean(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Byte GetByte(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual long GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Char GetChar(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual long GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Int16 GetInt16(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Int32 GetInt32(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Int64 GetInt64(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Single GetFloat(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Double GetDouble(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual String GetString(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Decimal GetDecimal(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual DateTime GetDateTime(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual Guid GetGuid(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlBoolean GetSqlBoolean(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlByte GetSqlByte(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlInt16 GetSqlInt16(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlInt32 GetSqlInt32(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlInt64 GetSqlInt64(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlSingle GetSqlSingle(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlDouble GetSqlDouble(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlMoney GetSqlMoney(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlDateTime GetSqlDateTime(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlDecimal GetSqlDecimal(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlString GetSqlString(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlBinary GetSqlBinary(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlGuid GetSqlGuid(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlChars GetSqlChars(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlBytes GetSqlBytes(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlXml GetSqlXml(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlXml GetSqlXmlRef(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlBytes GetSqlBytesRef(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual SqlChars GetSqlCharsRef(int ordinal) - { - // ******** OBSOLETING from SMI -- use corresponding ITypedGettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - // - // ITypedSetters methods - // - public virtual void SetDBNull(int ordinal) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetBoolean(int ordinal, Boolean value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetByte(int ordinal, Byte value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetChar(int ordinal, char value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetInt16(int ordinal, Int16 value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetInt32(int ordinal, Int32 value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetInt64(int ordinal, Int64 value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetFloat(int ordinal, Single value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetDouble(int ordinal, Double value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetString(int ordinal, string value) - { - // Implemented as empty virtual method to allow transport to remove it's implementation - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1. - // 2) Server didn't implement V1 on some interface and negotiated V1. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetString(int ordinal, string value, int offset) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetDecimal(int ordinal, Decimal value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetDateTime(int ordinal, DateTime value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetGuid(int ordinal, Guid value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlBoolean(int ordinal, SqlBoolean value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlByte(int ordinal, SqlByte value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlInt16(int ordinal, SqlInt16 value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlInt32(int ordinal, SqlInt32 value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlInt64(int ordinal, SqlInt64 value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlSingle(int ordinal, SqlSingle value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlDouble(int ordinal, SqlDouble value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlMoney(int ordinal, SqlMoney value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlDateTime(int ordinal, SqlDateTime value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlDecimal(int ordinal, SqlDecimal value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlString(int ordinal, SqlString value) - { - // Implemented as empty virtual method to allow transport to remove it's implementation - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1. - // 2) Server didn't implement V1 on some interface and negotiated V1. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlString(int ordinal, SqlString value, int offset) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlBinary(int ordinal, SqlBinary value) - { - // Implemented as empty virtual method to allow transport to remove it's implementation - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1. - // 2) Server didn't implement V1 on some interface and negotiated V1. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlBinary(int ordinal, SqlBinary value, int offset) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlGuid(int ordinal, SqlGuid value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlChars(int ordinal, SqlChars value) - { - // Implemented as empty virtual method to allow transport to remove it's implementation - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1. - // 2) Server didn't implement V1 on some interface and negotiated V1. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlChars(int ordinal, SqlChars value, int offset) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlBytes(int ordinal, SqlBytes value) - { - // Implemented as empty virtual method to allow transport to remove it's implementation - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V2 and dropped support for V1. - // 2) Server didn't implement V1 on some interface and negotiated V1. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlBytes(int ordinal, SqlBytes value, int offset) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - public virtual void SetSqlXml(int ordinal, SqlXml value) - { - // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead - // Intended to be removed prior to RTM. - - // Implement body with throw because there are only a couple of ways to get to this code: - // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-. - // 2) Server didn't implement V2- on some interface and negotiated V2-. - throw Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod); - } - - #endregion - } -} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs deleted file mode 100644 index 408e3baf85..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs +++ /dev/null @@ -1,68 +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. - -using System.Diagnostics; -using Microsoft.Data.SqlClient.Server; - -namespace Microsoft.Data.SqlClient -{ - // Simple Getter/Setter for structured parameters to allow using common ValueUtilsSmi code. - // This is a stand-in to having a true SmiRequestExecutor class for TDS. - internal class TdsParameterSetter : SmiTypedGetterSetter - { - - #region Private fields - - private TdsRecordBufferSetter _target; - - #endregion - - #region ctor & control - - internal TdsParameterSetter(TdsParserStateObject stateObj, SmiMetaData md) - { - _target = new TdsRecordBufferSetter(stateObj, md); - } - - #endregion - - #region TypedGetterSetter overrides - // Are calls to Get methods allowed? - internal override bool CanGet - { - get - { - return false; - } - } - - // Are calls to Set methods allowed? - internal override bool CanSet - { - get - { - return true; - } - } - - // valid for structured types - // This method called for both get and set. - internal override SmiTypedGetterSetter GetTypedGetterSetter(SmiEventSink sink, int ordinal) - { - Debug.Assert(0 == ordinal, "TdsParameterSetter only supports 0 for ordinal. Actual = " + ordinal); - return _target; - } - - // Set value to null - // valid for all types - public override void SetDBNull(SmiEventSink sink, int ordinal) - { - Debug.Assert(0 == ordinal, "TdsParameterSetter only supports 0 for ordinal. Actual = " + ordinal); - - _target.EndElements(sink); - } - - #endregion - } -} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs deleted file mode 100644 index 159c2f3981..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs +++ /dev/null @@ -1,311 +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. - -using System; -using System.Data; -using System.Data.SqlTypes; -using System.Diagnostics; -using Microsoft.Data.SqlClient.Server; - -namespace Microsoft.Data.SqlClient -{ - // TdsRecordBufferSetter handles writing a structured value out to a TDS stream - internal class TdsRecordBufferSetter : SmiRecordBuffer - { - #region Fields (private) - - private TdsValueSetter[] _fieldSetters; // setters for individual fields - - private TdsParserStateObject _stateObj; // target to write to - private SmiMetaData _metaData; // metadata describing value -#if DEBUG - private const int ReadyForToken = -1; // must call new/end element next - private const int EndElementsCalled = -2; // already called EndElements, can only call Close - private const int Closed = -3; // closed (zombied) - - private int _currentField; // validate that caller sets columns in correct order. -#endif - - #endregion - - #region Exposed Construct and control methods/properties - - internal TdsRecordBufferSetter(TdsParserStateObject stateObj, SmiMetaData md) - { - Debug.Assert(SqlDbType.Structured == md.SqlDbType, "Unsupported SqlDbType: " + md.SqlDbType); - _fieldSetters = new TdsValueSetter[md.FieldMetaData.Count]; - for (int i = 0; i < md.FieldMetaData.Count; i++) - { - _fieldSetters[i] = new TdsValueSetter(stateObj, md.FieldMetaData[i]); - } - _stateObj = stateObj; - _metaData = md; -#if DEBUG - _currentField = ReadyForToken; -#endif - } - - // TdsRecordBufferSetter supports Setting only - internal override bool CanGet - { - get - { - return false; - } - } - - internal override bool CanSet - { - get - { - return true; - } - } - - // Close method does nothing (value is sent to TDS), but we need to override to avoid throwing - // Also make sure protocol is followed (no calling setters after calling close). - public override void Close(SmiEventSink eventSink) - { -#if DEBUG - _currentField = Closed; -#endif - } - #endregion - - #region Setters - - // Set value to null - // valid for all types - public override void SetDBNull(SmiEventSink sink, int ordinal) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetDBNull(); - } - - // valid for SqlDbType.Bit - public override void SetBoolean(SmiEventSink sink, int ordinal, Boolean value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetBoolean(value); - } - - // valid for SqlDbType.TinyInt - public override void SetByte(SmiEventSink sink, int ordinal, Byte value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetByte(value); - } - - // Semantics for SetBytes are to modify existing value, not overwrite - // Use in combination with SetLength to ensure overwriting when necessary - // valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml - // (VarBinary assumed for variants) - public override int SetBytes(SmiEventSink sink, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length) - { - CheckWritingToColumn(ordinal); - return _fieldSetters[ordinal].SetBytes(fieldOffset, buffer, bufferOffset, length); - } - public override void SetBytesLength(SmiEventSink sink, int ordinal, long length) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetBytesLength(length); - } - - // Semantics for SetChars are to modify existing value, not overwrite - // Use in combination with SetLength to ensure overwriting when necessary - // valid for character types: Char, VarChar, Text, NChar, NVarChar, NText - // (NVarChar and global clr collation assumed for variants) - public override int SetChars(SmiEventSink sink, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length) - { - CheckWritingToColumn(ordinal); - return _fieldSetters[ordinal].SetChars(fieldOffset, buffer, bufferOffset, length); - } - - public override void SetCharsLength(SmiEventSink sink, int ordinal, long length) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetCharsLength(length); - } - - // valid for character types: Char, VarChar, Text, NChar, NVarChar, NText - public override void SetString(SmiEventSink sink, int ordinal, string value, int offset, int length) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetString(value, offset, length); - } - - // valid for SqlDbType.SmallInt - public override void SetInt16(SmiEventSink sink, int ordinal, Int16 value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetInt16(value); - } - - // valid for SqlDbType.Int - public override void SetInt32(SmiEventSink sink, int ordinal, Int32 value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetInt32(value); - } - - // valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney - public override void SetInt64(SmiEventSink sink, int ordinal, Int64 value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetInt64(value); - } - - // valid for SqlDbType.Real - public override void SetSingle(SmiEventSink sink, int ordinal, Single value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetSingle(value); - } - - // valid for SqlDbType.Float - public override void SetDouble(SmiEventSink sink, int ordinal, Double value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetDouble(value); - } - - // valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range) - public override void SetSqlDecimal(SmiEventSink sink, int ordinal, SqlDecimal value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetSqlDecimal(value); - } - - // valid for DateTime, SmallDateTime, Date, DateTime2 - public override void SetDateTime(SmiEventSink sink, int ordinal, DateTime value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetDateTime(value); - } - - // valid for UniqueIdentifier - public override void SetGuid(SmiEventSink sink, int ordinal, Guid value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetGuid(value); - } - - // valid for SqlDbType.Time - public override void SetTimeSpan(SmiEventSink sink, int ordinal, TimeSpan value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetTimeSpan(value); - } - - // valid for DateTimeOffset - public override void SetDateTimeOffset(SmiEventSink sink, int ordinal, DateTimeOffset value) - { - CheckSettingColumn(ordinal); - _fieldSetters[ordinal].SetDateTimeOffset(value); - } - - // valid for SqlDbType.Variant - public override void SetVariantMetaData(SmiEventSink sink, int ordinal, SmiMetaData metaData) - { - CheckWritingToColumn(ordinal); - _fieldSetters[ordinal].SetVariantType(metaData); - } - - // valid for multi-valued types - internal override void NewElement(SmiEventSink sink) - { -#if DEBUG - SkipPossibleDefaultedColumns(ReadyForToken); - Debug.Assert(ReadyForToken==_currentField, "Not on first or last column!"); -#endif - - // For TVP types, write new-row token - Debug.Assert(_metaData.IsMultiValued, "Unsupported call for single-valued types"); - _stateObj.WriteByte(TdsEnums.TVP_ROW_TOKEN); -#if DEBUG - _currentField = 0; -#endif - } - - internal override void EndElements(SmiEventSink sink) - { -#if DEBUG - SkipPossibleDefaultedColumns(ReadyForToken); - Debug.Assert(ReadyForToken==_currentField, "Not on first or last column!"); - Debug.Assert(_metaData.IsMultiValued, "Unsupported call for single-valued types"); -#endif - // For TVP types, write no-more-rows token - _stateObj.WriteByte(TdsEnums.TVP_END_TOKEN); -#if DEBUG - _currentField = EndElementsCalled; -#endif - } - - - #endregion - - #region private methods - [Conditional("DEBUG")] - private void CheckWritingToColumn(int ordinal) - { -#if DEBUG - Debug.Assert(0 <= ordinal, "TdsRecordBufferSetter.CheckWritingToColumn: Targeting invalid column: " + ordinal); - SkipPossibleDefaultedColumns(ordinal); - - Debug.Assert(0 <= _currentField && _metaData.FieldMetaData.Count > _currentField, "_currentField out of range for setting a column:" + _currentField); - Debug.Assert(ordinal == _currentField, "Setter called out of order. Should be " + _currentField + ", but was " + ordinal); - // Must not write to field with a DefaultFieldsProperty set to true - Debug.Assert(!((SmiDefaultFieldsProperty)_metaData.ExtendedProperties[SmiPropertySelector.DefaultFields])[ordinal], - "Attempt to write to a default-valued field: " + ordinal); -#endif - } - - // Handle logic of skipping default columns - [Conditional("DEBUG")] - private void SkipPossibleDefaultedColumns(int targetColumn) - { -#if DEBUG - Debug.Assert(targetColumn < _metaData.FieldMetaData.Count && targetColumn >= ReadyForToken, "TdsRecordBufferSetter.SkipPossibleDefaultedColumns: Invalid target column: " + targetColumn); - - // special setup for ReadyForToken as the target - if (targetColumn == ReadyForToken) { - if (ReadyForToken == _currentField) { - return; - } - - // Handle readyfortoken by using count of columns in the loop. - targetColumn = _metaData.FieldMetaData.Count; - } - - // Handle skipping default-valued fields - while (targetColumn > _currentField) { - // All intermediate fields must be default fields (i.e. have a "true" entry in SmiDefaultFieldsProperty - Debug.Assert(((SmiDefaultFieldsProperty)_metaData.ExtendedProperties[SmiPropertySelector.DefaultFields])[_currentField], - "Skipping a field that was not default: " + _currentField); - _currentField++; - } - - if (_metaData.FieldMetaData.Count == _currentField) { - _currentField = ReadyForToken; - } -#endif - } - - [Conditional("DEBUG")] - internal void CheckSettingColumn(int ordinal) - { -#if DEBUG - // Make sure target column can be written to. - CheckWritingToColumn(ordinal); - - _currentField++; - if (_metaData.FieldMetaData.Count == _currentField) { - _currentField = ReadyForToken; - } -#endif - } - - #endregion - } -} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsValueSetter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsValueSetter.cs deleted file mode 100644 index c4779b3e64..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsValueSetter.cs +++ /dev/null @@ -1,709 +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. - -using System; -using System.Data; -using System.Data.SqlTypes; -using System.Diagnostics; -using System.Text; -using Microsoft.Data.Common; -using Microsoft.Data.SqlClient.Server; - -namespace Microsoft.Data.SqlClient -{ - // TdsValueSetter handles writing a single value out to a TDS stream - // This class can easily be extended to handle multiple versions of TDS by sub-classing and virtualizing - // methods that have different formats or are not supported in one or the other version. - internal class TdsValueSetter - { - #region Private fields - - private TdsParserStateObject _stateObj; // target to write to - private SmiMetaData _metaData; // metadata describing value - private bool _isPlp; // should this column be sent in PLP format? - private bool _plpUnknownSent;// did we send initial UNKNOWN_LENGTH marker? - private Encoder _encoder; // required for chunking character type data - private SmiMetaData _variantType; // required for sql_variant -#if DEBUG - private int _currentOffset; // for chunking, verify that caller is using correct offsets -#endif - - #endregion - - #region Exposed Construct/factory methods - - internal TdsValueSetter(TdsParserStateObject stateObj, SmiMetaData md) - { - _stateObj = stateObj; - _metaData = md; - _isPlp = MetaDataUtilsSmi.IsPlpFormat(md); - _plpUnknownSent = false; - _encoder = null; -#if DEBUG - _currentOffset = 0; -#endif - } - - #endregion - - #region Setters - - // Set value to null - // valid for all types - internal void SetDBNull() - { - Debug.Assert(!_plpUnknownSent, "Setting a column to null that we already stated sending!"); - if (_isPlp) - { - _stateObj.Parser.WriteUnsignedLong(TdsEnums.SQL_PLP_NULL, _stateObj); - } - else - { - switch (_metaData.SqlDbType) - { - case SqlDbType.BigInt: - case SqlDbType.Bit: - case SqlDbType.DateTime: - case SqlDbType.Decimal: - case SqlDbType.Float: - case SqlDbType.Int: - case SqlDbType.Money: - case SqlDbType.Real: - case SqlDbType.UniqueIdentifier: - case SqlDbType.SmallDateTime: - case SqlDbType.SmallInt: - case SqlDbType.SmallMoney: - case SqlDbType.TinyInt: - case SqlDbType.Date: - case SqlDbType.Time: - case SqlDbType.DateTime2: - case SqlDbType.DateTimeOffset: - _stateObj.WriteByte(TdsEnums.FIXEDNULL); - break; - case SqlDbType.Binary: - case SqlDbType.Char: - case SqlDbType.Image: - case SqlDbType.NChar: - case SqlDbType.NText: - case SqlDbType.NVarChar: - case SqlDbType.Text: - case SqlDbType.Timestamp: - case SqlDbType.VarBinary: - case SqlDbType.VarChar: - _stateObj.Parser.WriteShort(TdsEnums.VARNULL, _stateObj); - break; - case SqlDbType.Udt: - case SqlDbType.Xml: - Debug.Fail("PLP-only types shouldn't get to this point. Type: " + _metaData.SqlDbType); - break; - case SqlDbType.Variant: - _stateObj.Parser.WriteInt(TdsEnums.FIXEDNULL, _stateObj); - break; - case SqlDbType.Structured: - Debug.Fail("Not yet implemented. Not needed until Structured UDTs"); - break; - default: - Debug.Fail("Unexpected SqlDbType: " + _metaData.SqlDbType); - break; - } - } - } - - // valid for SqlDbType.Bit - internal void SetBoolean(Boolean value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetBoolean)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(3, TdsEnums.SQLBIT, 0, _stateObj); - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - if (value) - { - _stateObj.WriteByte(1); - } - else - { - _stateObj.WriteByte(0); - } - } - - // valid for SqlDbType.TinyInt - internal void SetByte(Byte value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetByte)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(3, TdsEnums.SQLINT1, 0, _stateObj); - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - _stateObj.WriteByte(value); - } - - // Semantics for SetBytes are to modify existing value, not overwrite - // Use in combination with SetLength to ensure overwriting when necessary - // valid for SqlDbTypes: Binary, VarBinary, Image, Udt, Xml - // (VarBinary assumed for variants) - internal int SetBytes(long fieldOffset, byte[] buffer, int bufferOffset, int length) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetBytes)); - CheckSettingOffset(fieldOffset); - - SetBytesNoOffsetHandling(fieldOffset, buffer, bufferOffset, length); -#if DEBUG - _currentOffset += length; -#endif - return length; - } - - private void SetBytesNoOffsetHandling(long fieldOffset, byte[] buffer, int bufferOffset, int length) - { - if (_isPlp) - { - if (!_plpUnknownSent) - { - _stateObj.Parser.WriteUnsignedLong(TdsEnums.SQL_PLP_UNKNOWNLEN, _stateObj); - _plpUnknownSent = true; - } - - // Write chunk length & chunk - _stateObj.Parser.WriteInt(length, _stateObj); - _stateObj.WriteByteArray(buffer, length, bufferOffset); - } - else - { - // Non-plp data must be sent in one chunk for now. -#if DEBUG - Debug.Assert(0 == _currentOffset, "SetBytes doesn't yet support chunking for non-plp data: " + _currentOffset); - -#endif - Debug.Assert(!MetaType.GetMetaTypeFromSqlDbType(_metaData.SqlDbType, _metaData.IsMultiValued).IsLong, - "We're assuming long length types are sent as PLP. SqlDbType = " + _metaData.SqlDbType); - - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(4 + length, TdsEnums.SQLBIGVARBINARY, 2, _stateObj); - } - _stateObj.Parser.WriteShort(length, _stateObj); - _stateObj.WriteByteArray(buffer, length, bufferOffset); - } - } - - internal void SetBytesLength(long length) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetBytes)); - CheckSettingOffset(length); - - if (0 == length) - { - if (_isPlp) - { - Debug.Assert(!_plpUnknownSent, "A plpUnknown has already been sent before setting length to zero."); - - _stateObj.Parser.WriteLong(0, _stateObj); - _plpUnknownSent = true; - } - else - { - Debug.Assert(!MetaType.GetMetaTypeFromSqlDbType(_metaData.SqlDbType, _metaData.IsMultiValued).IsLong, - "We're assuming long length types are sent as PLP. SqlDbType = " + _metaData.SqlDbType); - - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(4, TdsEnums.SQLBIGVARBINARY, 2, _stateObj); - } - _stateObj.Parser.WriteShort(0, _stateObj); - } - } - if (_plpUnknownSent) - { - _stateObj.Parser.WriteInt(TdsEnums.SQL_PLP_CHUNK_TERMINATOR, _stateObj); - _plpUnknownSent = false; - } - -#if DEBUG - //UNDONE: assumes SetBytesLength is done at end. But we could optimize deciding when we send PLP's! - _currentOffset = 0; -#endif - } - - // Semantics for SetChars are to modify existing value, not overwrite - // Use in combination with SetLength to ensure overwriting when necessary - // valid for character types: Char, VarChar, Text, NChar, NVarChar, NText - // (NVarChar and global clr collation assumed for variants) - internal int SetChars(long fieldOffset, char[] buffer, int bufferOffset, int length) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetChars)); - - // ANSI types must convert to byte[] because that's the tool we have. - if (MetaDataUtilsSmi.IsAnsiType(_metaData.SqlDbType)) - { - if (null == _encoder) - { - _encoder = _stateObj.Parser._defaultEncoding.GetEncoder(); - } - byte[] bytes = new byte[_encoder.GetByteCount(buffer, bufferOffset, length, false)]; - _encoder.GetBytes(buffer, bufferOffset, length, bytes, 0, false); - SetBytesNoOffsetHandling(fieldOffset, bytes, 0, bytes.Length); - } - else - { - CheckSettingOffset(fieldOffset); - - // Send via PLP format if we can. - if (_isPlp) - { - - // Handle initial PLP markers - if (!_plpUnknownSent) - { - _stateObj.Parser.WriteUnsignedLong(TdsEnums.SQL_PLP_UNKNOWNLEN, _stateObj); - _plpUnknownSent = true; - } - - // Write chunk length - _stateObj.Parser.WriteInt(length * ADP.CharSize, _stateObj); - _stateObj.Parser.WriteCharArray(buffer, length, bufferOffset, _stateObj); - } - else - { - // Non-plp data must be sent in one chunk for now. -#if DEBUG - Debug.Assert(0 == _currentOffset, "SetChars doesn't yet support chunking for non-plp data: " + _currentOffset); -#endif - - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantValue(new String(buffer, bufferOffset, length), length, 0, _stateObj); - } - else - { - Debug.Assert(!MetaType.GetMetaTypeFromSqlDbType(_metaData.SqlDbType, _metaData.IsMultiValued).IsLong, - "We're assuming long length types are sent as PLP. SqlDbType = " + _metaData.SqlDbType); - _stateObj.Parser.WriteShort(length * ADP.CharSize, _stateObj); - _stateObj.Parser.WriteCharArray(buffer, length, bufferOffset, _stateObj); - } - } - } - -#if DEBUG - _currentOffset += length; -#endif - return length; - } - internal void SetCharsLength(long length) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetChars)); - CheckSettingOffset(length); - - if (0 == length) - { - if (_isPlp) - { - Debug.Assert(!_plpUnknownSent, "A plpUnknown has already been sent before setting length to zero."); - - _stateObj.Parser.WriteLong(0, _stateObj); - _plpUnknownSent = true; - } - else - { - Debug.Assert(!MetaType.GetMetaTypeFromSqlDbType(_metaData.SqlDbType, _metaData.IsMultiValued).IsLong, - "We're assuming long length types are sent as PLP. SqlDbType = " + _metaData.SqlDbType); - - _stateObj.Parser.WriteShort(0, _stateObj); - } - } - if (_plpUnknownSent) - { - _stateObj.Parser.WriteInt(TdsEnums.SQL_PLP_CHUNK_TERMINATOR, _stateObj); - _plpUnknownSent = false; - } - _encoder = null; - -#if DEBUG - //UNDONE: assumes SetCharsLength is done at end. But we could optimize deciding when we send PLP's by setting length first! - _currentOffset = 0; -#endif - } - - // valid for character types: Char, VarChar, Text, NChar, NVarChar, NText - internal void SetString(string value, int offset, int length) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetString)); - - // ANSI types must convert to byte[] because that's the tool we have. - if (MetaDataUtilsSmi.IsAnsiType(_metaData.SqlDbType)) - { - byte[] bytes; - // Optimize for common case of writing entire string - if (offset == 0 && value.Length <= length) - { - bytes = _stateObj.Parser._defaultEncoding.GetBytes(value); - } - else - { - char[] chars = value.ToCharArray(offset, length); - bytes = _stateObj.Parser._defaultEncoding.GetBytes(chars); - } - SetBytes(0, bytes, 0, bytes.Length); - SetBytesLength(bytes.Length); - } - else if (SqlDbType.Variant == _metaData.SqlDbType) - { - Debug.Assert(null != _variantType && SqlDbType.NVarChar == _variantType.SqlDbType, "Invalid variant type"); - - SqlCollation collation = new SqlCollation(); - collation.LCID = checked((int)_variantType.LocaleId); - collation.SqlCompareOptions = _variantType.CompareOptions; - - if (length * ADP.CharSize > TdsEnums.TYPE_SIZE_LIMIT) - { // send as varchar for length greater than 4000 - byte[] bytes; - // Optimize for common case of writing entire string - if (offset == 0 && value.Length <= length) - { - bytes = _stateObj.Parser._defaultEncoding.GetBytes(value); - } - else - { - bytes = _stateObj.Parser._defaultEncoding.GetBytes(value.ToCharArray(offset, length)); - } - _stateObj.Parser.WriteSqlVariantHeader(9 + bytes.Length, TdsEnums.SQLBIGVARCHAR, 7, _stateObj); - _stateObj.Parser.WriteUnsignedInt(collation.info, _stateObj); // propbytes: collation.Info - _stateObj.WriteByte(collation.sortId); // propbytes: collation.SortId - _stateObj.Parser.WriteShort(bytes.Length, _stateObj); // propbyte: varlen - _stateObj.WriteByteArray(bytes, bytes.Length, 0); - } - else - { - _stateObj.Parser.WriteSqlVariantHeader(9 + length * ADP.CharSize, TdsEnums.SQLNVARCHAR, 7, _stateObj); - _stateObj.Parser.WriteUnsignedInt(collation.info, _stateObj); // propbytes: collation.Info - _stateObj.WriteByte(collation.sortId); // propbytes: collation.SortId - _stateObj.Parser.WriteShort(length * ADP.CharSize, _stateObj); // propbyte: varlen - _stateObj.Parser.WriteString(value, length, offset, _stateObj); - } - _variantType = null; - } - else if (_isPlp) - { - // Send the string as a complete PLP chunk. - _stateObj.Parser.WriteLong(length * ADP.CharSize, _stateObj); // PLP total length - _stateObj.Parser.WriteInt(length * ADP.CharSize, _stateObj); // Chunk length - _stateObj.Parser.WriteString(value, length, offset, _stateObj); // Data - if (length != 0) - { - _stateObj.Parser.WriteInt(TdsEnums.SQL_PLP_CHUNK_TERMINATOR, _stateObj); // Terminator - } - } - else - { - _stateObj.Parser.WriteShort(length * ADP.CharSize, _stateObj); - _stateObj.Parser.WriteString(value, length, offset, _stateObj); - } - } - - // valid for SqlDbType.SmallInt - internal void SetInt16(Int16 value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetInt16)); - - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(4, TdsEnums.SQLINT2, 0, _stateObj); - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - _stateObj.Parser.WriteShort(value, _stateObj); - } - - // valid for SqlDbType.Int - internal void SetInt32(Int32 value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetInt32)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(6, TdsEnums.SQLINT4, 0, _stateObj); - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - _stateObj.Parser.WriteInt(value, _stateObj); - } - - // valid for SqlDbType.BigInt, SqlDbType.Money, SqlDbType.SmallMoney - internal void SetInt64(Int64 value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetInt64)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - if (null == _variantType) - { - _stateObj.Parser.WriteSqlVariantHeader(10, TdsEnums.SQLINT8, 0, _stateObj); - _stateObj.Parser.WriteLong(value, _stateObj); - } - else - { - Debug.Assert(SqlDbType.Money == _variantType.SqlDbType, "Invalid variant type"); - - _stateObj.Parser.WriteSqlVariantHeader(10, TdsEnums.SQLMONEY, 0, _stateObj); - _stateObj.Parser.WriteInt((int)(value >> 0x20), _stateObj); - _stateObj.Parser.WriteInt((int)value, _stateObj); - _variantType = null; - } - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - if (SqlDbType.SmallMoney == _metaData.SqlDbType) - { - _stateObj.Parser.WriteInt((int)value, _stateObj); - } - else if (SqlDbType.Money == _metaData.SqlDbType) - { - _stateObj.Parser.WriteInt((int)(value >> 0x20), _stateObj); - _stateObj.Parser.WriteInt((int)value, _stateObj); - } - else - { - _stateObj.Parser.WriteLong(value, _stateObj); - } - } - } - - // valid for SqlDbType.Real - internal void SetSingle(Single value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetSingle)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(6, TdsEnums.SQLFLT4, 0, _stateObj); - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - _stateObj.Parser.WriteFloat(value, _stateObj); - } - - // valid for SqlDbType.Float - internal void SetDouble(Double value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetDouble)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(10, TdsEnums.SQLFLT8, 0, _stateObj); - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - _stateObj.Parser.WriteDouble(value, _stateObj); - } - - // valid for SqlDbType.Numeric (uses SqlDecimal since Decimal cannot hold full range) - internal void SetSqlDecimal(SqlDecimal value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetSqlDecimal)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(21, TdsEnums.SQLNUMERICN, 2, _stateObj); - _stateObj.WriteByte(value.Precision); // propbytes: precision - _stateObj.WriteByte(value.Scale); // propbytes: scale - _stateObj.Parser.WriteSqlDecimal(value, _stateObj); - } - else - { - _stateObj.WriteByte(checked((byte)MetaType.MetaDecimal.FixedLength)); // SmiMetaData's length and actual wire format's length are different - _stateObj.Parser.WriteSqlDecimal(SqlDecimal.ConvertToPrecScale(value, _metaData.Precision, _metaData.Scale), _stateObj); - } - } - - // valid for DateTime, SmallDateTime, Date, DateTime2 - internal void SetDateTime(DateTime value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetDateTime)); - if (SqlDbType.Variant == _metaData.SqlDbType) - { - if ((_variantType != null) && (_variantType.SqlDbType == SqlDbType.DateTime2)) - { - _stateObj.Parser.WriteSqlVariantDateTime2(value, _stateObj); - } - else if ((_variantType != null) && (_variantType.SqlDbType == SqlDbType.Date)) - { - _stateObj.Parser.WriteSqlVariantDate(value, _stateObj); - } - else - { - TdsDateTime dt = MetaType.FromDateTime(value, 8); - _stateObj.Parser.WriteSqlVariantHeader(10, TdsEnums.SQLDATETIME, 0, _stateObj); - _stateObj.Parser.WriteInt(dt.days, _stateObj); - _stateObj.Parser.WriteInt(dt.time, _stateObj); - } - - // Clean the variant metadata to prevent sharing it with next row. - // As a reminder, SetVariantType raises an assert if _variantType is not clean - _variantType = null; - - } - else - { - _stateObj.WriteByte((byte)_metaData.MaxLength); - if (SqlDbType.SmallDateTime == _metaData.SqlDbType) - { - TdsDateTime dt = MetaType.FromDateTime(value, (byte)_metaData.MaxLength); - Debug.Assert(0 <= dt.days && dt.days <= UInt16.MaxValue, "Invalid DateTime '" + value + "' for SmallDateTime"); - - _stateObj.Parser.WriteShort(dt.days, _stateObj); - _stateObj.Parser.WriteShort(dt.time, _stateObj); - } - else if (SqlDbType.DateTime == _metaData.SqlDbType) - { - TdsDateTime dt = MetaType.FromDateTime(value, (byte)_metaData.MaxLength); - _stateObj.Parser.WriteInt(dt.days, _stateObj); - _stateObj.Parser.WriteInt(dt.time, _stateObj); - } - else - { // date and datetime2 - int days = value.Subtract(DateTime.MinValue).Days; - if (SqlDbType.DateTime2 == _metaData.SqlDbType) - { - Int64 time = value.TimeOfDay.Ticks / TdsEnums.TICKS_FROM_SCALE[_metaData.Scale]; - _stateObj.WriteByteArray(BitConverter.GetBytes(time), (int)_metaData.MaxLength - 3, 0); - } - _stateObj.WriteByteArray(BitConverter.GetBytes(days), 3, 0); - } - } - } - - // valid for UniqueIdentifier - internal void SetGuid(Guid value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetGuid)); - - byte[] bytes = value.ToByteArray(); - Debug.Assert(SmiMetaData.DefaultUniqueIdentifier.MaxLength == bytes.Length, "Invalid length for guid bytes: " + bytes.Length); - - if (SqlDbType.Variant == _metaData.SqlDbType) - { - _stateObj.Parser.WriteSqlVariantHeader(18, TdsEnums.SQLUNIQUEID, 0, _stateObj); - } - else - { - Debug.Assert(_metaData.MaxLength == bytes.Length, "Unexpected uniqueid metadata length: " + _metaData.MaxLength); - - _stateObj.WriteByte((byte)_metaData.MaxLength); - } - _stateObj.WriteByteArray(bytes, bytes.Length, 0); - } - - // valid for SqlDbType.Time - internal void SetTimeSpan(TimeSpan value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetTime)); - byte scale; - byte length; - if (SqlDbType.Variant == _metaData.SqlDbType) - { - scale = SmiMetaData.DefaultTime.Scale; - length = (byte)SmiMetaData.DefaultTime.MaxLength; - _stateObj.Parser.WriteSqlVariantHeader(8, TdsEnums.SQLTIME, 1, _stateObj); - _stateObj.WriteByte(scale); //propbytes: scale - } - else - { - scale = _metaData.Scale; - length = (byte)_metaData.MaxLength; - _stateObj.WriteByte(length); - } - Int64 time = value.Ticks / TdsEnums.TICKS_FROM_SCALE[scale]; - _stateObj.WriteByteArray(BitConverter.GetBytes(time), length, 0); - } - - // valid for DateTimeOffset - internal void SetDateTimeOffset(DateTimeOffset value) - { - Debug.Assert( - SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetDateTimeOffset)); - byte scale; - byte length; - if (SqlDbType.Variant == _metaData.SqlDbType) - { - // VSTFDevDiv #885208 - DateTimeOffset throws ArgumentException for when passing DateTimeOffset value to a sql_variant TVP - // using a SqlDataRecord or SqlDataReader - SmiMetaData dateTimeOffsetMetaData = SmiMetaData.DefaultDateTimeOffset; - scale = MetaType.MetaDateTimeOffset.Scale; - length = (byte)dateTimeOffsetMetaData.MaxLength; - _stateObj.Parser.WriteSqlVariantHeader(13, TdsEnums.SQLDATETIMEOFFSET, 1, _stateObj); - _stateObj.WriteByte(scale); //propbytes: scale - } - else - { - scale = _metaData.Scale; - length = (byte)_metaData.MaxLength; - _stateObj.WriteByte(length); - } - DateTime utcDateTime = value.UtcDateTime; - Int64 time = utcDateTime.TimeOfDay.Ticks / TdsEnums.TICKS_FROM_SCALE[scale]; - int days = utcDateTime.Subtract(DateTime.MinValue).Days; - Int16 offset = (Int16)value.Offset.TotalMinutes; - - _stateObj.WriteByteArray(BitConverter.GetBytes(time), length - 5, 0); // time - _stateObj.WriteByteArray(BitConverter.GetBytes(days), 3, 0); // date - _stateObj.WriteByte((byte)(offset & 0xff)); // offset byte 1 - _stateObj.WriteByte((byte)((offset >> 8) & 0xff)); // offset byte 2 - } - - internal void SetVariantType(SmiMetaData value) - { - Debug.Assert(null == _variantType, "Variant type can only be set once"); - Debug.Assert(value != null && - (value.SqlDbType == SqlDbType.Money || - value.SqlDbType == SqlDbType.NVarChar || - value.SqlDbType == SqlDbType.Date || - value.SqlDbType == SqlDbType.DateTime || - value.SqlDbType == SqlDbType.DateTime2 || - value.SqlDbType == SqlDbType.DateTimeOffset || - value.SqlDbType == SqlDbType.SmallDateTime - ), "Invalid variant type"); - _variantType = value; - } - - #endregion - - #region private methods - [Conditional("DEBUG")] - private void CheckSettingOffset(long offset) - { -#if DEBUG - Debug.Assert(offset == _currentOffset, "Invalid offset passed. Should be: " + _currentOffset + ", but was: " + offset); -#endif - } - #endregion - } -} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiRecordBuffer.cs diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParameterSetter.cs diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsRecordBufferSetter.cs diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsValueSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsValueSetter.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs