From 03e67f1c017cfdf4e85794f98f4a29f2a9f1af30 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 06:37:36 +0000
Subject: [PATCH 01/14] Factored relevant netfx classes into
AlwaysEncryptedHelperClasses.cs for comparison and changes
---
.../netfx/src/Microsoft.Data.SqlClient.csproj | 7 +-
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 597 ++++++++++++++++++
.../Data/SqlClient/TdsParserHelperClasses.cs | 581 +----------------
3 files changed, 606 insertions(+), 579 deletions(-)
create mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.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 97feee8bef..21f8906838 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -22,14 +22,14 @@
full
-
+
$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(GeneratedSourceFileName)'))
-
+
True
@@ -633,6 +633,7 @@
+
@@ -751,4 +752,4 @@
-
+
\ No newline at end of file
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
new file mode 100644
index 0000000000..dd3b6dfec5
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
@@ -0,0 +1,597 @@
+// 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.Collections.Generic;
+using System.Diagnostics;
+using Microsoft.Data.SqlClient.Server;
+
+namespace Microsoft.Data.SqlClient
+{
+
+ ///
+ /// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
+ /// the store type, name,the key path and encryption algorithm.
+ ///
+ internal class SqlEncryptionKeyInfo
+ {
+ internal byte[] encryptedKey; // the encrypted "column encryption key"
+ internal int databaseId;
+ internal int cekId;
+ internal int cekVersion;
+ internal byte[] cekMdVersion;
+ internal string keyPath;
+ internal string keyStoreName;
+ internal string algorithmName;
+ internal byte normalizationRuleVersion;
+ }
+
+ ///
+ /// Encapsulates one entry in the CipherInfo table sent as part of Colmetadata.
+ /// The same CEK is encrypted multiple times with different master keys (for master key
+ /// rotation scenario) We need to keep all these around until we can resolve the CEK
+ /// using the correct master key.
+ ///
+ internal class SqlTceCipherInfoEntry
+ {
+
+ ///
+ /// List of Column Encryption Key Information.
+ ///
+ private readonly List _columnEncryptionKeyValues;
+
+ ///
+ /// Key Ordinal.
+ ///
+ private readonly int _ordinal;
+
+ ///
+ /// Database ID
+ ///
+ private int _databaseId;
+
+ ///
+ /// Cek ID
+ ///
+ private int _cekId;
+
+ ///
+ /// Cek Version
+ ///
+ private int _cekVersion;
+
+ ///
+ /// Cek MD Version
+ ///
+ private byte[] _cekMdVersion;
+
+ ///
+ /// Return the ordinal.
+ ///
+ internal int Ordinal
+ {
+ get
+ {
+ return _ordinal;
+ }
+ }
+
+ ///
+ /// Return the DatabaseID.
+ ///
+ internal int DatabaseId
+ {
+ get
+ {
+ return _databaseId;
+ }
+ }
+
+ ///
+ /// Return the CEK ID.
+ ///
+ internal int CekId
+ {
+ get
+ {
+ return _cekId;
+ }
+ }
+
+ ///
+ /// Return the CEK Version.
+ ///
+ internal int CekVersion
+ {
+ get
+ {
+ return _cekVersion;
+ }
+ }
+
+ ///
+ /// Return the CEK MD Version.
+ ///
+ internal byte[] CekMdVersion
+ {
+ get
+ {
+ return _cekMdVersion;
+ }
+ }
+
+ ///
+ /// Return the list of Column Encryption Key Values.
+ ///
+ internal List ColumnEncryptionKeyValues
+ {
+ get
+ {
+ return _columnEncryptionKeyValues;
+ }
+ }
+
+ ///
+ /// Add an entry to the list of ColumnEncryptionKeyValues.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
+ {
+
+ Debug.Assert(_columnEncryptionKeyValues != null, "_columnEncryptionKeyValues should already be initialized.");
+
+ SqlEncryptionKeyInfo encryptionKey = new SqlEncryptionKeyInfo();
+ encryptionKey.encryptedKey = encryptedKey;
+ encryptionKey.databaseId = databaseId;
+ encryptionKey.cekId = cekId;
+ encryptionKey.cekVersion = cekVersion;
+ encryptionKey.cekMdVersion = cekMdVersion;
+ encryptionKey.keyPath = keyPath;
+ encryptionKey.keyStoreName = keyStoreName;
+ encryptionKey.algorithmName = algorithmName;
+ _columnEncryptionKeyValues.Add(encryptionKey);
+
+ if (0 == _databaseId)
+ {
+ _databaseId = databaseId;
+ _cekId = cekId;
+ _cekVersion = cekVersion;
+ _cekMdVersion = cekMdVersion;
+ }
+ else
+ {
+ Debug.Assert(_databaseId == databaseId);
+ Debug.Assert(_cekId == cekId);
+ Debug.Assert(_cekVersion == cekVersion);
+ Debug.Assert(_cekMdVersion != null && cekMdVersion != null && _cekMdVersion.Length == _cekMdVersion.Length);
+ }
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ internal SqlTceCipherInfoEntry(int ordinal = 0)
+ {
+ _ordinal = ordinal;
+ _databaseId = 0;
+ _cekId = 0;
+ _cekVersion = 0;
+ _cekMdVersion = null;
+ _columnEncryptionKeyValues = new List();
+ }
+ }
+
+ ///
+ /// Represents a table with various CEKs used in a resultset. Each entry corresponds to one (unique) CEK. The CEK
+ /// may have been encrypted using multiple master keys (giving us multiple CEK values). All these values form one single
+ /// entry in this table.
+ ///
+ internal class SqlTceCipherInfoTable
+ {
+ private readonly SqlTceCipherInfoEntry[] keyList;
+
+ internal SqlTceCipherInfoTable(int tabSize)
+ {
+ Debug.Assert(0 < tabSize, "Invalid Table Size");
+ keyList = new SqlTceCipherInfoEntry[tabSize];
+ }
+
+ internal SqlTceCipherInfoEntry this[int index]
+ {
+ get
+ {
+ Debug.Assert(index < keyList.Length, "Invalid index specified.");
+ return keyList[index];
+ }
+ set
+ {
+ Debug.Assert(index < keyList.Length, "Invalid index specified.");
+ keyList[index] = value;
+ }
+ }
+
+ internal int Size
+ {
+ get
+ {
+ return keyList.Length;
+ }
+ }
+ }
+
+ sealed internal partial class _SqlMetaDataSet
+ {
+ internal readonly SqlTceCipherInfoTable cekTable; // table of "column encryption keys" used for this metadataset
+
+ internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
+ : this(count)
+ {
+ cekTable = cipherTable;
+ }
+ }
+
+ ///
+ /// Represents Encryption related information of the cipher data.
+ ///
+ internal class SqlCipherMetadata
+ {
+
+ ///
+ /// Cipher Info Entry.
+ ///
+ private SqlTceCipherInfoEntry _sqlTceCipherInfoEntry;
+
+ ///
+ /// Encryption Algorithm Id.
+ ///
+ private readonly byte _cipherAlgorithmId;
+
+ ///
+ /// Encryption Algorithm Name.
+ ///
+ private readonly string _cipherAlgorithmName;
+
+ ///
+ /// Encryption Type.
+ ///
+ private readonly byte _encryptionType;
+
+ ///
+ /// Normalization Rule Version.
+ ///
+ private readonly byte _normalizationRuleVersion;
+
+ ///
+ /// Encryption Algorithm Handle.
+ ///
+ private SqlClientEncryptionAlgorithm _sqlClientEncryptionAlgorithm;
+
+ ///
+ /// Sql Encryption Key Info.
+ ///
+ private SqlEncryptionKeyInfo _sqlEncryptionKeyInfo;
+
+ ///
+ /// Ordinal (into the Cek Table).
+ ///
+ private readonly ushort _ordinal;
+
+ ///
+ /// Return the Encryption Info Entry.
+ ///
+ internal SqlTceCipherInfoEntry EncryptionInfo
+ {
+ get
+ {
+ return _sqlTceCipherInfoEntry;
+ }
+ set
+ {
+ Debug.Assert(_sqlTceCipherInfoEntry == null, "We can only set the EncryptionInfo once.");
+ _sqlTceCipherInfoEntry = value;
+ }
+ }
+
+ ///
+ /// Return the cipher's encryption algorithm id.
+ ///
+ internal byte CipherAlgorithmId
+ {
+ get
+ {
+ return _cipherAlgorithmId;
+ }
+ }
+
+ ///
+ /// Return the cipher's encryption algorithm name (could be null).
+ ///
+ internal string CipherAlgorithmName
+ {
+ get
+ {
+ return _cipherAlgorithmName;
+ }
+ }
+
+ ///
+ /// Return EncryptionType (Deterministic, Randomized, etc.)
+ ///
+ internal byte EncryptionType
+ {
+ get
+ {
+ return _encryptionType;
+ }
+ }
+
+ ///
+ /// Return normalization rule version.
+ ///
+ internal byte NormalizationRuleVersion
+ {
+ get
+ {
+ return _normalizationRuleVersion;
+ }
+ }
+
+ ///
+ /// Return the cipher encryption algorithm handle.
+ ///
+ internal SqlClientEncryptionAlgorithm CipherAlgorithm
+ {
+ get
+ {
+ return _sqlClientEncryptionAlgorithm;
+ }
+ set
+ {
+ Debug.Assert(_sqlClientEncryptionAlgorithm == null, "_sqlClientEncryptionAlgorithm should not be set more than once.");
+ _sqlClientEncryptionAlgorithm = value;
+ }
+ }
+
+ ///
+ /// Return Encryption Key Info.
+ ///
+ internal SqlEncryptionKeyInfo EncryptionKeyInfo
+ {
+ get
+ {
+ return _sqlEncryptionKeyInfo;
+ }
+
+ set
+ {
+ Debug.Assert(_sqlEncryptionKeyInfo == null, "_sqlEncryptionKeyInfo should not be set more than once.");
+ _sqlEncryptionKeyInfo = value;
+ }
+ }
+
+ ///
+ /// Return Ordinal into Cek Table.
+ ///
+ internal ushort CekTableOrdinal
+ {
+ get
+ {
+ return _ordinal;
+ }
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
+ ushort ordinal,
+ byte cipherAlgorithmId,
+ string cipherAlgorithmName,
+ byte encryptionType,
+ byte normalizationRuleVersion)
+ {
+ Debug.Assert(!sqlTceCipherInfoEntry.Equals(default(SqlTceCipherInfoEntry)), "sqlTceCipherInfoEntry should not be un-initialized.");
+
+ _sqlTceCipherInfoEntry = sqlTceCipherInfoEntry;
+ _ordinal = ordinal;
+ _cipherAlgorithmId = cipherAlgorithmId;
+ _cipherAlgorithmName = cipherAlgorithmName;
+ _encryptionType = encryptionType;
+ _normalizationRuleVersion = normalizationRuleVersion;
+ _sqlEncryptionKeyInfo = null;
+ }
+
+ ///
+ /// Do we have an handle to the cipher encryption algorithm already ?
+ ///
+ ///
+ internal bool IsAlgorithmInitialized()
+ {
+ return (null != _sqlClientEncryptionAlgorithm) ? true : false;
+ }
+ }
+
+ internal partial class SqlMetaDataPriv
+ {
+ internal bool isEncrypted; // TCE encrypted?
+ internal SqlMetaDataPriv baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
+ internal SqlCipherMetadata cipherMD; // Cipher related metadata for encrypted columns.
+
+ ///
+ /// Is the algorithm handle for the cipher encryption initialized ?
+ ///
+ ///
+ internal bool IsAlgorithmInitialized()
+ {
+ if (null != cipherMD)
+ {
+ return cipherMD.IsAlgorithmInitialized();
+ }
+
+ return false;
+ }
+
+ ///
+ /// Returns the normalization rule version byte.
+ ///
+ ///
+ internal byte NormalizationRuleVersion
+ {
+ get
+ {
+ if (null != cipherMD)
+ {
+ return cipherMD.NormalizationRuleVersion;
+ }
+
+ return 0x00;
+ }
+ }
+ }
+
+ ///
+ /// Class encapsulating additional information when sending encrypted input parameters.
+ ///
+ sealed internal class SqlColumnEncryptionInputParameterInfo
+ {
+ ///
+ /// Metadata of the parameter to write the TYPE_INFO of the unencrypted column data type.
+ ///
+ private readonly SmiParameterMetaData _smiParameterMetadata;
+
+ ///
+ /// Column encryption related metadata.
+ ///
+ private readonly SqlCipherMetadata _cipherMetadata;
+
+ ///
+ /// Serialized format for a subset of members.
+ /// Does not include _smiParameterMetadata's serialization.
+ ///
+ private readonly byte[] _serializedWireFormat;
+
+ ///
+ /// Return the SMI Parameter Metadata.
+ ///
+ internal SmiParameterMetaData ParameterMetadata
+ {
+ get
+ {
+ return _smiParameterMetadata;
+ }
+ }
+
+ ///
+ /// Return the serialized format for some members.
+ /// This is pre-calculated and cached since members are immutable.
+ /// Does not include _smiParameterMetadata's serialization.
+ ///
+ internal byte[] SerializedWireFormat
+ {
+ get
+ {
+ return _serializedWireFormat;
+ }
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ ///
+ internal SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
+ {
+ Debug.Assert(smiParameterMetadata != null, "smiParameterMetadata should not be null.");
+ Debug.Assert(cipherMetadata != null, "cipherMetadata should not be null");
+ Debug.Assert(cipherMetadata.EncryptionKeyInfo != null, "cipherMetadata.EncryptionKeyInfo.HasValue should be true.");
+
+ _smiParameterMetadata = smiParameterMetadata;
+ _cipherMetadata = cipherMetadata;
+ _serializedWireFormat = SerializeToWriteFormat();
+ }
+
+ ///
+ /// Serializes some data members to wire format.
+ ///
+ private byte[] SerializeToWriteFormat()
+ {
+ int totalLength = 0;
+
+ // CipherAlgorithmId.
+ totalLength += sizeof(byte);
+
+ // Encryption Type.
+ totalLength += sizeof(byte);
+
+ // Database id of the encryption key.
+ totalLength += sizeof(int);
+
+ // Id of the encryption key.
+ totalLength += sizeof(int);
+
+ // Version of the encryption key.
+ totalLength += sizeof(int);
+
+ // Metadata version of the encryption key.
+ totalLength += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
+
+ // Normalization Rule Version.
+ totalLength += sizeof(byte);
+
+ byte[] serializedWireFormat = new byte[totalLength];
+
+ // No:of bytes consumed till now. Running variable.
+ int consumedBytes = 0;
+
+ // 1 - Write Cipher Algorithm Id.
+ serializedWireFormat[consumedBytes++] = _cipherMetadata.CipherAlgorithmId;
+
+ // 2 - Write Encryption Type.
+ serializedWireFormat[consumedBytes++] = _cipherMetadata.EncryptionType;
+
+ // 3 - Write the database id of the encryption key.
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.databaseId, serializedWireFormat, ref consumedBytes);
+
+ // 4 - Write the id of the encryption key.
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekId, serializedWireFormat, ref consumedBytes);
+
+ // 5 - Write the version of the encryption key.
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekVersion, serializedWireFormat, ref consumedBytes);
+
+ // 6 - Write the metadata version of the encryption key.
+ Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length);
+ consumedBytes += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
+
+ // 7 - Write Normalization Rule Version.
+ serializedWireFormat[consumedBytes++] = _cipherMetadata.NormalizationRuleVersion;
+
+ return serializedWireFormat;
+ }
+
+ ///
+ /// Serializes an int into the provided buffer and offset.
+ ///
+ private void SerializeIntIntoBuffer(int value, byte[] buffer, ref int offset)
+ {
+ buffer[offset++] = (byte)(value & 0xff);
+ buffer[offset++] = (byte)((value >> 8) & 0xff);
+ buffer[offset++] = (byte)((value >> 16) & 0xff);
+ buffer[offset++] = (byte)((value >> 24) & 0xff);
+ }
+ }
+}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index 079787506a..3b200f250b 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -80,224 +80,6 @@ internal class FederatedAuthenticationFeatureExtensionData
internal byte[] accessToken;
}
- ///
- /// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
- /// the store type, name,the key path and encryption algorithm.
- ///
- internal class SqlEncryptionKeyInfo
- {
- internal byte[] encryptedKey; // the encrypted "column encryption key"
- internal int databaseId;
- internal int cekId;
- internal int cekVersion;
- internal byte[] cekMdVersion;
- internal string keyPath;
- internal string keyStoreName;
- internal string algorithmName;
- internal byte normalizationRuleVersion;
- }
-
- ///
- /// Encapsulates one entry in the CipherInfo table sent as part of Colmetadata.
- /// The same CEK is encrypted multiple times with different master keys (for master key
- /// rotation scenario) We need to keep all these around until we can resolve the CEK
- /// using the correct master key.
- ///
- internal class SqlTceCipherInfoEntry
- {
-
- ///
- /// List of Column Encryption Key Information.
- ///
- private readonly List _columnEncryptionKeyValues;
-
- ///
- /// Key Ordinal.
- ///
- private readonly int _ordinal;
-
- ///
- /// Database ID
- ///
- private int _databaseId;
-
- ///
- /// Cek ID
- ///
- private int _cekId;
-
- ///
- /// Cek Version
- ///
- private int _cekVersion;
-
- ///
- /// Cek MD Version
- ///
- private byte[] _cekMdVersion;
-
- ///
- /// Return the ordinal.
- ///
- internal int Ordinal
- {
- get
- {
- return _ordinal;
- }
- }
-
- ///
- /// Return the DatabaseID.
- ///
- internal int DatabaseId
- {
- get
- {
- return _databaseId;
- }
- }
-
- ///
- /// Return the CEK ID.
- ///
- internal int CekId
- {
- get
- {
- return _cekId;
- }
- }
-
- ///
- /// Return the CEK Version.
- ///
- internal int CekVersion
- {
- get
- {
- return _cekVersion;
- }
- }
-
- ///
- /// Return the CEK MD Version.
- ///
- internal byte[] CekMdVersion
- {
- get
- {
- return _cekMdVersion;
- }
- }
-
- ///
- /// Return the list of Column Encryption Key Values.
- ///
- internal List ColumnEncryptionKeyValues
- {
- get
- {
- return _columnEncryptionKeyValues;
- }
- }
-
- ///
- /// Add an entry to the list of ColumnEncryptionKeyValues.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
- {
-
- Debug.Assert(_columnEncryptionKeyValues != null, "_columnEncryptionKeyValues should already be initialized.");
-
- SqlEncryptionKeyInfo encryptionKey = new SqlEncryptionKeyInfo();
- encryptionKey.encryptedKey = encryptedKey;
- encryptionKey.databaseId = databaseId;
- encryptionKey.cekId = cekId;
- encryptionKey.cekVersion = cekVersion;
- encryptionKey.cekMdVersion = cekMdVersion;
- encryptionKey.keyPath = keyPath;
- encryptionKey.keyStoreName = keyStoreName;
- encryptionKey.algorithmName = algorithmName;
- _columnEncryptionKeyValues.Add(encryptionKey);
-
- if (0 == _databaseId)
- {
- _databaseId = databaseId;
- _cekId = cekId;
- _cekVersion = cekVersion;
- _cekMdVersion = cekMdVersion;
- }
- else
- {
- Debug.Assert(_databaseId == databaseId);
- Debug.Assert(_cekId == cekId);
- Debug.Assert(_cekVersion == cekVersion);
- Debug.Assert(_cekMdVersion != null && cekMdVersion != null && _cekMdVersion.Length == _cekMdVersion.Length);
- }
- }
-
- ///
- /// Constructor.
- ///
- ///
- internal SqlTceCipherInfoEntry(int ordinal = 0)
- {
- _ordinal = ordinal;
- _databaseId = 0;
- _cekId = 0;
- _cekVersion = 0;
- _cekMdVersion = null;
- _columnEncryptionKeyValues = new List();
- }
- }
-
- ///
- /// Represents a table with various CEKs used in a resultset. Each entry corresponds to one (unique) CEK. The CEK
- /// may have been encrypted using multiple master keys (giving us multiple CEK values). All these values form one single
- /// entry in this table.
- ///
- internal class SqlTceCipherInfoTable
- {
- private readonly SqlTceCipherInfoEntry[] keyList;
-
- internal SqlTceCipherInfoTable(int tabSize)
- {
- Debug.Assert(0 < tabSize, "Invalid Table Size");
- keyList = new SqlTceCipherInfoEntry[tabSize];
- }
-
- internal SqlTceCipherInfoEntry this[int index]
- {
- get
- {
- Debug.Assert(index < keyList.Length, "Invalid index specified.");
- return keyList[index];
- }
- set
- {
- Debug.Assert(index < keyList.Length, "Invalid index specified.");
- keyList[index] = value;
- }
- }
-
- internal int Size
- {
- get
- {
- return keyList.Length;
- }
- }
- }
-
internal class RoutingInfo
{
internal byte Protocol { get; private set; }
@@ -511,19 +293,19 @@ public object Clone()
}
}
- sealed internal class _SqlMetaDataSet
+ internal sealed partial class _SqlMetaDataSet
{
internal ushort id; // for altrow-columns only
+
internal DataTable _schemaTable;
- internal readonly SqlTceCipherInfoTable cekTable; // table of "column encryption keys" used for this metadataset
internal readonly _SqlMetaData[] _metaDataArray;
+
private int _hiddenColumnCount;
private int[] _visibleColumnMap;
- internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
+ internal _SqlMetaDataSet(int count)
{
_hiddenColumnCount = -1;
- cekTable = cipherTable;
_metaDataArray = new _SqlMetaData[count];
for (int i = 0; i < _metaDataArray.Length; ++i)
{
@@ -688,194 +470,7 @@ public object Clone()
}
}
- ///
- /// Represents Encryption related information of the cipher data.
- ///
- internal class SqlCipherMetadata
- {
-
- ///
- /// Cipher Info Entry.
- ///
- private SqlTceCipherInfoEntry _sqlTceCipherInfoEntry;
-
- ///
- /// Encryption Algorithm Id.
- ///
- private readonly byte _cipherAlgorithmId;
-
- ///
- /// Encryption Algorithm Name.
- ///
- private readonly string _cipherAlgorithmName;
-
- ///
- /// Encryption Type.
- ///
- private readonly byte _encryptionType;
-
- ///
- /// Normalization Rule Version.
- ///
- private readonly byte _normalizationRuleVersion;
-
- ///
- /// Encryption Algorithm Handle.
- ///
- private SqlClientEncryptionAlgorithm _sqlClientEncryptionAlgorithm;
-
- ///
- /// Sql Encryption Key Info.
- ///
- private SqlEncryptionKeyInfo _sqlEncryptionKeyInfo;
-
- ///
- /// Ordinal (into the Cek Table).
- ///
- private readonly ushort _ordinal;
-
- ///
- /// Return the Encryption Info Entry.
- ///
- internal SqlTceCipherInfoEntry EncryptionInfo
- {
- get
- {
- return _sqlTceCipherInfoEntry;
- }
- set
- {
- Debug.Assert(_sqlTceCipherInfoEntry == null, "We can only set the EncryptionInfo once.");
- _sqlTceCipherInfoEntry = value;
- }
- }
-
- ///
- /// Return the cipher's encryption algorithm id.
- ///
- internal byte CipherAlgorithmId
- {
- get
- {
- return _cipherAlgorithmId;
- }
- }
-
- ///
- /// Return the cipher's encryption algorithm name (could be null).
- ///
- internal string CipherAlgorithmName
- {
- get
- {
- return _cipherAlgorithmName;
- }
- }
-
- ///
- /// Return EncryptionType (Deterministic, Randomized, etc.)
- ///
- internal byte EncryptionType
- {
- get
- {
- return _encryptionType;
- }
- }
-
- ///
- /// Return normalization rule version.
- ///
- internal byte NormalizationRuleVersion
- {
- get
- {
- return _normalizationRuleVersion;
- }
- }
-
- ///
- /// Return the cipher encyrption algorithm handle.
- ///
- internal SqlClientEncryptionAlgorithm CipherAlgorithm
- {
- get
- {
- return _sqlClientEncryptionAlgorithm;
- }
- set
- {
- Debug.Assert(_sqlClientEncryptionAlgorithm == null, "_sqlClientEncryptionAlgorithm should not be set more than once.");
- _sqlClientEncryptionAlgorithm = value;
- }
- }
-
- ///
- /// Return Encryption Key Info.
- ///
- internal SqlEncryptionKeyInfo EncryptionKeyInfo
- {
- get
- {
- return _sqlEncryptionKeyInfo;
- }
-
- set
- {
- Debug.Assert(_sqlEncryptionKeyInfo == null, "_sqlEncryptionKeyInfo should not be set more than once.");
- _sqlEncryptionKeyInfo = value;
- }
- }
-
- ///
- /// Return Ordinal into Cek Table.
- ///
- internal ushort CekTableOrdinal
- {
- get
- {
- return _ordinal;
- }
- }
-
- ///
- /// Constructor.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- internal SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
- ushort ordinal,
- byte cipherAlgorithmId,
- string cipherAlgorithmName,
- byte encryptionType,
- byte normalizationRuleVersion)
- {
- Debug.Assert(!sqlTceCipherInfoEntry.Equals(default(SqlTceCipherInfoEntry)), "sqlTceCipherInfoEntry should not be un-initialized.");
-
- _sqlTceCipherInfoEntry = sqlTceCipherInfoEntry;
- _ordinal = ordinal;
- _cipherAlgorithmId = cipherAlgorithmId;
- _cipherAlgorithmName = cipherAlgorithmName;
- _encryptionType = encryptionType;
- _normalizationRuleVersion = normalizationRuleVersion;
- _sqlEncryptionKeyInfo = null;
- }
-
- ///
- /// Do we have an handle to the cipher encryption algorithm already ?
- ///
- ///
- internal bool IsAlgorithmInitialized()
- {
- return (null != _sqlClientEncryptionAlgorithm) ? true : false;
- }
- }
-
- internal class SqlMetaDataPriv
+ internal partial class SqlMetaDataPriv
{
[Flags]
private enum SqlMetaDataPrivFlags : byte
@@ -898,10 +493,6 @@ private enum SqlMetaDataPrivFlags : byte
public SqlMetaDataUdt udt;
public SqlMetaDataXmlSchemaCollection xmlSchemaCollection;
- internal bool isEncrypted; // TCE encrypted?
- internal SqlMetaDataPriv baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
- internal SqlCipherMetadata cipherMD; // Cipher related metadata for encrypted columns.
-
internal SqlMetaDataPriv()
{
}
@@ -953,37 +544,6 @@ internal virtual void CopyFrom(SqlMetaDataPriv original)
xmlSchemaCollection.CopyFrom(original.xmlSchemaCollection);
}
}
-
- ///
- /// Is the algorithm handle for the cipher encryption initialized ?
- ///
- ///
- internal bool IsAlgorithmInitialized()
- {
- if (null != cipherMD)
- {
- return cipherMD.IsAlgorithmInitialized();
- }
-
- return false;
- }
-
- ///
- /// Returns the normalization rule version byte.
- ///
- ///
- internal byte NormalizationRuleVersion
- {
- get
- {
- if (null != cipherMD)
- {
- return cipherMD.NormalizationRuleVersion;
- }
-
- return 0x00;
- }
- }
}
sealed internal class SqlMetaDataXmlSchemaCollection
@@ -1024,137 +584,6 @@ public void CopyFrom(SqlMetaDataUdt original)
}
}
- ///
- /// Class encapsulating additional information when sending encrypted input parameters.
- ///
- sealed internal class SqlColumnEncryptionInputParameterInfo
- {
- ///
- /// Metadata of the parameter to write the TYPE_INFO of the unencrypted column data type.
- ///
- private readonly SmiParameterMetaData _smiParameterMetadata;
-
- ///
- /// Column encryption related metadata.
- ///
- private readonly SqlCipherMetadata _cipherMetadata;
-
- ///
- /// Serialized format for a subset of members.
- /// Does not include _smiParameterMetadata's serialization.
- ///
- private readonly byte[] _serializedWireFormat;
-
- ///
- /// Return the SMI Parameter Metadata.
- ///
- internal SmiParameterMetaData ParameterMetadata
- {
- get
- {
- return _smiParameterMetadata;
- }
- }
-
- ///
- /// Return the serialized format for some members.
- /// This is pre-calculated and cached since members are immutable.
- /// Does not include _smiParameterMetadata's serialization.
- ///
- internal byte[] SerializedWireFormat
- {
- get
- {
- return _serializedWireFormat;
- }
- }
-
- ///
- /// Constructor.
- ///
- ///
- ///
- internal SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
- {
- Debug.Assert(smiParameterMetadata != null, "smiParameterMetadata should not be null.");
- Debug.Assert(cipherMetadata != null, "cipherMetadata should not be null");
- Debug.Assert(cipherMetadata.EncryptionKeyInfo != null, "cipherMetadata.EncryptionKeyInfo.HasValue should be true.");
-
- _smiParameterMetadata = smiParameterMetadata;
- _cipherMetadata = cipherMetadata;
- _serializedWireFormat = SerializeToWriteFormat();
- }
-
- ///
- /// Serializes some data members to wire format.
- ///
- private byte[] SerializeToWriteFormat()
- {
- int totalLength = 0;
-
- // CipherAlgorithmId.
- totalLength += sizeof(byte);
-
- // Encryption Type.
- totalLength += sizeof(byte);
-
- // Database id of the encryption key.
- totalLength += sizeof(int);
-
- // Id of the encryption key.
- totalLength += sizeof(int);
-
- // Version of the encryption key.
- totalLength += sizeof(int);
-
- // Metadata version of the encryption key.
- totalLength += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
-
- // Normalization Rule Version.
- totalLength += sizeof(byte);
-
- byte[] serializedWireFormat = new byte[totalLength];
-
- // No:of bytes consumed till now. Running variable.
- int consumedBytes = 0;
-
- // 1 - Write Cipher Algorithm Id.
- serializedWireFormat[consumedBytes++] = _cipherMetadata.CipherAlgorithmId;
-
- // 2 - Write Encryption Type.
- serializedWireFormat[consumedBytes++] = _cipherMetadata.EncryptionType;
-
- // 3 - Write the database id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.databaseId, serializedWireFormat, ref consumedBytes);
-
- // 4 - Write the id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekId, serializedWireFormat, ref consumedBytes);
-
- // 5 - Write the version of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekVersion, serializedWireFormat, ref consumedBytes);
-
- // 6 - Write the metadata version of the encryption key.
- Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length);
- consumedBytes += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
-
- // 7 - Write Normalization Rule Version.
- serializedWireFormat[consumedBytes++] = _cipherMetadata.NormalizationRuleVersion;
-
- return serializedWireFormat;
- }
-
- ///
- /// Serializes an int into the provided buffer and offset.
- ///
- private void SerializeIntIntoBuffer(int value, byte[] buffer, ref int offset)
- {
- buffer[offset++] = (byte)(value & 0xff);
- buffer[offset++] = (byte)((value >> 8) & 0xff);
- buffer[offset++] = (byte)((value >> 16) & 0xff);
- buffer[offset++] = (byte)((value >> 24) & 0xff);
- }
- }
-
sealed internal class _SqlRPC
{
internal string rpcName;
From 152a3abf54e7533ad3435b8debb4f026a9c31580 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 06:41:30 +0000
Subject: [PATCH 02/14] Removed unused "normalizationRuleVersion" field from
SqlEncryptionKeyInfo - this isn't present in .NET Core and isn't used
---
.../src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
index dd3b6dfec5..657e77b638 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
@@ -24,7 +24,6 @@ internal class SqlEncryptionKeyInfo
internal string keyPath;
internal string keyStoreName;
internal string algorithmName;
- internal byte normalizationRuleVersion;
}
///
From fe0b79eb0c80f1a617c4837642591164eef3089e Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 06:48:32 +0000
Subject: [PATCH 03/14] Merged AlwaysEncryptedHelperClasses.cs
---
.../src/Microsoft.Data.SqlClient.csproj | 4 +-
.../netfx/src/Microsoft.Data.SqlClient.csproj | 6 +-
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 596 ------------------
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 0
4 files changed, 7 insertions(+), 599 deletions(-)
delete mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
rename src/Microsoft.Data.SqlClient/{netcore => }/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs (100%)
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 7a3a8e208f..00b4fae5dc 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -105,6 +105,9 @@
Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
+
+ Microsoft\Data\SqlClient\AlwaysEncryptedHelperClasses.cs
+
Microsoft\Data\SqlClient\ApplicationIntent.cs
@@ -628,7 +631,6 @@
-
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 21f8906838..8d03642393 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -172,6 +172,9 @@
Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
+
+ Microsoft\Data\SqlClient\AlwaysEncryptedHelperClasses.cs
+
Microsoft\Data\SqlClient\ApplicationIntent.cs
@@ -633,7 +636,6 @@
-
@@ -752,4 +754,4 @@
-
\ No newline at end of file
+
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
deleted file mode 100644
index 657e77b638..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
+++ /dev/null
@@ -1,596 +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.Collections.Generic;
-using System.Diagnostics;
-using Microsoft.Data.SqlClient.Server;
-
-namespace Microsoft.Data.SqlClient
-{
-
- ///
- /// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
- /// the store type, name,the key path and encryption algorithm.
- ///
- internal class SqlEncryptionKeyInfo
- {
- internal byte[] encryptedKey; // the encrypted "column encryption key"
- internal int databaseId;
- internal int cekId;
- internal int cekVersion;
- internal byte[] cekMdVersion;
- internal string keyPath;
- internal string keyStoreName;
- internal string algorithmName;
- }
-
- ///
- /// Encapsulates one entry in the CipherInfo table sent as part of Colmetadata.
- /// The same CEK is encrypted multiple times with different master keys (for master key
- /// rotation scenario) We need to keep all these around until we can resolve the CEK
- /// using the correct master key.
- ///
- internal class SqlTceCipherInfoEntry
- {
-
- ///
- /// List of Column Encryption Key Information.
- ///
- private readonly List _columnEncryptionKeyValues;
-
- ///
- /// Key Ordinal.
- ///
- private readonly int _ordinal;
-
- ///
- /// Database ID
- ///
- private int _databaseId;
-
- ///
- /// Cek ID
- ///
- private int _cekId;
-
- ///
- /// Cek Version
- ///
- private int _cekVersion;
-
- ///
- /// Cek MD Version
- ///
- private byte[] _cekMdVersion;
-
- ///
- /// Return the ordinal.
- ///
- internal int Ordinal
- {
- get
- {
- return _ordinal;
- }
- }
-
- ///
- /// Return the DatabaseID.
- ///
- internal int DatabaseId
- {
- get
- {
- return _databaseId;
- }
- }
-
- ///
- /// Return the CEK ID.
- ///
- internal int CekId
- {
- get
- {
- return _cekId;
- }
- }
-
- ///
- /// Return the CEK Version.
- ///
- internal int CekVersion
- {
- get
- {
- return _cekVersion;
- }
- }
-
- ///
- /// Return the CEK MD Version.
- ///
- internal byte[] CekMdVersion
- {
- get
- {
- return _cekMdVersion;
- }
- }
-
- ///
- /// Return the list of Column Encryption Key Values.
- ///
- internal List ColumnEncryptionKeyValues
- {
- get
- {
- return _columnEncryptionKeyValues;
- }
- }
-
- ///
- /// Add an entry to the list of ColumnEncryptionKeyValues.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
- {
-
- Debug.Assert(_columnEncryptionKeyValues != null, "_columnEncryptionKeyValues should already be initialized.");
-
- SqlEncryptionKeyInfo encryptionKey = new SqlEncryptionKeyInfo();
- encryptionKey.encryptedKey = encryptedKey;
- encryptionKey.databaseId = databaseId;
- encryptionKey.cekId = cekId;
- encryptionKey.cekVersion = cekVersion;
- encryptionKey.cekMdVersion = cekMdVersion;
- encryptionKey.keyPath = keyPath;
- encryptionKey.keyStoreName = keyStoreName;
- encryptionKey.algorithmName = algorithmName;
- _columnEncryptionKeyValues.Add(encryptionKey);
-
- if (0 == _databaseId)
- {
- _databaseId = databaseId;
- _cekId = cekId;
- _cekVersion = cekVersion;
- _cekMdVersion = cekMdVersion;
- }
- else
- {
- Debug.Assert(_databaseId == databaseId);
- Debug.Assert(_cekId == cekId);
- Debug.Assert(_cekVersion == cekVersion);
- Debug.Assert(_cekMdVersion != null && cekMdVersion != null && _cekMdVersion.Length == _cekMdVersion.Length);
- }
- }
-
- ///
- /// Constructor.
- ///
- ///
- internal SqlTceCipherInfoEntry(int ordinal = 0)
- {
- _ordinal = ordinal;
- _databaseId = 0;
- _cekId = 0;
- _cekVersion = 0;
- _cekMdVersion = null;
- _columnEncryptionKeyValues = new List();
- }
- }
-
- ///
- /// Represents a table with various CEKs used in a resultset. Each entry corresponds to one (unique) CEK. The CEK
- /// may have been encrypted using multiple master keys (giving us multiple CEK values). All these values form one single
- /// entry in this table.
- ///
- internal class SqlTceCipherInfoTable
- {
- private readonly SqlTceCipherInfoEntry[] keyList;
-
- internal SqlTceCipherInfoTable(int tabSize)
- {
- Debug.Assert(0 < tabSize, "Invalid Table Size");
- keyList = new SqlTceCipherInfoEntry[tabSize];
- }
-
- internal SqlTceCipherInfoEntry this[int index]
- {
- get
- {
- Debug.Assert(index < keyList.Length, "Invalid index specified.");
- return keyList[index];
- }
- set
- {
- Debug.Assert(index < keyList.Length, "Invalid index specified.");
- keyList[index] = value;
- }
- }
-
- internal int Size
- {
- get
- {
- return keyList.Length;
- }
- }
- }
-
- sealed internal partial class _SqlMetaDataSet
- {
- internal readonly SqlTceCipherInfoTable cekTable; // table of "column encryption keys" used for this metadataset
-
- internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
- : this(count)
- {
- cekTable = cipherTable;
- }
- }
-
- ///
- /// Represents Encryption related information of the cipher data.
- ///
- internal class SqlCipherMetadata
- {
-
- ///
- /// Cipher Info Entry.
- ///
- private SqlTceCipherInfoEntry _sqlTceCipherInfoEntry;
-
- ///
- /// Encryption Algorithm Id.
- ///
- private readonly byte _cipherAlgorithmId;
-
- ///
- /// Encryption Algorithm Name.
- ///
- private readonly string _cipherAlgorithmName;
-
- ///
- /// Encryption Type.
- ///
- private readonly byte _encryptionType;
-
- ///
- /// Normalization Rule Version.
- ///
- private readonly byte _normalizationRuleVersion;
-
- ///
- /// Encryption Algorithm Handle.
- ///
- private SqlClientEncryptionAlgorithm _sqlClientEncryptionAlgorithm;
-
- ///
- /// Sql Encryption Key Info.
- ///
- private SqlEncryptionKeyInfo _sqlEncryptionKeyInfo;
-
- ///
- /// Ordinal (into the Cek Table).
- ///
- private readonly ushort _ordinal;
-
- ///
- /// Return the Encryption Info Entry.
- ///
- internal SqlTceCipherInfoEntry EncryptionInfo
- {
- get
- {
- return _sqlTceCipherInfoEntry;
- }
- set
- {
- Debug.Assert(_sqlTceCipherInfoEntry == null, "We can only set the EncryptionInfo once.");
- _sqlTceCipherInfoEntry = value;
- }
- }
-
- ///
- /// Return the cipher's encryption algorithm id.
- ///
- internal byte CipherAlgorithmId
- {
- get
- {
- return _cipherAlgorithmId;
- }
- }
-
- ///
- /// Return the cipher's encryption algorithm name (could be null).
- ///
- internal string CipherAlgorithmName
- {
- get
- {
- return _cipherAlgorithmName;
- }
- }
-
- ///
- /// Return EncryptionType (Deterministic, Randomized, etc.)
- ///
- internal byte EncryptionType
- {
- get
- {
- return _encryptionType;
- }
- }
-
- ///
- /// Return normalization rule version.
- ///
- internal byte NormalizationRuleVersion
- {
- get
- {
- return _normalizationRuleVersion;
- }
- }
-
- ///
- /// Return the cipher encryption algorithm handle.
- ///
- internal SqlClientEncryptionAlgorithm CipherAlgorithm
- {
- get
- {
- return _sqlClientEncryptionAlgorithm;
- }
- set
- {
- Debug.Assert(_sqlClientEncryptionAlgorithm == null, "_sqlClientEncryptionAlgorithm should not be set more than once.");
- _sqlClientEncryptionAlgorithm = value;
- }
- }
-
- ///
- /// Return Encryption Key Info.
- ///
- internal SqlEncryptionKeyInfo EncryptionKeyInfo
- {
- get
- {
- return _sqlEncryptionKeyInfo;
- }
-
- set
- {
- Debug.Assert(_sqlEncryptionKeyInfo == null, "_sqlEncryptionKeyInfo should not be set more than once.");
- _sqlEncryptionKeyInfo = value;
- }
- }
-
- ///
- /// Return Ordinal into Cek Table.
- ///
- internal ushort CekTableOrdinal
- {
- get
- {
- return _ordinal;
- }
- }
-
- ///
- /// Constructor.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- internal SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
- ushort ordinal,
- byte cipherAlgorithmId,
- string cipherAlgorithmName,
- byte encryptionType,
- byte normalizationRuleVersion)
- {
- Debug.Assert(!sqlTceCipherInfoEntry.Equals(default(SqlTceCipherInfoEntry)), "sqlTceCipherInfoEntry should not be un-initialized.");
-
- _sqlTceCipherInfoEntry = sqlTceCipherInfoEntry;
- _ordinal = ordinal;
- _cipherAlgorithmId = cipherAlgorithmId;
- _cipherAlgorithmName = cipherAlgorithmName;
- _encryptionType = encryptionType;
- _normalizationRuleVersion = normalizationRuleVersion;
- _sqlEncryptionKeyInfo = null;
- }
-
- ///
- /// Do we have an handle to the cipher encryption algorithm already ?
- ///
- ///
- internal bool IsAlgorithmInitialized()
- {
- return (null != _sqlClientEncryptionAlgorithm) ? true : false;
- }
- }
-
- internal partial class SqlMetaDataPriv
- {
- internal bool isEncrypted; // TCE encrypted?
- internal SqlMetaDataPriv baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
- internal SqlCipherMetadata cipherMD; // Cipher related metadata for encrypted columns.
-
- ///
- /// Is the algorithm handle for the cipher encryption initialized ?
- ///
- ///
- internal bool IsAlgorithmInitialized()
- {
- if (null != cipherMD)
- {
- return cipherMD.IsAlgorithmInitialized();
- }
-
- return false;
- }
-
- ///
- /// Returns the normalization rule version byte.
- ///
- ///
- internal byte NormalizationRuleVersion
- {
- get
- {
- if (null != cipherMD)
- {
- return cipherMD.NormalizationRuleVersion;
- }
-
- return 0x00;
- }
- }
- }
-
- ///
- /// Class encapsulating additional information when sending encrypted input parameters.
- ///
- sealed internal class SqlColumnEncryptionInputParameterInfo
- {
- ///
- /// Metadata of the parameter to write the TYPE_INFO of the unencrypted column data type.
- ///
- private readonly SmiParameterMetaData _smiParameterMetadata;
-
- ///
- /// Column encryption related metadata.
- ///
- private readonly SqlCipherMetadata _cipherMetadata;
-
- ///
- /// Serialized format for a subset of members.
- /// Does not include _smiParameterMetadata's serialization.
- ///
- private readonly byte[] _serializedWireFormat;
-
- ///
- /// Return the SMI Parameter Metadata.
- ///
- internal SmiParameterMetaData ParameterMetadata
- {
- get
- {
- return _smiParameterMetadata;
- }
- }
-
- ///
- /// Return the serialized format for some members.
- /// This is pre-calculated and cached since members are immutable.
- /// Does not include _smiParameterMetadata's serialization.
- ///
- internal byte[] SerializedWireFormat
- {
- get
- {
- return _serializedWireFormat;
- }
- }
-
- ///
- /// Constructor.
- ///
- ///
- ///
- internal SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
- {
- Debug.Assert(smiParameterMetadata != null, "smiParameterMetadata should not be null.");
- Debug.Assert(cipherMetadata != null, "cipherMetadata should not be null");
- Debug.Assert(cipherMetadata.EncryptionKeyInfo != null, "cipherMetadata.EncryptionKeyInfo.HasValue should be true.");
-
- _smiParameterMetadata = smiParameterMetadata;
- _cipherMetadata = cipherMetadata;
- _serializedWireFormat = SerializeToWriteFormat();
- }
-
- ///
- /// Serializes some data members to wire format.
- ///
- private byte[] SerializeToWriteFormat()
- {
- int totalLength = 0;
-
- // CipherAlgorithmId.
- totalLength += sizeof(byte);
-
- // Encryption Type.
- totalLength += sizeof(byte);
-
- // Database id of the encryption key.
- totalLength += sizeof(int);
-
- // Id of the encryption key.
- totalLength += sizeof(int);
-
- // Version of the encryption key.
- totalLength += sizeof(int);
-
- // Metadata version of the encryption key.
- totalLength += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
-
- // Normalization Rule Version.
- totalLength += sizeof(byte);
-
- byte[] serializedWireFormat = new byte[totalLength];
-
- // No:of bytes consumed till now. Running variable.
- int consumedBytes = 0;
-
- // 1 - Write Cipher Algorithm Id.
- serializedWireFormat[consumedBytes++] = _cipherMetadata.CipherAlgorithmId;
-
- // 2 - Write Encryption Type.
- serializedWireFormat[consumedBytes++] = _cipherMetadata.EncryptionType;
-
- // 3 - Write the database id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.databaseId, serializedWireFormat, ref consumedBytes);
-
- // 4 - Write the id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekId, serializedWireFormat, ref consumedBytes);
-
- // 5 - Write the version of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekVersion, serializedWireFormat, ref consumedBytes);
-
- // 6 - Write the metadata version of the encryption key.
- Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length);
- consumedBytes += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
-
- // 7 - Write Normalization Rule Version.
- serializedWireFormat[consumedBytes++] = _cipherMetadata.NormalizationRuleVersion;
-
- return serializedWireFormat;
- }
-
- ///
- /// Serializes an int into the provided buffer and offset.
- ///
- private void SerializeIntIntoBuffer(int value, byte[] buffer, ref int offset)
- {
- buffer[offset++] = (byte)(value & 0xff);
- buffer[offset++] = (byte)((value >> 8) & 0xff);
- buffer[offset++] = (byte)((value >> 16) & 0xff);
- buffer[offset++] = (byte)((value >> 24) & 0xff);
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
From c0859819692918864c9ae23f8bf884a49e4fbc51 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 07:42:13 +0000
Subject: [PATCH 04/14] Updated merged file to fit coding-style.md. Renaming
internally-accessible fields has generated most of these changes
---
.../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 22 ++--
.../Microsoft/Data/SqlClient/SqlCommand.cs | 6 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 98 ++++++++--------
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 110 +++++++++---------
.../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 24 ++--
.../Microsoft/Data/SqlClient/SqlCommand.cs | 6 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 98 ++++++++--------
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 110 +++++++++---------
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 88 +++++++-------
.../Data/SqlClient/EnclaveDelegate.cs | 6 +-
.../Data/SqlClient/SqlQueryMetadataCache.cs | 4 +-
.../Data/SqlClient/SqlSecurityUtility.cs | 16 +--
.../Data/SqlClient/SqlSymmetricKeyCache.cs | 18 +--
13 files changed, 303 insertions(+), 303 deletions(-)
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
index 273394395a..12364261b5 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
@@ -1466,13 +1466,13 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
byte scale = metadata.scale;
byte precision = metadata.precision;
int length = metadata.length;
- if (metadata.isEncrypted)
+ if (metadata._isEncrypted)
{
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- type = metadata.baseTI.metaType;
- scale = metadata.baseTI.scale;
- precision = metadata.baseTI.precision;
- length = metadata.baseTI.length;
+ type = metadata._baseTI.metaType;
+ scale = metadata._baseTI.scale;
+ precision = metadata._baseTI.precision;
+ length = metadata._baseTI.length;
}
try
@@ -1513,7 +1513,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
}
catch (SqlTruncateException)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
}
}
@@ -1558,7 +1558,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
int maxStringLength = length / 2;
if (str.Length > maxStringLength)
{
- if (metadata.isEncrypted)
+ if (metadata._isEncrypted)
{
str = "";
}
@@ -1602,7 +1602,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
default:
Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), null);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), null);
}
if (typeChanged)
@@ -1619,7 +1619,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
throw;
}
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), e);
}
}
@@ -2167,7 +2167,7 @@ private Task ReadWriteColumnValueAsync(int col)
// If column encryption is requested via connection string option, perform encryption here
if (!isNull && // if value is not NULL
- metadata.isEncrypted)
+ metadata._isEncrypted)
{ // If we are transparently encrypting
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
value = _parser.EncryptColumnValue(value, metadata, metadata.column, _stateObj, isDataFeed, isSqlType);
@@ -2185,7 +2185,7 @@ private Task ReadWriteColumnValueAsync(int col)
else
{
// Target type shouldn't be encrypted
- Debug.Assert(!metadata.isEncrypted, "Can't encrypt SQL Variant type");
+ Debug.Assert(!metadata._isEncrypted, "Can't encrypt SQL Variant type");
SqlBuffer.StorageType variantInternalType = SqlBuffer.StorageType.Empty;
if ((_sqlDataReaderRowSource != null) && (_connection.Is2008OrNewer))
{
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
index 39dbb917e0..ced7863f55 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
@@ -5688,7 +5688,7 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
{
// If the parameter's direction is InputOutput, Output or ReturnValue and it needs to be transparently encrypted/decrypted
// then simply decrypt, deserialize and set the value.
- if (rec.cipherMD != null &&
+ if (rec._cipherMD != null &&
thisParam.CipherMetadata != null &&
(thisParam.Direction == ParameterDirection.Output ||
thisParam.Direction == ParameterDirection.InputOutput ||
@@ -5713,8 +5713,8 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
Debug.Assert(_activeConnection != null, @"_activeConnection should not be null");
// Get the key information from the parameter and decrypt the value.
- rec.cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec.cipherMD, _activeConnection, this);
+ rec._cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec._cipherMD, _activeConnection, this);
if (unencryptedBytes != null)
{
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
index 5eb7d7cdeb..cb059d4e05 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
@@ -542,10 +542,10 @@ internal DataTable BuildSchemaTable()
// col.length is always byte count so for unicode types, half the length
//
// For MAX and XML datatypes, we get 0x7fffffff from the server. Do not divide this.
- if (col.cipherMD != null)
+ if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null && col.baseTI.metaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
- schemaRow[size] = (col.baseTI.metaType.IsSizeInCharacters && (col.baseTI.length != 0x7fffffff)) ? (col.baseTI.length / 2) : col.baseTI.length;
+ Debug.Assert(col._baseTI != null && col._baseTI.metaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
+ schemaRow[size] = (col._baseTI.metaType.IsSizeInCharacters && (col._baseTI.length != 0x7fffffff)) ? (col._baseTI.length / 2) : col._baseTI.length;
}
else
{
@@ -554,7 +554,7 @@ internal DataTable BuildSchemaTable()
schemaRow[dataType] = GetFieldTypeInternal(col);
schemaRow[providerSpecificDataType] = GetProviderSpecificFieldTypeInternal(col);
- schemaRow[nonVersionedProviderType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type); // SqlDbType enum value - does not change with TypeSystem.
+ schemaRow[nonVersionedProviderType] = (int)(col._cipherMD != null ? col._baseTI.type : col.type); // SqlDbType enum value - does not change with TypeSystem.
schemaRow[dataTypeName] = GetDataTypeNameInternal(col);
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.Is2008DateTimeType)
@@ -596,7 +596,7 @@ internal DataTable BuildSchemaTable()
// TypeSystem.SQLServer2005 and above
// SqlDbType enum value - always the actual type for SQLServer2005.
- schemaRow[providerType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type);
+ schemaRow[providerType] = (int)(col._cipherMD != null ? col._baseTI.type : col.type);
if (col.type == SqlDbType.Udt)
{ // Additional metadata for UDTs.
@@ -619,16 +619,16 @@ internal DataTable BuildSchemaTable()
schemaRow[providerType] = GetVersionedMetaType(col.metaType).SqlDbType;
}
- if (col.cipherMD != null)
+ if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.precision)
+ Debug.Assert(col._baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col._baseTI.precision)
{
- schemaRow[precision] = col.baseTI.precision;
+ schemaRow[precision] = col._baseTI.precision;
}
else
{
- schemaRow[precision] = col.baseTI.metaType.Precision;
+ schemaRow[precision] = col._baseTI.metaType.Precision;
}
}
else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.precision)
@@ -644,16 +644,16 @@ internal DataTable BuildSchemaTable()
{
schemaRow[scale] = MetaType.MetaNVarChar.Scale;
}
- else if (col.cipherMD != null)
+ else if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.scale)
+ Debug.Assert(col._baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col._baseTI.scale)
{
- schemaRow[scale] = col.baseTI.scale;
+ schemaRow[scale] = col._baseTI.scale;
}
else
{
- schemaRow[scale] = col.baseTI.metaType.Scale;
+ schemaRow[scale] = col._baseTI.metaType.Scale;
}
}
else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale)
@@ -679,11 +679,11 @@ internal DataTable BuildSchemaTable()
schemaRow[isIdentity] = col.IsIdentity;
schemaRow[isAutoIncrement] = col.IsIdentity;
- if (col.cipherMD != null)
+ if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
- Debug.Assert(col.baseTI.metaType != null, @"col.baseTI.metaType should not be null.");
- schemaRow[isLong] = col.baseTI.metaType.IsLong;
+ Debug.Assert(col._baseTI != null, @"col.baseTI should not be null.");
+ Debug.Assert(col._baseTI.metaType != null, @"col.baseTI.metaType should not be null.");
+ schemaRow[isLong] = col._baseTI.metaType.IsLong;
}
else
{
@@ -1201,10 +1201,10 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- dataTypeName = metaData.baseTI.metaType.TypeName;
+ Debug.Assert(metaData._baseTI != null && metaData._baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ dataTypeName = metaData._baseTI.metaType.TypeName;
}
else
{
@@ -1292,10 +1292,10 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- fieldType = metaData.baseTI.metaType.ClassType;
+ Debug.Assert(metaData._baseTI != null && metaData._baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ fieldType = metaData._baseTI.metaType.ClassType;
}
else
{
@@ -1317,13 +1317,13 @@ virtual internal int GetLocaleId(int i)
_SqlMetaData sqlMetaData = MetaData[i];
int lcid;
- if (sqlMetaData.cipherMD != null)
+ if (sqlMetaData._cipherMD != null)
{
// If this column is encrypted, get the collation from baseTI
//
- if (sqlMetaData.baseTI.collation != null)
+ if (sqlMetaData._baseTI.collation != null)
{
- lcid = sqlMetaData.baseTI.collation.LCID;
+ lcid = sqlMetaData._baseTI.collation.LCID;
}
else
{
@@ -1406,11 +1406,11 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
else
{
// For all other types, including Xml - use data in MetaType.
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null,
+ Debug.Assert(metaData._baseTI != null && metaData._baseTI.metaType != null,
"metaData.baseTI and metaData.baseTI.metaType should not be null.");
- providerSpecificFieldType = metaData.baseTI.metaType.SqlType; // SqlType type.
+ providerSpecificFieldType = metaData._baseTI.metaType.SqlType; // SqlType type.
}
else
{
@@ -1539,7 +1539,7 @@ override public Stream GetStream(int i)
CheckDataIsReady(columnIndex: i);
// Streaming is not supported on encrypted columns.
- if (_metaData[i] != null && _metaData[i].cipherMD != null)
+ if (_metaData[i] != null && _metaData[i]._cipherMD != null)
{
throw SQL.StreamNotSupportOnEncryptedColumn(_metaData[i].column);
}
@@ -1647,7 +1647,7 @@ private bool TryGetBytesInternal(int i, long dataIndex, byte[] buffer, int buffe
{
Debug.Assert(!HasActiveStreamOrTextReaderOnColumn(i), "Column has an active Stream or TextReader");
- if (_metaData[i] != null && _metaData[i].cipherMD != null)
+ if (_metaData[i] != null && _metaData[i]._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
@@ -1940,10 +1940,10 @@ override public TextReader GetTextReader(int i)
// Xml type is not supported
MetaType mt = null;
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
- Debug.Assert(_metaData[i].baseTI != null, "_metaData[i].baseTI should not be null.");
- mt = _metaData[i].baseTI.metaType;
+ Debug.Assert(_metaData[i]._baseTI != null, "_metaData[i].baseTI should not be null.");
+ mt = _metaData[i]._baseTI.metaType;
}
else
{
@@ -1960,7 +1960,7 @@ override public TextReader GetTextReader(int i)
// For non-variant types with sequential access, we support proper streaming
if ((mt.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)))
{
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
@@ -2021,10 +2021,10 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
}
MetaType mt = null;
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
- Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
- mt = _metaData[i].baseTI.metaType;
+ Debug.Assert(_metaData[i]._baseTI != null, @"_metaData[i].baseTI should not be null.");
+ mt = _metaData[i]._baseTI.metaType;
}
else
{
@@ -2034,10 +2034,10 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
Debug.Assert(mt != null, "mt should not be null.");
SqlDbType sqlDbType;
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
- Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
- sqlDbType = _metaData[i].baseTI.type;
+ Debug.Assert(_metaData[i]._baseTI != null, @"_metaData[i].baseTI should not be null.");
+ sqlDbType = _metaData[i]._baseTI.type;
}
else
{
@@ -2056,7 +2056,7 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
throw ADP.InvalidDataLength(length);
}
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
@@ -2905,10 +2905,10 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// Xml type is not supported
MetaType metaType = metaData.metaType;
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null, "_metaData[i].baseTI should not be null.");
- metaType = metaData.baseTI.metaType;
+ Debug.Assert(metaData._baseTI != null, "_metaData[i].baseTI should not be null.");
+ metaType = metaData._baseTI.metaType;
}
if (
@@ -2922,7 +2922,7 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
// For non-variant types with sequential access, we support proper streaming
if ((metaType.SqlDbType != SqlDbType.Variant) && IsCommandBehavior(CommandBehavior.SequentialAccess))
{
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(metaData.column);
}
@@ -2946,7 +2946,7 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
}
else if (typeof(T) == typeof(Stream))
{
- if (metaData != null && metaData.cipherMD != null)
+ if (metaData != null && metaData._cipherMD != null)
{
throw SQL.StreamNotSupportOnEncryptedColumn(metaData.column);
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
index 7e04f6b9c5..33234630de 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -4062,7 +4062,7 @@ internal bool TryProcessReturnValue(int length, TdsParserStateObject stateObj, o
// Check if the column is encrypted.
if (IsColumnEncryptionSupported)
{
- rec.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ rec._isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// read the type
@@ -4220,7 +4220,7 @@ internal bool TryProcessReturnValue(int length, TdsParserStateObject stateObj, o
}
// For encrypted parameters, read the unencrypted type and encryption information.
- if (IsColumnEncryptionSupported && rec.isEncrypted)
+ if (IsColumnEncryptionSupported && rec._isEncrypted)
{
if (!TryProcessTceCryptoMetadata(stateObj, rec, cipherTable: null, columnEncryptionSetting: columnEncryptionSetting, isReturnValue: true))
{
@@ -4299,8 +4299,8 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
}
// Read the base TypeInfo
- col.baseTI = new SqlMetaDataPriv();
- if (!TryProcessTypeInfo(stateObj, col.baseTI, userType))
+ col._baseTI = new SqlMetaDataPriv();
+ if (!TryProcessTypeInfo(stateObj, col._baseTI, userType))
{
return false;
}
@@ -4342,7 +4342,7 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
return false;
}
- Debug.Assert(col.cipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
+ Debug.Assert(col._cipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
// Check if TCE is enable and if it is set the crypto MD for the column.
// TCE is enabled if the command is set to enabled or to resultset only and this is not a return value
@@ -4353,7 +4353,7 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
_connHandler != null && _connHandler.ConnectionOptions != null &&
_connHandler.ConnectionOptions.ColumnEncryptionSetting == SqlConnectionColumnEncryptionSetting.Enabled))
{
- col.cipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
+ col._cipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
index,
cipherAlgorithmId: cipherAlgorithmId,
cipherAlgorithmName: cipherAlgorithmName,
@@ -4363,7 +4363,7 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
else
{
// If TCE is disabled mark the MD as not encrypted.
- col.isEncrypted = false;
+ col._isEncrypted = false;
}
return true;
@@ -5040,7 +5040,7 @@ private bool TryCommonProcessMetaData(TdsParserStateObject stateObj, _SqlMetaDat
if (fColMD && IsColumnEncryptionSupported)
{
- col.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ col._isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// Read TypeInfo
@@ -5060,7 +5060,7 @@ private bool TryCommonProcessMetaData(TdsParserStateObject stateObj, _SqlMetaDat
}
// Read the TCE column cryptoinfo
- if (fColMD && IsColumnEncryptionSupported && col.isEncrypted)
+ if (fColMD && IsColumnEncryptionSupported && col._isEncrypted)
{
// If the column is encrypted, we should have a valid cipherTable
if (cipherTable != null && !TryProcessTceCryptoMetadata(stateObj, col, cipherTable, columnEncryptionSetting, isReturnValue: false))
@@ -5480,10 +5480,10 @@ internal static object GetNullSqlValue(SqlBuffer nullVal, SqlMetaDataPriv md, Sq
SqlDbType type = md.type;
if (type == SqlDbType.VarBinary && // if its a varbinary
- md.isEncrypted &&// and encrypted
+ md._isEncrypted &&// and encrypted
ShouldHonorTceForRead(columnEncryptionSetting, connection))
{
- type = md.baseTI.type; // the use the actual (plaintext) type
+ type = md._baseTI.type; // the use the actual (plaintext) type
}
switch (type)
@@ -5791,14 +5791,14 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
throw SQL.UnsupportedNormalizationVersion(normalizationVersion);
}
- byte tdsType = md.baseTI.tdsType;
+ byte tdsType = md._baseTI.tdsType;
int length = unencryptedBytes.Length;
// For normalized types, the length and scale of the actual type might be different than the value's.
- int denormalizedLength = md.baseTI.length;
- byte denormalizedScale = md.baseTI.scale;
+ int denormalizedLength = md._baseTI.length;
+ byte denormalizedScale = md._baseTI.scale;
- Debug.Assert(false == md.baseTI.isEncrypted, "Double encryption detected");
+ Debug.Assert(false == md._baseTI._isEncrypted, "Double encryption detected");
//DEVNOTE: When modifying the following routines (for deserialization) please pay attention to
// deserialization code in DecryptWithKey () method and modify it accordingly.
switch (tdsType)
@@ -5948,7 +5948,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with zeros to get to the fixed length size.
if (tdsType == TdsEnums.SQLBINARY || tdsType == TdsEnums.SQLBIGBINARY)
{
- byte[] bytes = new byte[md.baseTI.length];
+ byte[] bytes = new byte[md._baseTI.length];
Buffer.BlockCopy(unencryptedBytes, 0, bytes, 0, unencryptedBytes.Length);
unencryptedBytes = bytes;
}
@@ -5975,7 +5975,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
bits[i] = BinaryPrimitives.ReadInt32LittleEndian(span.Slice(index));
index += 4;
}
- value.SetToDecimal(md.baseTI.precision, md.baseTI.scale, fPositive, bits);
+ value.SetToDecimal(md._baseTI.precision, md._baseTI.scale, fPositive, bits);
break;
case TdsEnums.SQLCHAR:
@@ -5984,7 +5984,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
case TdsEnums.SQLBIGVARCHAR:
case TdsEnums.SQLTEXT:
{
- System.Text.Encoding encoding = md.baseTI.encoding;
+ System.Text.Encoding encoding = md._baseTI.encoding;
if (null == encoding)
{
@@ -6001,7 +6001,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLCHAR || tdsType == TdsEnums.SQLBIGCHAR)
{
- strValue = strValue.PadRight(md.baseTI.length);
+ strValue = strValue.PadRight(md._baseTI.length);
}
value.SetToString(strValue);
@@ -6017,7 +6017,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLNCHAR)
{
- strValue = strValue.PadRight(md.baseTI.length / ADP.CharSize);
+ strValue = strValue.PadRight(md._baseTI.length / ADP.CharSize);
}
value.SetToString(strValue);
@@ -6048,7 +6048,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
break;
default:
- MetaType metaType = md.baseTI.metaType;
+ MetaType metaType = md._baseTI.metaType;
// If we don't have a metatype already, construct one to get the proper type name.
if (metaType == null)
@@ -6115,7 +6115,7 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
}
}
- if (md.isEncrypted
+ if (md._isEncrypted
&& (columnEncryptionOverride == SqlCommandColumnEncryptionSetting.Enabled
|| columnEncryptionOverride == SqlCommandColumnEncryptionSetting.ResultSetOnly
|| (columnEncryptionOverride == SqlCommandColumnEncryptionSetting.UseConnectionSetting
@@ -6125,7 +6125,7 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
try
{
// CipherInfo is present, decrypt and read
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md.cipherMD, _connHandler.Connection, command);
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md._cipherMD, _connHandler.Connection, command);
if (unencryptedBytes != null)
{
@@ -10412,9 +10412,9 @@ internal void LoadColumnEncryptionKeys(_SqlMetaDataSet metadataCollection, SqlCo
if (null != metadataCollection[col])
{
_SqlMetaData md = metadataCollection[col];
- if (md.isEncrypted)
+ if (md._isEncrypted)
{
- SqlSecurityUtility.DecryptSymmetricKey(md.cipherMD, connection, command);
+ SqlSecurityUtility.DecryptSymmetricKey(md._cipherMD, connection, command);
}
}
}
@@ -10462,14 +10462,14 @@ internal void WriteCekTable(_SqlMetaDataSet metadataCollection, TdsParserStateOb
// Note- Cek table (with 0 entries) will be present if TCE
// was enabled and server supports it!
// OR if encryption was disabled in connection options
- if (metadataCollection.cekTable == null ||
+ if (metadataCollection._cekTable == null ||
!ShouldEncryptValuesForBulkCopy())
{
WriteShort(0x00, stateObj);
return;
}
- SqlTceCipherInfoTable cekTable = metadataCollection.cekTable;
+ SqlTceCipherInfoTable cekTable = metadataCollection._cekTable;
ushort count = (ushort)cekTable.Size;
WriteShort(count, stateObj);
@@ -10524,34 +10524,34 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
internal void WriteCryptoMetadata(_SqlMetaData md, TdsParserStateObject stateObj)
{
if (!IsColumnEncryptionSupported || // TCE Feature supported
- !md.isEncrypted || // Column is not encrypted
+ !md._isEncrypted || // Column is not encrypted
!ShouldEncryptValuesForBulkCopy())
{ // TCE disabled on connection string
return;
}
// Write the ordinal
- WriteShort(md.cipherMD.CekTableOrdinal, stateObj);
+ WriteShort(md._cipherMD.CekTableOrdinal, stateObj);
// Write UserType and TYPEINFO
- WriteTceUserTypeAndTypeInfo(md.baseTI, stateObj);
+ WriteTceUserTypeAndTypeInfo(md._baseTI, stateObj);
// Write Encryption Algo
- stateObj.WriteByte(md.cipherMD.CipherAlgorithmId);
+ stateObj.WriteByte(md._cipherMD.CipherAlgorithmId);
- if (TdsEnums.CustomCipherAlgorithmId == md.cipherMD.CipherAlgorithmId)
+ if (TdsEnums.CustomCipherAlgorithmId == md._cipherMD.CipherAlgorithmId)
{
// Write the algorithm name
- Debug.Assert(md.cipherMD.CipherAlgorithmName.Length < 256);
- stateObj.WriteByte((byte)md.cipherMD.CipherAlgorithmName.Length);
- WriteString(md.cipherMD.CipherAlgorithmName, stateObj);
+ Debug.Assert(md._cipherMD.CipherAlgorithmName.Length < 256);
+ stateObj.WriteByte((byte)md._cipherMD.CipherAlgorithmName.Length);
+ WriteString(md._cipherMD.CipherAlgorithmName, stateObj);
}
// Write Encryption Algo Type
- stateObj.WriteByte(md.cipherMD.EncryptionType);
+ stateObj.WriteByte(md._cipherMD.EncryptionType);
// Write Normalization Version
- stateObj.WriteByte(md.cipherMD.NormalizationRuleVersion);
+ stateObj.WriteByte(md._cipherMD.NormalizationRuleVersion);
}
internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int count, TdsParserStateObject stateObj)
@@ -10587,7 +10587,7 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
{ // TCE Supported
if (ShouldEncryptValuesForBulkCopy())
{ // TCE enabled on connection options
- flags |= (UInt16)(md.isEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
+ flags |= (UInt16)(md._isEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
}
}
@@ -10674,7 +10674,7 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
}
int actualLengthInBytes;
- switch (metadata.baseTI.metaType.NullableType)
+ switch (metadata._baseTI.metaType.NullableType)
{
case TdsEnums.SQLBIGBINARY:
case TdsEnums.SQLBIGVARBINARY:
@@ -10689,11 +10689,11 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
// to report the size of data to be copied out (for serialization). If we underreport the
// size, truncation will happen for us!
actualLengthInBytes = (isSqlType) ? ((SqlBinary)value).Length : ((byte[])value).Length;
- if (metadata.baseTI.length > 0 &&
- actualLengthInBytes > metadata.baseTI.length)
+ if (metadata._baseTI.length > 0 &&
+ actualLengthInBytes > metadata._baseTI.length)
{
// see comments above
- actualLengthInBytes = metadata.baseTI.length;
+ actualLengthInBytes = metadata._baseTI.length;
}
break;
@@ -10712,10 +10712,10 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
actualLengthInBytes = _defaultEncoding.GetByteCount(stringValue);
// If the string length is > max length, then use the max length (see comments above)
- if (metadata.baseTI.length > 0 &&
- actualLengthInBytes > metadata.baseTI.length)
+ if (metadata._baseTI.length > 0 &&
+ actualLengthInBytes > metadata._baseTI.length)
{
- actualLengthInBytes = metadata.baseTI.length; // this ensure truncation!
+ actualLengthInBytes = metadata._baseTI.length; // this ensure truncation!
}
break;
@@ -10724,16 +10724,16 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
case TdsEnums.SQLNTEXT:
actualLengthInBytes = ((isSqlType) ? ((SqlString)value).Value.Length : ((string)value).Length) * 2;
- if (metadata.baseTI.length > 0 &&
- actualLengthInBytes > metadata.baseTI.length)
+ if (metadata._baseTI.length > 0 &&
+ actualLengthInBytes > metadata._baseTI.length)
{ // see comments above
- actualLengthInBytes = metadata.baseTI.length;
+ actualLengthInBytes = metadata._baseTI.length;
}
break;
default:
- actualLengthInBytes = metadata.baseTI.length;
+ actualLengthInBytes = metadata._baseTI.length;
break;
}
@@ -10742,28 +10742,28 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
{
// SqlType
serializedValue = SerializeUnencryptedSqlValue(value,
- metadata.baseTI.metaType,
+ metadata._baseTI.metaType,
actualLengthInBytes,
offset: 0,
- normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata._cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
else
{
serializedValue = SerializeUnencryptedValue(value,
- metadata.baseTI.metaType,
- metadata.baseTI.scale,
+ metadata._baseTI.metaType,
+ metadata._baseTI.scale,
actualLengthInBytes,
offset: 0,
isDataFeed: isDataFeed,
- normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata._cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
Debug.Assert(serializedValue != null, "serializedValue should not be null in TdsExecuteRPC.");
return SqlSecurityUtility.EncryptWithKey(
serializedValue,
- metadata.cipherMD,
+ metadata._cipherMD,
_connHandler.Connection,
null);
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
index 6b65491499..29deed4e49 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
@@ -1509,13 +1509,13 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
byte scale = metadata.scale;
byte precision = metadata.precision;
int length = metadata.length;
- if (metadata.isEncrypted)
+ if (metadata._isEncrypted)
{
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- type = metadata.baseTI.metaType;
- scale = metadata.baseTI.scale;
- precision = metadata.baseTI.precision;
- length = metadata.baseTI.length;
+ type = metadata._baseTI.metaType;
+ scale = metadata._baseTI.scale;
+ precision = metadata._baseTI.precision;
+ length = metadata._baseTI.length;
}
try
@@ -1556,11 +1556,11 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
}
catch (SqlTruncateException)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
}
catch (Exception e)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), e);
}
}
@@ -1605,7 +1605,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
int maxStringLength = length / 2;
if (str.Length > maxStringLength)
{
- if (metadata.isEncrypted)
+ if (metadata._isEncrypted)
{
str = "";
}
@@ -1649,7 +1649,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
default:
Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), null);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), null);
}
if (typeChanged)
@@ -1666,7 +1666,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
throw;
}
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), e);
}
}
@@ -2271,7 +2271,7 @@ private Task ReadWriteColumnValueAsync(int col)
// If column encryption is requested via connection string option, perform encryption here
if (!isNull && // if value is not NULL
- metadata.isEncrypted)
+ metadata._isEncrypted)
{ // If we are transparently encrypting
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
value = _parser.EncryptColumnValue(value, metadata, metadata.column, _stateObj, isDataFeed, isSqlType);
@@ -2289,7 +2289,7 @@ private Task ReadWriteColumnValueAsync(int col)
else
{
// Target type shouldn't be encrypted
- Debug.Assert(!metadata.isEncrypted, "Can't encrypt SQL Variant type");
+ Debug.Assert(!metadata._isEncrypted, "Can't encrypt SQL Variant type");
SqlBuffer.StorageType variantInternalType = SqlBuffer.StorageType.Empty;
if ((_sqlDataReaderRowSource != null) && (_connection.Is2008OrNewer))
{
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs
index 0ac6ed775e..15a7975b8d 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs
@@ -6321,7 +6321,7 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
{
// If the parameter's direction is InputOutput, Output or ReturnValue and it needs to be transparently encrypted/decrypted
// then simply decrypt, deserialize and set the value.
- if (rec.cipherMD != null &&
+ if (rec._cipherMD != null &&
thisParam.CipherMetadata != null &&
(thisParam.Direction == ParameterDirection.Output ||
thisParam.Direction == ParameterDirection.InputOutput ||
@@ -6346,8 +6346,8 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
Debug.Assert(_activeConnection != null, @"_activeConnection should not be null");
// Get the key information from the parameter and decrypt the value.
- rec.cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec.cipherMD, _activeConnection, this);
+ rec._cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec._cipherMD, _activeConnection, this);
if (unencryptedBytes != null)
{
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs
index e85c446cd1..80ef36e56b 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs
@@ -596,10 +596,10 @@ internal DataTable BuildSchemaTable()
// col.length is always byte count so for unicode types, half the length
//
// For MAX and XML datatypes, we get 0x7fffffff from the server. Do not divide this.
- if (col.cipherMD != null)
+ if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null && col.baseTI.metaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
- schemaRow[Size] = (col.baseTI.metaType.IsSizeInCharacters && (col.baseTI.length != 0x7fffffff)) ? (col.baseTI.length / 2) : col.baseTI.length;
+ Debug.Assert(col._baseTI != null && col._baseTI.metaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
+ schemaRow[Size] = (col._baseTI.metaType.IsSizeInCharacters && (col._baseTI.length != 0x7fffffff)) ? (col._baseTI.length / 2) : col._baseTI.length;
}
else
{
@@ -608,7 +608,7 @@ internal DataTable BuildSchemaTable()
schemaRow[DataType] = GetFieldTypeInternal(col);
schemaRow[ProviderSpecificDataType] = GetProviderSpecificFieldTypeInternal(col);
- schemaRow[NonVersionedProviderType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type); // SqlDbType enum value - does not change with TypeSystem.
+ schemaRow[NonVersionedProviderType] = (int)(col._cipherMD != null ? col._baseTI.type : col.type); // SqlDbType enum value - does not change with TypeSystem.
schemaRow[DataTypeName] = GetDataTypeNameInternal(col);
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.Is2008DateTimeType)
@@ -650,7 +650,7 @@ internal DataTable BuildSchemaTable()
// TypeSystem.SQLServer2005 and above
// SqlDbType enum value - always the actual type for SQLServer2005.
- schemaRow[ProviderType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type);
+ schemaRow[ProviderType] = (int)(col._cipherMD != null ? col._baseTI.type : col.type);
if (col.type == SqlDbType.Udt)
{ // Additional metadata for UDTs.
@@ -673,16 +673,16 @@ internal DataTable BuildSchemaTable()
schemaRow[ProviderType] = GetVersionedMetaType(col.metaType).SqlDbType;
}
- if (col.cipherMD != null)
+ if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.precision)
+ Debug.Assert(col._baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col._baseTI.precision)
{
- schemaRow[Precision] = col.baseTI.precision;
+ schemaRow[Precision] = col._baseTI.precision;
}
else
{
- schemaRow[Precision] = col.baseTI.metaType.Precision;
+ schemaRow[Precision] = col._baseTI.metaType.Precision;
}
}
else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.precision)
@@ -698,16 +698,16 @@ internal DataTable BuildSchemaTable()
{
schemaRow[Scale] = MetaType.MetaNVarChar.Scale;
}
- else if (col.cipherMD != null)
+ else if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.scale)
+ Debug.Assert(col._baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col._baseTI.scale)
{
- schemaRow[Scale] = col.baseTI.scale;
+ schemaRow[Scale] = col._baseTI.scale;
}
else
{
- schemaRow[Scale] = col.baseTI.metaType.Scale;
+ schemaRow[Scale] = col._baseTI.metaType.Scale;
}
}
else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale)
@@ -733,11 +733,11 @@ internal DataTable BuildSchemaTable()
schemaRow[IsIdentity] = col.IsIdentity;
schemaRow[IsAutoIncrement] = col.IsIdentity;
- if (col.cipherMD != null)
+ if (col._cipherMD != null)
{
- Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
- Debug.Assert(col.baseTI.metaType != null, @"col.baseTI.metaType should not be null.");
- schemaRow[IsLong] = col.baseTI.metaType.IsLong;
+ Debug.Assert(col._baseTI != null, @"col.baseTI should not be null.");
+ Debug.Assert(col._baseTI.metaType != null, @"col.baseTI.metaType should not be null.");
+ schemaRow[IsLong] = col._baseTI.metaType.IsLong;
}
else
{
@@ -1405,10 +1405,10 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- dataTypeName = metaData.baseTI.metaType.TypeName;
+ Debug.Assert(metaData._baseTI != null && metaData._baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ dataTypeName = metaData._baseTI.metaType.TypeName;
}
else
{
@@ -1490,10 +1490,10 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- fieldType = metaData.baseTI.metaType.ClassType;
+ Debug.Assert(metaData._baseTI != null && metaData._baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ fieldType = metaData._baseTI.metaType.ClassType;
}
else
{
@@ -1516,13 +1516,13 @@ virtual internal int GetLocaleId(int i)
_SqlMetaData sqlMetaData = MetaData[i];
int lcid;
- if (sqlMetaData.cipherMD != null)
+ if (sqlMetaData._cipherMD != null)
{
// If this column is encrypted, get the collation from baseTI
//
- if (sqlMetaData.baseTI.collation != null)
+ if (sqlMetaData._baseTI.collation != null)
{
- lcid = sqlMetaData.baseTI.collation.LCID;
+ lcid = sqlMetaData._baseTI.collation.LCID;
}
else
{
@@ -1602,11 +1602,11 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
else
{
// For all other types, including Xml - use data in MetaType.
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null,
+ Debug.Assert(metaData._baseTI != null && metaData._baseTI.metaType != null,
"metaData.baseTI and metaData.baseTI.metaType should not be null.");
- providerSpecificFieldType = metaData.baseTI.metaType.SqlType; // SqlType type.
+ providerSpecificFieldType = metaData._baseTI.metaType.SqlType; // SqlType type.
}
else
{
@@ -1736,7 +1736,7 @@ override public Stream GetStream(int i)
CheckDataIsReady(columnIndex: i, methodName: "GetStream");
// Streaming is not supported on encrypted columns.
- if (_metaData[i] != null && _metaData[i].cipherMD != null)
+ if (_metaData[i] != null && _metaData[i]._cipherMD != null)
{
throw SQL.StreamNotSupportOnEncryptedColumn(_metaData[i].column);
}
@@ -1855,7 +1855,7 @@ private bool TryGetBytesInternal(int i, long dataIndex, byte[] buffer, int buffe
{
Debug.Assert(!HasActiveStreamOrTextReaderOnColumn(i), "Column has an active Stream or TextReader");
- if (_metaData[i] != null && _metaData[i].cipherMD != null)
+ if (_metaData[i] != null && _metaData[i]._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
@@ -2226,10 +2226,10 @@ override public TextReader GetTextReader(int i)
// Xml type is not supported
MetaType mt = null;
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
- Debug.Assert(_metaData[i].baseTI != null, "_metaData[i].baseTI should not be null.");
- mt = _metaData[i].baseTI.metaType;
+ Debug.Assert(_metaData[i]._baseTI != null, "_metaData[i].baseTI should not be null.");
+ mt = _metaData[i]._baseTI.metaType;
}
else
{
@@ -2246,7 +2246,7 @@ override public TextReader GetTextReader(int i)
// For non-variant types with sequential access, we support proper streaming
if ((mt.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)))
{
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
@@ -2308,10 +2308,10 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
}
MetaType mt = null;
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
- Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
- mt = _metaData[i].baseTI.metaType;
+ Debug.Assert(_metaData[i]._baseTI != null, @"_metaData[i].baseTI should not be null.");
+ mt = _metaData[i]._baseTI.metaType;
}
else
{
@@ -2321,10 +2321,10 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
Debug.Assert(mt != null, "mt should not be null.");
SqlDbType sqlDbType;
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
- Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
- sqlDbType = _metaData[i].baseTI.type;
+ Debug.Assert(_metaData[i]._baseTI != null, @"_metaData[i].baseTI should not be null.");
+ sqlDbType = _metaData[i]._baseTI.type;
}
else
{
@@ -2343,7 +2343,7 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
throw ADP.InvalidDataLength(length);
}
- if (_metaData[i].cipherMD != null)
+ if (_metaData[i]._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
@@ -3244,10 +3244,10 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// Xml type is not supported
MetaType metaType = metaData.metaType;
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
- Debug.Assert(metaData.baseTI != null, "_metaData[i].baseTI should not be null.");
- metaType = metaData.baseTI.metaType;
+ Debug.Assert(metaData._baseTI != null, "_metaData[i].baseTI should not be null.");
+ metaType = metaData._baseTI.metaType;
}
if (
@@ -3261,7 +3261,7 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
// For non-variant types with sequential access, we support proper streaming
if ((metaType.SqlDbType != SqlDbType.Variant) && IsCommandBehavior(CommandBehavior.SequentialAccess))
{
- if (metaData.cipherMD != null)
+ if (metaData._cipherMD != null)
{
throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(metaData.column);
}
@@ -3285,7 +3285,7 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
}
else if (typeof(T) == typeof(Stream))
{
- if (metaData != null && metaData.cipherMD != null)
+ if (metaData != null && metaData._cipherMD != null)
{
throw SQL.StreamNotSupportOnEncryptedColumn(metaData.column);
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
index 7a9bbfdfd3..ad15ac6eb7 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -4609,7 +4609,7 @@ internal bool TryProcessReturnValue(int length,
// Check if the column is encrypted.
if (_serverSupportsColumnEncryption)
{
- rec.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ rec._isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// read the type
@@ -4778,7 +4778,7 @@ internal bool TryProcessReturnValue(int length,
}
// For encrypted parameters, read the unencrypted type and encryption information.
- if (_serverSupportsColumnEncryption && rec.isEncrypted)
+ if (_serverSupportsColumnEncryption && rec._isEncrypted)
{
if (!TryProcessTceCryptoMetadata(stateObj, rec, cipherTable: null, columnEncryptionSetting: columnEncryptionSetting, isReturnValue: true))
{
@@ -4857,8 +4857,8 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
}
// Read the base TypeInfo
- col.baseTI = new SqlMetaDataPriv();
- if (!TryProcessTypeInfo(stateObj, col.baseTI, userType))
+ col._baseTI = new SqlMetaDataPriv();
+ if (!TryProcessTypeInfo(stateObj, col._baseTI, userType))
{
return false;
}
@@ -4900,7 +4900,7 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
return false;
}
- Debug.Assert(col.cipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
+ Debug.Assert(col._cipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
// Check if TCE is enable and if it is set the crypto MD for the column.
// TCE is enabled if the command is set to enabled or to resultset only and this is not a return value
@@ -4911,7 +4911,7 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
_connHandler != null && _connHandler.ConnectionOptions != null &&
_connHandler.ConnectionOptions.ColumnEncryptionSetting == SqlConnectionColumnEncryptionSetting.Enabled))
{
- col.cipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
+ col._cipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
index,
cipherAlgorithmId: cipherAlgorithmId,
cipherAlgorithmName: cipherAlgorithmName,
@@ -4921,7 +4921,7 @@ internal bool TryProcessTceCryptoMetadata(TdsParserStateObject stateObj,
else
{
// If TCE is disabled mark the MD as not encrypted.
- col.isEncrypted = false;
+ col._isEncrypted = false;
}
return true;
@@ -5722,7 +5722,7 @@ private bool TryCommonProcessMetaData(TdsParserStateObject stateObj, _SqlMetaDat
col.IsColumnSet = (TdsEnums.IsColumnSet == (flags & TdsEnums.IsColumnSet));
if (fColMD && _serverSupportsColumnEncryption)
{
- col.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ col._isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// Read TypeInfo
@@ -5763,7 +5763,7 @@ private bool TryCommonProcessMetaData(TdsParserStateObject stateObj, _SqlMetaDat
}
// Read the TCE column cryptoinfo
- if (fColMD && _serverSupportsColumnEncryption && col.isEncrypted)
+ if (fColMD && _serverSupportsColumnEncryption && col._isEncrypted)
{
// If the column is encrypted, we should have a valid cipherTable
if (cipherTable != null && !TryProcessTceCryptoMetadata(stateObj, col, cipherTable, columnEncryptionSetting, isReturnValue: false))
@@ -6286,10 +6286,10 @@ internal static object GetNullSqlValue(
SqlDbType type = md.type;
if (type == SqlDbType.VarBinary && // if its a varbinary
- md.isEncrypted &&// and encrypted
+ md._isEncrypted &&// and encrypted
ShouldHonorTceForRead(columnEncryptionSetting, connection))
{
- type = md.baseTI.type; // the use the actual (plaintext) type
+ type = md._baseTI.type; // the use the actual (plaintext) type
}
switch (type)
@@ -6581,14 +6581,14 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
throw SQL.UnsupportedNormalizationVersion(normalizationVersion);
}
- byte tdsType = md.baseTI.tdsType;
+ byte tdsType = md._baseTI.tdsType;
int length = unencryptedBytes.Length;
// For normalized types, the length and scale of the actual type might be different than the value's.
- int denormalizedLength = md.baseTI.length;
- byte denormalizedScale = md.baseTI.scale;
+ int denormalizedLength = md._baseTI.length;
+ byte denormalizedScale = md._baseTI.scale;
- Debug.Assert(false == md.baseTI.isEncrypted, "Double encryption detected");
+ Debug.Assert(false == md._baseTI._isEncrypted, "Double encryption detected");
switch (tdsType)
{
// We normalize to allow conversion across data types. All data types below are serialized into a BIGINT.
@@ -6736,7 +6736,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with zeros to get to the fixed length size.
if (tdsType == TdsEnums.SQLBINARY || tdsType == TdsEnums.SQLBIGBINARY)
{
- byte[] bytes = new byte[md.baseTI.length];
+ byte[] bytes = new byte[md._baseTI.length];
Buffer.BlockCopy(unencryptedBytes, 0, bytes, 0, unencryptedBytes.Length);
unencryptedBytes = bytes;
}
@@ -6762,7 +6762,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
bits[i] = BitConverter.ToInt32(unencryptedBytes, index);
index += 4;
}
- value.SetToDecimal(md.baseTI.precision, md.baseTI.scale, fPositive, bits);
+ value.SetToDecimal(md._baseTI.precision, md._baseTI.scale, fPositive, bits);
break;
case TdsEnums.SQLCHAR:
@@ -6771,7 +6771,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
case TdsEnums.SQLBIGVARCHAR:
case TdsEnums.SQLTEXT:
{
- System.Text.Encoding encoding = md.baseTI.encoding;
+ System.Text.Encoding encoding = md._baseTI.encoding;
if (null == encoding)
{
@@ -6788,7 +6788,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLCHAR || tdsType == TdsEnums.SQLBIGCHAR)
{
- strValue = strValue.PadRight(md.baseTI.length);
+ strValue = strValue.PadRight(md._baseTI.length);
}
value.SetToString(strValue);
@@ -6804,7 +6804,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLNCHAR)
{
- strValue = strValue.PadRight(md.baseTI.length / ADP.CharSize);
+ strValue = strValue.PadRight(md._baseTI.length / ADP.CharSize);
}
value.SetToString(strValue);
@@ -6835,7 +6835,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
break;
default:
- MetaType metaType = md.baseTI.metaType;
+ MetaType metaType = md._baseTI.metaType;
// If we don't have a metatype already, construct one to get the proper type name.
if (metaType == null)
@@ -6907,7 +6907,7 @@ internal bool TryReadSqlValue(SqlBuffer value,
}
}
- if (md.isEncrypted
+ if (md._isEncrypted
&& ((columnEncryptionOverride == SqlCommandColumnEncryptionSetting.Enabled
|| columnEncryptionOverride == SqlCommandColumnEncryptionSetting.ResultSetOnly)
|| (columnEncryptionOverride == SqlCommandColumnEncryptionSetting.UseConnectionSetting
@@ -6917,7 +6917,7 @@ internal bool TryReadSqlValue(SqlBuffer value,
try
{
// CipherInfo is present, decrypt and read
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md.cipherMD, _connHandler.Connection, command);
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md._cipherMD, _connHandler.Connection, command);
if (unencryptedBytes != null)
{
@@ -11340,9 +11340,9 @@ internal void LoadColumnEncryptionKeys(_SqlMetaDataSet metadataCollection, SqlCo
if (null != metadataCollection[col])
{
_SqlMetaData md = metadataCollection[col];
- if (md.isEncrypted)
+ if (md._isEncrypted)
{
- SqlSecurityUtility.DecryptSymmetricKey(md.cipherMD, connection, command);
+ SqlSecurityUtility.DecryptSymmetricKey(md._cipherMD, connection, command);
}
}
}
@@ -11390,14 +11390,14 @@ internal void WriteCekTable(_SqlMetaDataSet metadataCollection, TdsParserStateOb
// Note- Cek table (with 0 entries) will be present if TCE
// was enabled and server supports it!
// OR if encryption was disabled in connection options
- if (metadataCollection.cekTable == null ||
+ if (metadataCollection._cekTable == null ||
!ShouldEncryptValuesForBulkCopy())
{
WriteShort(0x00, stateObj);
return;
}
- SqlTceCipherInfoTable cekTable = metadataCollection.cekTable;
+ SqlTceCipherInfoTable cekTable = metadataCollection._cekTable;
ushort count = (ushort)cekTable.Size;
WriteShort(count, stateObj);
@@ -11452,34 +11452,34 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
internal void WriteCryptoMetadata(_SqlMetaData md, TdsParserStateObject stateObj)
{
if (!_serverSupportsColumnEncryption || // TCE Feature supported
- !md.isEncrypted || // Column is not encrypted
+ !md._isEncrypted || // Column is not encrypted
!ShouldEncryptValuesForBulkCopy())
{ // TCE disabled on connection string
return;
}
// Write the ordinal
- WriteShort(md.cipherMD.CekTableOrdinal, stateObj);
+ WriteShort(md._cipherMD.CekTableOrdinal, stateObj);
// Write UserType and TYPEINFO
- WriteTceUserTypeAndTypeInfo(md.baseTI, stateObj);
+ WriteTceUserTypeAndTypeInfo(md._baseTI, stateObj);
// Write Encryption Algo
- stateObj.WriteByte(md.cipherMD.CipherAlgorithmId);
+ stateObj.WriteByte(md._cipherMD.CipherAlgorithmId);
- if (TdsEnums.CustomCipherAlgorithmId == md.cipherMD.CipherAlgorithmId)
+ if (TdsEnums.CustomCipherAlgorithmId == md._cipherMD.CipherAlgorithmId)
{
// Write the algorithm name
- Debug.Assert(md.cipherMD.CipherAlgorithmName.Length < 256);
- stateObj.WriteByte((byte)md.cipherMD.CipherAlgorithmName.Length);
- WriteString(md.cipherMD.CipherAlgorithmName, stateObj);
+ Debug.Assert(md._cipherMD.CipherAlgorithmName.Length < 256);
+ stateObj.WriteByte((byte)md._cipherMD.CipherAlgorithmName.Length);
+ WriteString(md._cipherMD.CipherAlgorithmName, stateObj);
}
// Write Encryption Algo Type
- stateObj.WriteByte(md.cipherMD.EncryptionType);
+ stateObj.WriteByte(md._cipherMD.EncryptionType);
// Write Normalization Version
- stateObj.WriteByte(md.cipherMD.NormalizationRuleVersion);
+ stateObj.WriteByte(md._cipherMD.NormalizationRuleVersion);
}
internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int count, TdsParserStateObject stateObj)
@@ -11522,7 +11522,7 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
{ // TCE Supported
if (ShouldEncryptValuesForBulkCopy())
{ // TCE enabled on connection options
- flags |= (UInt16)(md.isEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
+ flags |= (UInt16)(md._isEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
}
}
@@ -11614,7 +11614,7 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
}
int actualLengthInBytes;
- switch (metadata.baseTI.metaType.NullableType)
+ switch (metadata._baseTI.metaType.NullableType)
{
case TdsEnums.SQLBIGBINARY:
case TdsEnums.SQLBIGVARBINARY:
@@ -11629,10 +11629,10 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
// to report the size of data to be copied out (for serialization). If we underreport the
// size, truncation will happen for us!
actualLengthInBytes = (isSqlType) ? ((SqlBinary)value).Length : ((byte[])value).Length;
- if (metadata.baseTI.length > 0 &&
- actualLengthInBytes > metadata.baseTI.length)
+ if (metadata._baseTI.length > 0 &&
+ actualLengthInBytes > metadata._baseTI.length)
{ // see comments agove
- actualLengthInBytes = metadata.baseTI.length;
+ actualLengthInBytes = metadata._baseTI.length;
}
break;
@@ -11651,10 +11651,10 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
actualLengthInBytes = _defaultEncoding.GetByteCount(stringValue);
// If the string length is > max length, then use the max length (see comments above)
- if (metadata.baseTI.length > 0 &&
- actualLengthInBytes > metadata.baseTI.length)
+ if (metadata._baseTI.length > 0 &&
+ actualLengthInBytes > metadata._baseTI.length)
{
- actualLengthInBytes = metadata.baseTI.length; // this ensure truncation!
+ actualLengthInBytes = metadata._baseTI.length; // this ensure truncation!
}
break;
@@ -11663,16 +11663,16 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
case TdsEnums.SQLNTEXT:
actualLengthInBytes = ((isSqlType) ? ((SqlString)value).Value.Length : ((string)value).Length) * 2;
- if (metadata.baseTI.length > 0 &&
- actualLengthInBytes > metadata.baseTI.length)
+ if (metadata._baseTI.length > 0 &&
+ actualLengthInBytes > metadata._baseTI.length)
{ // see comments above
- actualLengthInBytes = metadata.baseTI.length;
+ actualLengthInBytes = metadata._baseTI.length;
}
break;
default:
- actualLengthInBytes = metadata.baseTI.length;
+ actualLengthInBytes = metadata._baseTI.length;
break;
}
@@ -11681,28 +11681,28 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
{
// SqlType
serializedValue = SerializeUnencryptedSqlValue(value,
- metadata.baseTI.metaType,
+ metadata._baseTI.metaType,
actualLengthInBytes,
offset: 0,
- normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata._cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
else
{
serializedValue = SerializeUnencryptedValue(value,
- metadata.baseTI.metaType,
- metadata.baseTI.scale,
+ metadata._baseTI.metaType,
+ metadata._baseTI.scale,
actualLengthInBytes,
offset: 0,
isDataFeed: isDataFeed,
- normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata._cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
Debug.Assert(serializedValue != null, "serializedValue should not be null in TdsExecuteRPC.");
return SqlSecurityUtility.EncryptWithKey(
serializedValue,
- metadata.cipherMD,
+ metadata._cipherMD,
_connHandler.Connection,
null);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
index 0a4fe787a9..38e1d0828d 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
@@ -14,16 +14,16 @@ namespace Microsoft.Data.SqlClient
/// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
/// the store type, name,the key path and encryption algorithm.
///
- internal class SqlEncryptionKeyInfo
+ internal sealed class SqlEncryptionKeyInfo
{
- internal byte[] encryptedKey; // the encrypted "column encryption key"
- internal int databaseId;
- internal int cekId;
- internal int cekVersion;
- internal byte[] cekMdVersion;
- internal string keyPath;
- internal string keyStoreName;
- internal string algorithmName;
+ internal byte[] _encryptedKey; // the encrypted "column encryption key"
+ internal int _databaseId;
+ internal int _cekId;
+ internal int _cekVersion;
+ internal byte[] _cekMdVersion;
+ internal string _keyPath;
+ internal string _keyStoreName;
+ internal string _algorithmName;
}
///
@@ -32,7 +32,7 @@ internal class SqlEncryptionKeyInfo
/// rotation scenario) We need to keep all these around until we can resolve the CEK
/// using the correct master key.
///
- internal class SqlTceCipherInfoEntry
+ internal sealed class SqlTceCipherInfoEntry
{
///
@@ -149,14 +149,14 @@ internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion
SqlEncryptionKeyInfo encryptionKey = new SqlEncryptionKeyInfo
{
- encryptedKey = encryptedKey,
- databaseId = databaseId,
- cekId = cekId,
- cekVersion = cekVersion,
- cekMdVersion = cekMdVersion,
- keyPath = keyPath,
- keyStoreName = keyStoreName,
- algorithmName = algorithmName
+ _encryptedKey = encryptedKey,
+ _databaseId = databaseId,
+ _cekId = cekId,
+ _cekVersion = cekVersion,
+ _cekMdVersion = cekMdVersion,
+ _keyPath = keyPath,
+ _keyStoreName = keyStoreName,
+ _algorithmName = algorithmName
};
_columnEncryptionKeyValues.Add(encryptionKey);
@@ -196,27 +196,27 @@ internal SqlTceCipherInfoEntry(int ordinal = 0)
/// may have been encrypted using multiple master keys (giving us multiple CEK values). All these values form one single
/// entry in this table.
///
- internal class SqlTceCipherInfoTable
+ internal sealed class SqlTceCipherInfoTable
{
- private readonly SqlTceCipherInfoEntry[] keyList;
+ private readonly SqlTceCipherInfoEntry[] _keyList;
internal SqlTceCipherInfoTable(int tabSize)
{
Debug.Assert(0 < tabSize, "Invalid Table Size");
- keyList = new SqlTceCipherInfoEntry[tabSize];
+ _keyList = new SqlTceCipherInfoEntry[tabSize];
}
internal SqlTceCipherInfoEntry this[int index]
{
get
{
- Debug.Assert(index < keyList.Length, "Invalid index specified.");
- return keyList[index];
+ Debug.Assert(index < _keyList.Length, "Invalid index specified.");
+ return _keyList[index];
}
set
{
- Debug.Assert(index < keyList.Length, "Invalid index specified.");
- keyList[index] = value;
+ Debug.Assert(index < _keyList.Length, "Invalid index specified.");
+ _keyList[index] = value;
}
}
@@ -224,26 +224,26 @@ internal int Size
{
get
{
- return keyList.Length;
+ return _keyList.Length;
}
}
}
- sealed internal partial class _SqlMetaDataSet
+ internal sealed partial class _SqlMetaDataSet
{
- internal readonly SqlTceCipherInfoTable cekTable; // table of "column encryption keys" used for this metadataset
+ internal readonly SqlTceCipherInfoTable _cekTable; // table of "column encryption keys" used for this metadataset
internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
: this(count)
{
- cekTable = cipherTable;
+ _cekTable = cipherTable;
}
}
///
/// Represents Encryption related information of the cipher data.
///
- internal class SqlCipherMetadata
+ internal sealed class SqlCipherMetadata
{
///
@@ -429,9 +429,9 @@ internal bool IsAlgorithmInitialized()
internal partial class SqlMetaDataPriv
{
- internal bool isEncrypted; // TCE encrypted?
- internal SqlMetaDataPriv baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
- internal SqlCipherMetadata cipherMD; // Cipher related metadata for encrypted columns.
+ internal bool _isEncrypted; // TCE encrypted?
+ internal SqlMetaDataPriv _baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
+ internal SqlCipherMetadata _cipherMD; // Cipher related metadata for encrypted columns.
///
/// Is the algorithm handle for the cipher encryption initialized ?
@@ -439,9 +439,9 @@ internal partial class SqlMetaDataPriv
///
internal bool IsAlgorithmInitialized()
{
- if (null != cipherMD)
+ if (null != _cipherMD)
{
- return cipherMD.IsAlgorithmInitialized();
+ return _cipherMD.IsAlgorithmInitialized();
}
return false;
@@ -455,9 +455,9 @@ internal byte NormalizationRuleVersion
{
get
{
- if (null != cipherMD)
+ if (null != _cipherMD)
{
- return cipherMD.NormalizationRuleVersion;
+ return _cipherMD.NormalizationRuleVersion;
}
return 0x00;
@@ -468,7 +468,7 @@ internal byte NormalizationRuleVersion
///
/// Class encapsulating additional information when sending encrypted input parameters.
///
- sealed internal class SqlColumnEncryptionInputParameterInfo
+ internal sealed class SqlColumnEncryptionInputParameterInfo
{
///
/// Metadata of the parameter to write the TYPE_INFO of the unencrypted column data type.
@@ -549,7 +549,7 @@ private byte[] SerializeToWriteFormat()
totalLength += sizeof(int);
// Metadata version of the encryption key.
- totalLength += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
+ totalLength += _cipherMetadata.EncryptionKeyInfo._cekMdVersion.Length;
// Normalization Rule Version.
totalLength += sizeof(byte);
@@ -566,17 +566,17 @@ private byte[] SerializeToWriteFormat()
serializedWireFormat[consumedBytes++] = _cipherMetadata.EncryptionType;
// 3 - Write the database id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.databaseId, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo._databaseId, serializedWireFormat, ref consumedBytes);
// 4 - Write the id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekId, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo._cekId, serializedWireFormat, ref consumedBytes);
// 5 - Write the version of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekVersion, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo._cekVersion, serializedWireFormat, ref consumedBytes);
// 6 - Write the metadata version of the encryption key.
- Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length);
- consumedBytes += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
+ Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo._cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo._cekMdVersion.Length);
+ consumedBytes += _cipherMetadata.EncryptionKeyInfo._cekMdVersion.Length;
// 7 - Write Normalization Rule Version.
serializedWireFormat[consumedBytes++] = _cipherMetadata.NormalizationRuleVersion;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
index fc10fda351..d6eb859e1b 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
@@ -76,9 +76,9 @@ private List GetDecryptedKeysToBeSentToEnclave(Concurre
decryptedKeysToBeSentToEnclave.Add(
new ColumnEncryptionKeyInfo(
sqlClientSymmetricKey.RootKey,
- cipherInfo.ColumnEncryptionKeyValues[0].databaseId,
- cipherInfo.ColumnEncryptionKeyValues[0].cekMdVersion,
- cipherInfo.ColumnEncryptionKeyValues[0].cekId
+ cipherInfo.ColumnEncryptionKeyValues[0]._databaseId,
+ cipherInfo.ColumnEncryptionKeyValues[0]._cekMdVersion,
+ cipherInfo.ColumnEncryptionKeyValues[0]._cekId
)
);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
index 5475eb5a0c..58a6dd0290 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
@@ -309,8 +309,8 @@ private ConcurrentDictionary CreateCopyOfEnclaveKeys
SqlTceCipherInfoEntry copy = new(ordinal);
foreach (SqlEncryptionKeyInfo cekInfo in original.ColumnEncryptionKeyValues)
{
- copy.Add(cekInfo.encryptedKey, cekInfo.databaseId, cekInfo.cekId, cekInfo.cekVersion,
- cekInfo.cekMdVersion, cekInfo.keyPath, cekInfo.keyStoreName, cekInfo.algorithmName);
+ copy.Add(cekInfo._encryptedKey, cekInfo._databaseId, cekInfo._cekId, cekInfo._cekVersion,
+ cekInfo._cekMdVersion, cekInfo._keyPath, cekInfo._keyStoreName, cekInfo._algorithmName);
}
enclaveKeys.TryAdd(ordinal, copy);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
index d9fea6b211..5d79fb9a0e 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
@@ -227,7 +227,7 @@ internal static byte[] DecryptWithKey(byte[] cipherText, SqlCipherMetadata md, S
catch (Exception e)
{
// compute the strings to pass
- string keyStr = GetBytesAsString(md.EncryptionKeyInfo.encryptedKey, fLast: true, countOfBytes: 10);
+ string keyStr = GetBytesAsString(md.EncryptionKeyInfo._encryptedKey, fLast: true, countOfBytes: 10);
string valStr = GetBytesAsString(cipherText, fLast: false, countOfBytes: 10);
throw SQL.ThrowDecryptionFailed(keyStr, valStr, e);
}
@@ -275,7 +275,7 @@ internal static void DecryptSymmetricKey(SqlTceCipherInfoEntry sqlTceCipherInfoE
{
try
{
- sqlClientSymmetricKey = ShouldUseInstanceLevelProviderFlow(keyInfo.keyStoreName, connection, command) ?
+ sqlClientSymmetricKey = ShouldUseInstanceLevelProviderFlow(keyInfo._keyStoreName, connection, command) ?
GetKeyFromLocalProviders(keyInfo, connection, command) :
globalCekCache.GetKey(keyInfo, connection, command);
encryptionkeyInfoChosen = keyInfo;
@@ -303,10 +303,10 @@ private static SqlClientSymmetricKey GetKeyFromLocalProviders(SqlEncryptionKeyIn
Debug.Assert(SqlConnection.ColumnEncryptionTrustedMasterKeyPaths is not null, @"SqlConnection.ColumnEncryptionTrustedMasterKeyPaths should not be null");
- ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.keyPath);
- if (!TryGetColumnEncryptionKeyStoreProvider(keyInfo.keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
+ ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo._keyPath);
+ if (!TryGetColumnEncryptionKeyStoreProvider(keyInfo._keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
{
- throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.keyStoreName,
+ throw SQL.UnrecognizedKeyStoreProviderName(keyInfo._keyStoreName,
SqlConnection.GetColumnEncryptionSystemKeyStoreProvidersNames(),
GetListOfProviderNamesThatWereSearched(connection, command));
}
@@ -316,13 +316,13 @@ private static SqlClientSymmetricKey GetKeyFromLocalProviders(SqlEncryptionKeyIn
byte[] plaintextKey;
try
{
- plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.keyPath, keyInfo.algorithmName, keyInfo.encryptedKey);
+ plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo._keyPath, keyInfo._algorithmName, keyInfo._encryptedKey);
}
catch (Exception e)
{
// Generate a new exception and throw.
- string keyHex = GetBytesAsString(keyInfo.encryptedKey, fLast: true, countOfBytes: 10);
- throw SQL.KeyDecryptionFailed(keyInfo.keyStoreName, keyHex, e);
+ string keyHex = GetBytesAsString(keyInfo._encryptedKey, fLast: true, countOfBytes: 10);
+ throw SQL.KeyDecryptionFailed(keyInfo._keyStoreName, keyHex, e);
}
return new SqlClientSymmetricKey(plaintextKey);
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
index 663116ed59..61ece80b43 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
@@ -35,16 +35,16 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
string serverName = connection.DataSource;
Debug.Assert(serverName is not null, @"serverName should not be null.");
- StringBuilder cacheLookupKeyBuilder = new StringBuilder(serverName, capacity: serverName.Length + SqlSecurityUtility.GetBase64LengthFromByteLength(keyInfo.encryptedKey.Length) + keyInfo.keyStoreName.Length + 2/*separators*/);
+ StringBuilder cacheLookupKeyBuilder = new StringBuilder(serverName, capacity: serverName.Length + SqlSecurityUtility.GetBase64LengthFromByteLength(keyInfo._encryptedKey.Length) + keyInfo._keyStoreName.Length + 2/*separators*/);
#if DEBUG
int capacity = cacheLookupKeyBuilder.Capacity;
#endif //DEBUG
cacheLookupKeyBuilder.Append(":");
- cacheLookupKeyBuilder.Append(Convert.ToBase64String(keyInfo.encryptedKey));
+ cacheLookupKeyBuilder.Append(Convert.ToBase64String(keyInfo._encryptedKey));
cacheLookupKeyBuilder.Append(":");
- cacheLookupKeyBuilder.Append(keyInfo.keyStoreName);
+ cacheLookupKeyBuilder.Append(keyInfo._keyStoreName);
string cacheLookupKey = cacheLookupKeyBuilder.ToString();
@@ -57,12 +57,12 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
Debug.Assert(SqlConnection.ColumnEncryptionTrustedMasterKeyPaths is not null, @"SqlConnection.ColumnEncryptionTrustedMasterKeyPaths should not be null");
- SqlSecurityUtility.ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.keyPath);
+ SqlSecurityUtility.ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo._keyPath);
// Key Not found, attempt to look up the provider and decrypt CEK
- if (!SqlSecurityUtility.TryGetColumnEncryptionKeyStoreProvider(keyInfo.keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
+ if (!SqlSecurityUtility.TryGetColumnEncryptionKeyStoreProvider(keyInfo._keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
{
- throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.keyStoreName,
+ throw SQL.UnrecognizedKeyStoreProviderName(keyInfo._keyStoreName,
SqlConnection.GetColumnEncryptionSystemKeyStoreProvidersNames(),
SqlSecurityUtility.GetListOfProviderNamesThatWereSearched(connection, command));
}
@@ -74,13 +74,13 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
// to prevent conflicts between CEK caches, global providers should not use their own CEK caches
provider.ColumnEncryptionKeyCacheTtl = new TimeSpan(0);
- plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.keyPath, keyInfo.algorithmName, keyInfo.encryptedKey);
+ plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo._keyPath, keyInfo._algorithmName, keyInfo._encryptedKey);
}
catch (Exception e)
{
// Generate a new exception and throw.
- string keyHex = SqlSecurityUtility.GetBytesAsString(keyInfo.encryptedKey, fLast: true, countOfBytes: 10);
- throw SQL.KeyDecryptionFailed(keyInfo.keyStoreName, keyHex, e);
+ string keyHex = SqlSecurityUtility.GetBytesAsString(keyInfo._encryptedKey, fLast: true, countOfBytes: 10);
+ throw SQL.KeyDecryptionFailed(keyInfo._keyStoreName, keyHex, e);
}
encryptionKey = new SqlClientSymmetricKey(plaintextKey);
From 89f5a63e0d59c34bd284aef568b563d377212bd3 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 20:09:48 +0000
Subject: [PATCH 05/14] Split the classes in TdsParserHelperClasses.cs into
project-specific NetCoreApp and netfx files, ready for merge.
---
.../src/Microsoft.Data.SqlClient.csproj | 3 +-
.../TdsParserHelperClasses.NetCoreApp.cs | 115 ++++++++++++++
.../Data/SqlClient/TdsParserHelperClasses.cs | 99 +------------
.../netfx/src/Microsoft.Data.SqlClient.csproj | 1 +
.../Data/SqlClient/TdsParserHelperClasses.cs | 133 +----------------
.../SqlClient/TdsParserHelperClasses.netfx.cs | 140 ++++++++++++++++++
6 files changed, 264 insertions(+), 227 deletions(-)
create mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs
create mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.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 00b4fae5dc..c4f915c7e7 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -594,7 +594,7 @@
True
True
Strings.resx
-
+
Resources\Strings.resx
Microsoft.Data.SqlClient.Resources.Strings.resources
@@ -668,6 +668,7 @@
+
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs
new file mode 100644
index 0000000000..0a77f7fa31
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs
@@ -0,0 +1,115 @@
+// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Data;
+using System.Data.Common;
+using System.Data.SqlTypes;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Security;
+using System.Security.Authentication;
+using System.Text;
+using Microsoft.Data.Common;
+using Microsoft.Data.SqlTypes;
+
+namespace Microsoft.Data.SqlClient
+{
+ internal enum EncryptionOptions
+ {
+ OFF,
+ ON,
+ NOT_SUP,
+ REQ,
+ LOGIN
+ }
+
+ internal sealed partial class _SqlMetaDataSet
+ {
+ internal ReadOnlyCollection dbColumnSchema;
+
+ private _SqlMetaDataSet(_SqlMetaDataSet original)
+ {
+ id = original.id;
+ _hiddenColumnCount = original._hiddenColumnCount;
+ _visibleColumnMap = original._visibleColumnMap;
+ dbColumnSchema = original.dbColumnSchema;
+ if (original._metaDataArray == null)
+ {
+ _metaDataArray = null;
+ }
+ else
+ {
+ _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
+ for (int idx = 0; idx < _metaDataArray.Length; idx++)
+ {
+ _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
+ }
+ }
+ }
+ }
+
+ internal static class SslProtocolsHelper
+ {
+ private static string ToFriendlyName(this SslProtocols protocol)
+ {
+ string name;
+
+ /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
+ * This driver does not support this version yet!
+ if ((protocol & SslProtocols.Tls13) == SslProtocols.Tls13)
+ {
+ name = "TLS 1.3";
+ }*/
+ if ((protocol & SslProtocols.Tls12) == SslProtocols.Tls12)
+ {
+ name = "TLS 1.2";
+ }
+ else if ((protocol & SslProtocols.Tls11) == SslProtocols.Tls11)
+ {
+ name = "TLS 1.1";
+ }
+ else if ((protocol & SslProtocols.Tls) == SslProtocols.Tls)
+ {
+ name = "TLS 1.0";
+ }
+#pragma warning disable CS0618 // Type or member is obsolete: SSL is depricated
+ else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
+ {
+ name = "SSL 3.0";
+ }
+ else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
+#pragma warning restore CS0618 // Type or member is obsolete: SSL is depricated
+ {
+ name = "SSL 2.0";
+ }
+ else
+ {
+ name = protocol.ToString();
+ }
+
+ return name;
+ }
+
+ ///
+ /// check the negotiated secure protocol if it's under TLS 1.2
+ ///
+ ///
+ /// Localized warning message
+ public static string GetProtocolWarning(this SslProtocols protocol)
+ {
+ string message = string.Empty;
+#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
+ if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
+#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
+ {
+ message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
+ }
+ return message;
+ }
+ }
+}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index 9a6ceb7054..2b7969c42d 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -3,20 +3,14 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Buffers;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Data;
-using System.Data.Common;
-using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Security;
-using System.Security.Authentication;
using System.Text;
using Microsoft.Data.Common;
-using Microsoft.Data.SqlTypes;
namespace Microsoft.Data.SqlClient
{
@@ -26,15 +20,6 @@ internal enum CallbackType
Write = 1
}
- internal enum EncryptionOptions
- {
- OFF,
- ON,
- NOT_SUP,
- REQ,
- LOGIN
- }
-
internal enum PreLoginHandshakeStatus
{
Successful,
@@ -298,7 +283,6 @@ internal sealed partial class _SqlMetaDataSet
internal DataTable schemaTable;
private readonly _SqlMetaData[] _metaDataArray;
- internal ReadOnlyCollection dbColumnSchema;
private int _hiddenColumnCount;
private int[] _visibleColumnMap;
@@ -313,26 +297,6 @@ internal _SqlMetaDataSet(int count)
}
}
- private _SqlMetaDataSet(_SqlMetaDataSet original)
- {
- id = original.id;
- _hiddenColumnCount = original._hiddenColumnCount;
- _visibleColumnMap = original._visibleColumnMap;
- dbColumnSchema = original.dbColumnSchema;
- if (original._metaDataArray == null)
- {
- _metaDataArray = null;
- }
- else
- {
- _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
- for (int idx = 0; idx < _metaDataArray.Length; idx++)
- {
- _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
- }
- }
- }
-
internal int Length
{
get
@@ -647,10 +611,9 @@ internal SqlParameter GetParameterByIndex(int index, out byte options)
}
return retval;
}
-
}
- internal sealed class SqlReturnValue : SqlMetaDataPriv
+ internal sealed partial class SqlReturnValue : SqlMetaDataPriv
{
internal string parameter;
internal readonly SqlBuffer value;
@@ -739,64 +702,4 @@ private void ParseMultipartName()
internal static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
}
-
- internal static class SslProtocolsHelper
- {
- private static string ToFriendlyName(this SslProtocols protocol)
- {
- string name;
-
- /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
- * This driver does not support this version yet!
- if ((protocol & SslProtocols.Tls13) == SslProtocols.Tls13)
- {
- name = "TLS 1.3";
- }*/
- if((protocol & SslProtocols.Tls12) == SslProtocols.Tls12)
- {
- name = "TLS 1.2";
- }
- else if ((protocol & SslProtocols.Tls11) == SslProtocols.Tls11)
- {
- name = "TLS 1.1";
- }
- else if ((protocol & SslProtocols.Tls) == SslProtocols.Tls)
- {
- name = "TLS 1.0";
- }
-#pragma warning disable CS0618 // Type or member is obsolete: SSL is depricated
- else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
- {
- name = "SSL 3.0";
- }
- else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
-#pragma warning restore CS0618 // Type or member is obsolete: SSL is depricated
- {
- name = "SSL 2.0";
- }
- else
- {
- name = protocol.ToString();
- }
-
- return name;
- }
-
- ///
- /// check the negotiated secure protocol if it's under TLS 1.2
- ///
- ///
- /// Localized warning message
- public static string GetProtocolWarning(this SslProtocols protocol)
- {
- string message = string.Empty;
-#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
- if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
-#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
- {
- message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
- }
- 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 8d03642393..a709094d72 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -679,6 +679,7 @@
+
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index 3b200f250b..6a0300183d 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -5,14 +5,11 @@
using System;
using System.Collections.Generic;
using System.Data;
-using System.Data.SqlTypes;
using System.Diagnostics;
using System.Globalization;
using System.Security;
using System.Text;
using Microsoft.Data.Common;
-using Microsoft.Data.SqlClient.Server;
-using Microsoft.Data.SqlTypes;
namespace Microsoft.Data.SqlClient
{
@@ -22,18 +19,6 @@ internal enum CallbackType
Write = 1
}
- internal enum EncryptionOptions
- {
- OFF,
- ON,
- NOT_SUP,
- REQ,
- LOGIN,
- OPTIONS_MASK = 0x3f,
- CTAIP = 0x40,
- CLIENT_CERT = 0x80,
- }
-
internal enum PreLoginHandshakeStatus
{
Successful,
@@ -116,13 +101,11 @@ sealed internal class SqlLogin
internal SecureString newSecurePassword; // new password in SecureString for resetting pasword
}
- sealed internal class SqlLoginAck
+ internal sealed partial class SqlLoginAck
{
- internal string programName;
internal byte majorVersion;
internal byte minorVersion;
internal short buildNum;
- internal bool isVersion8;
internal UInt32 tdsVersion;
}
@@ -143,7 +126,7 @@ sealed internal class SqlFedAuthToken
internal long expirationFileTime;
}
- sealed internal class _SqlMetaData : SqlMetaDataPriv, ICloneable
+ sealed internal class _SqlMetaData : SqlMetaDataPriv
{
[Flags]
private enum _SqlMetadataFlags : int
@@ -298,7 +281,7 @@ internal sealed partial class _SqlMetaDataSet
internal ushort id; // for altrow-columns only
internal DataTable _schemaTable;
- internal readonly _SqlMetaData[] _metaDataArray;
+ private readonly _SqlMetaData[] _metaDataArray;
private int _hiddenColumnCount;
private int[] _visibleColumnMap;
@@ -313,26 +296,6 @@ internal _SqlMetaDataSet(int count)
}
}
- private _SqlMetaDataSet(_SqlMetaDataSet original)
- {
- id = original.id;
- _hiddenColumnCount = original._hiddenColumnCount;
- _visibleColumnMap = original._visibleColumnMap;
- _schemaTable = original._schemaTable;
- if (original._metaDataArray == null)
- {
- _metaDataArray = null;
- }
- else
- {
- _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
- for (int idx = 0; idx < _metaDataArray.Length; idx++)
- {
- _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
- }
- }
- }
-
internal int VisibleColumnCount
{
get
@@ -416,8 +379,7 @@ private void SetupHiddenColumns()
}
}
-
- sealed internal class _SqlMetaDataSetCollection : ICloneable
+ sealed internal class _SqlMetaDataSetCollection
{
private readonly List<_SqlMetaDataSet> altMetaDataSetArray;
internal _SqlMetaDataSet metaDataSet;
@@ -644,10 +606,8 @@ internal SqlParameter GetParameterByIndex(int index, out byte options)
}
}
- sealed internal class SqlReturnValue : SqlMetaDataPriv
+ internal sealed partial class SqlReturnValue : SqlMetaDataPriv
{
-
- internal ushort parmIndex; //2005 or later only
internal string parameter;
internal readonly SqlBuffer value;
@@ -735,87 +695,4 @@ private void ParseMultipartName()
internal static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
}
-
- internal static class SslProtocolsHelper
- {
- // protocol versions from native sni
- [Flags]
- private enum NativeProtocols
- {
- SP_PROT_SSL2_SERVER = 0x00000004,
- SP_PROT_SSL2_CLIENT = 0x00000008,
- SP_PROT_SSL3_SERVER = 0x00000010,
- SP_PROT_SSL3_CLIENT = 0x00000020,
- SP_PROT_TLS1_0_SERVER = 0x00000040,
- SP_PROT_TLS1_0_CLIENT = 0x00000080,
- SP_PROT_TLS1_1_SERVER = 0x00000100,
- SP_PROT_TLS1_1_CLIENT = 0x00000200,
- SP_PROT_TLS1_2_SERVER = 0x00000400,
- SP_PROT_TLS1_2_CLIENT = 0x00000800,
- SP_PROT_TLS1_3_SERVER = 0x00001000,
- SP_PROT_TLS1_3_CLIENT = 0x00002000,
- SP_PROT_SSL2 = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT,
- SP_PROT_SSL3 = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT,
- SP_PROT_TLS1_0 = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT,
- SP_PROT_TLS1_1 = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT,
- SP_PROT_TLS1_2 = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT,
- SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
- SP_PROT_NONE = 0x0
- }
-
- private static string ToFriendlyName(this NativeProtocols protocol)
- {
- string name;
-
- if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
- {
- name = "TLS 1.3";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
- {
- name = "TLS 1.2";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_SERVER))
- {
- name = "TLS 1.1";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_SERVER))
- {
- name = "TLS 1.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
- {
- name = "SSL 3.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
- {
- name = "SSL 2.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_NONE))
- {
- name = "None";
- }
- else
- {
- throw new ArgumentException(StringsHelper.GetString(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
- }
- return name;
- }
-
- ///
- /// check the negotiated secure protocol if it's under TLS 1.2
- ///
- ///
- /// Localized warning message
- public static string GetProtocolWarning(uint protocol)
- {
- var nativeProtocol = (NativeProtocols)protocol;
- string message = string.Empty;
- if ((nativeProtocol & (NativeProtocols.SP_PROT_SSL2 | NativeProtocols.SP_PROT_SSL3 | NativeProtocols.SP_PROT_TLS1_1)) != NativeProtocols.SP_PROT_NONE)
- {
- message = StringsHelper.GetString(Strings.SEC_ProtocolWarning, nativeProtocol.ToFriendlyName());
- }
- return message;
- }
- }
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.cs
new file mode 100644
index 0000000000..904dc84688
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.cs
@@ -0,0 +1,140 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Data.Common;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.Data.SqlClient
+{
+ internal enum EncryptionOptions
+ {
+ OFF,
+ ON,
+ NOT_SUP,
+ REQ,
+ LOGIN,
+ OPTIONS_MASK = 0x3f,
+ CTAIP = 0x40,
+ CLIENT_CERT = 0x80,
+ }
+
+ internal sealed partial class SqlLoginAck
+ {
+ internal string programName;
+
+ internal bool isVersion8;
+ }
+
+ internal sealed partial class _SqlMetaDataSet
+ {
+ private _SqlMetaDataSet(_SqlMetaDataSet original)
+ {
+ id = original.id;
+ _hiddenColumnCount = original._hiddenColumnCount;
+ _visibleColumnMap = original._visibleColumnMap;
+ _schemaTable = original._schemaTable;
+ if (original._metaDataArray == null)
+ {
+ _metaDataArray = null;
+ }
+ else
+ {
+ _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
+ for (int idx = 0; idx < _metaDataArray.Length; idx++)
+ {
+ _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
+ }
+ }
+ }
+ }
+
+ internal sealed partial class SqlReturnValue
+ {
+ internal ushort parmIndex; //2005 or later only
+ }
+
+ internal static class SslProtocolsHelper
+ {
+ // protocol versions from native sni
+ [Flags]
+ private enum NativeProtocols
+ {
+ SP_PROT_SSL2_SERVER = 0x00000004,
+ SP_PROT_SSL2_CLIENT = 0x00000008,
+ SP_PROT_SSL3_SERVER = 0x00000010,
+ SP_PROT_SSL3_CLIENT = 0x00000020,
+ SP_PROT_TLS1_0_SERVER = 0x00000040,
+ SP_PROT_TLS1_0_CLIENT = 0x00000080,
+ SP_PROT_TLS1_1_SERVER = 0x00000100,
+ SP_PROT_TLS1_1_CLIENT = 0x00000200,
+ SP_PROT_TLS1_2_SERVER = 0x00000400,
+ SP_PROT_TLS1_2_CLIENT = 0x00000800,
+ SP_PROT_TLS1_3_SERVER = 0x00001000,
+ SP_PROT_TLS1_3_CLIENT = 0x00002000,
+ SP_PROT_SSL2 = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT,
+ SP_PROT_SSL3 = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT,
+ SP_PROT_TLS1_0 = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT,
+ SP_PROT_TLS1_1 = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT,
+ SP_PROT_TLS1_2 = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT,
+ SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
+ SP_PROT_NONE = 0x0
+ }
+
+ private static string ToFriendlyName(this NativeProtocols protocol)
+ {
+ string name;
+
+ if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
+ {
+ name = "TLS 1.3";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
+ {
+ name = "TLS 1.2";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_SERVER))
+ {
+ name = "TLS 1.1";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_SERVER))
+ {
+ name = "TLS 1.0";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
+ {
+ name = "SSL 3.0";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
+ {
+ name = "SSL 2.0";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_NONE))
+ {
+ name = "None";
+ }
+ else
+ {
+ throw new ArgumentException(StringsHelper.GetString(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
+ }
+ return name;
+ }
+
+ ///
+ /// check the negotiated secure protocol if it's under TLS 1.2
+ ///
+ ///
+ /// Localized warning message
+ public static string GetProtocolWarning(uint protocol)
+ {
+ var nativeProtocol = (NativeProtocols)protocol;
+ string message = string.Empty;
+ if ((nativeProtocol & (NativeProtocols.SP_PROT_SSL2 | NativeProtocols.SP_PROT_SSL3 | NativeProtocols.SP_PROT_TLS1_1)) != NativeProtocols.SP_PROT_NONE)
+ {
+ message = StringsHelper.GetString(Strings.SEC_ProtocolWarning, nativeProtocol.ToFriendlyName());
+ }
+ return message;
+ }
+ }
+}
From ebe5428ef940d14b3de592f5dd89bce04d012b14 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 20:23:31 +0000
Subject: [PATCH 06/14] Merged TdsParserHelperClasses.cs. Made one change to
_SqlMetaDataSet (putting the _ in _schemaTable) to get netfx to compile.
---
.../src/Microsoft.Data.SqlClient.csproj | 4 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 8 +-
.../netfx/src/Microsoft.Data.SqlClient.csproj | 4 +-
.../Data/SqlClient/TdsParserHelperClasses.cs | 698 ------------------
.../Data/SqlClient/TdsParserHelperClasses.cs | 4 +-
5 files changed, 12 insertions(+), 706 deletions(-)
delete mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
rename src/Microsoft.Data.SqlClient/{netcore => }/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs (99%)
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 c4f915c7e7..9ef7b6b0f6 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -495,6 +495,9 @@
Microsoft\Data\SqlClient\TdsParserStaticMethods.cs
+
+ Microsoft\Data\SqlClient\TdsParserHelperClasses.cs
+
Microsoft\Data\SqlClient\TdsRecordBufferSetter.cs
@@ -667,7 +670,6 @@
-
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
index cb059d4e05..3799a551af 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
@@ -1469,15 +1469,15 @@ public override DataTable GetSchemaTable()
try
{
statistics = SqlStatistics.StartTimer(Statistics);
- if (null == _metaData || null == _metaData.schemaTable)
+ if (null == _metaData || null == _metaData._schemaTable)
{
if (null != this.MetaData)
{
- _metaData.schemaTable = BuildSchemaTable();
- Debug.Assert(null != _metaData.schemaTable, "No schema information yet!");
+ _metaData._schemaTable = BuildSchemaTable();
+ Debug.Assert(null != _metaData._schemaTable, "No schema information yet!");
}
}
- return _metaData?.schemaTable;
+ return _metaData?._schemaTable;
}
finally
{
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 a709094d72..90bb5e611f 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -577,6 +577,9 @@
Microsoft\Data\SqlClient\TdsParameterSetter.cs
+
+ Microsoft\Data\SqlClient\TdsParserHelperClasses.cs
+
Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs
@@ -678,7 +681,6 @@
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
deleted file mode 100644
index 6a0300183d..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ /dev/null
@@ -1,698 +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.Collections.Generic;
-using System.Data;
-using System.Diagnostics;
-using System.Globalization;
-using System.Security;
-using System.Text;
-using Microsoft.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- internal enum CallbackType
- {
- Read = 0,
- Write = 1
- }
-
- internal enum PreLoginHandshakeStatus
- {
- Successful,
- InstanceFailure
- }
-
- internal enum PreLoginOptions
- {
- VERSION,
- ENCRYPT,
- INSTANCE,
- THREADID,
- MARS,
- TRACEID,
- FEDAUTHREQUIRED,
- NUMOPT,
- LASTOPT = 255
- }
-
- internal enum RunBehavior
- {
- UntilDone = 1, // 0001 binary
- ReturnImmediately = 2, // 0010 binary
- Clean = 5, // 0101 binary - Clean AND UntilDone
- Attention = 13 // 1101 binary - Clean AND UntilDone AND Attention
- }
-
- internal enum TdsParserState
- {
- Closed,
- OpenNotLoggedIn,
- OpenLoggedIn,
- Broken,
- }
-
- ///
- /// Class encapsulating the data to be sent to the server as part of Federated Authentication Feature Extension.
- ///
- internal class FederatedAuthenticationFeatureExtensionData
- {
- internal TdsEnums.FedAuthLibrary libraryType;
- internal bool fedAuthRequiredPreLoginResponse;
- internal SqlAuthenticationMethod authentication;
- internal byte[] accessToken;
- }
-
- internal class RoutingInfo
- {
- internal byte Protocol { get; private set; }
- internal UInt16 Port { get; private set; }
- internal string ServerName { get; private set; }
-
- internal RoutingInfo(byte protocol, UInt16 port, string servername)
- {
- Protocol = protocol;
- Port = port;
- ServerName = servername;
- }
- }
-
- sealed internal class SqlLogin
- {
- internal SqlAuthenticationMethod authentication = SqlAuthenticationMethod.NotSpecified; // Authentication type
- internal int timeout; // login timeout
- internal bool userInstance = false; // user instance
- internal string hostName = ""; // client machine name
- internal string userName = ""; // user id
- internal string password = ""; // password
- internal string applicationName = ""; // application name
- internal string serverName = ""; // server name
- internal string language = ""; // initial language
- internal string database = ""; // initial database
- internal string attachDBFilename = ""; // DB filename to be attached
- internal string newPassword = ""; // new password for reset password
- internal bool useReplication = false; // user login for replication
- internal bool useSSPI = false; // use integrated security
- internal int packetSize = SqlConnectionString.DEFAULT.Packet_Size; // packet size
- internal bool readOnlyIntent = false; // read-only intent
- internal SqlCredential credential; // user id and password in SecureString
- internal SecureString newSecurePassword; // new password in SecureString for resetting pasword
- }
-
- internal sealed partial class SqlLoginAck
- {
- internal byte majorVersion;
- internal byte minorVersion;
- internal short buildNum;
- internal UInt32 tdsVersion;
- }
-
- sealed internal class SqlFedAuthInfo
- {
- internal string spn;
- internal string stsurl;
- public override string ToString()
- {
- return String.Format(CultureInfo.InvariantCulture, "STSURL: {0}, SPN: {1}", stsurl ?? String.Empty, spn ?? String.Empty);
- }
- }
-
- sealed internal class SqlFedAuthToken
- {
- internal UInt32 dataLen;
- internal byte[] accessToken;
- internal long expirationFileTime;
- }
-
- sealed internal class _SqlMetaData : SqlMetaDataPriv
- {
- [Flags]
- private enum _SqlMetadataFlags : int
- {
- None = 0,
-
- Updatable = 1 << 0,
- UpdateableUnknown = 1 << 1,
- IsDifferentName = 1 << 2,
- IsKey = 1 << 3,
- IsHidden = 1 << 4,
- IsExpression = 1 << 5,
- IsIdentity = 1 << 6,
- IsColumnSet = 1 << 7,
-
- IsUpdatableMask = (Updatable | UpdateableUnknown) // two bit field (0 is read only, 1 is updatable, 2 is updatability unknown)
- }
-
- internal string column;
- internal string baseColumn;
- internal MultiPartTableName multiPartTableName;
- internal readonly int ordinal;
- internal byte tableNum;
- internal byte op; // for altrow-columns only
- internal ushort operand; // for altrow-columns only
- private _SqlMetadataFlags flags;
-
- internal _SqlMetaData(int ordinal) : base()
- {
- this.ordinal = ordinal;
- }
-
- private bool HasFlag(_SqlMetadataFlags flag)
- {
- return (flags & flag) != 0;
- }
-
- internal string serverName
- {
- get
- {
- return multiPartTableName.ServerName;
- }
- }
- internal string catalogName
- {
- get
- {
- return multiPartTableName.CatalogName;
- }
- }
- internal string schemaName
- {
- get
- {
- return multiPartTableName.SchemaName;
- }
- }
- internal string tableName
- {
- get
- {
- return multiPartTableName.TableName;
- }
- }
-
- public byte Updatability
- {
- get => (byte)(flags & _SqlMetadataFlags.IsUpdatableMask);
- set => flags = (_SqlMetadataFlags)((value & (byte)_SqlMetadataFlags.IsUpdatableMask) | ((int)flags & ~(byte)_SqlMetadataFlags.IsUpdatableMask));
- }
-
- public bool IsReadOnly
- {
- get => !HasFlag(_SqlMetadataFlags.IsUpdatableMask);
- }
-
- public bool IsDifferentName
- {
- get => HasFlag(_SqlMetadataFlags.IsDifferentName);
- set => Set(_SqlMetadataFlags.IsDifferentName, value);
- }
-
- public bool IsKey
- {
- get => HasFlag(_SqlMetadataFlags.IsKey);
- set => Set(_SqlMetadataFlags.IsKey, value);
- }
-
- public bool IsHidden
- {
- get => HasFlag(_SqlMetadataFlags.IsHidden);
- set => Set(_SqlMetadataFlags.IsHidden, value);
- }
-
- public bool IsExpression
- {
- get => HasFlag(_SqlMetadataFlags.IsExpression);
- set => Set(_SqlMetadataFlags.IsExpression, value);
- }
-
- public bool IsIdentity
- {
- get => HasFlag(_SqlMetadataFlags.IsIdentity);
- set => Set(_SqlMetadataFlags.IsIdentity, value);
- }
-
- public bool IsColumnSet
- {
- get => HasFlag(_SqlMetadataFlags.IsColumnSet);
- set => Set(_SqlMetadataFlags.IsColumnSet, value);
- }
-
- private void Set(_SqlMetadataFlags flag, bool value)
- {
- flags = value ? flags | flag : flags & ~flag;
- }
-
- internal bool Is2008DateTimeType
- {
- get
- {
- return SqlDbType.Date == type || SqlDbType.Time == type || SqlDbType.DateTime2 == type || SqlDbType.DateTimeOffset == type;
- }
- }
-
- internal bool IsLargeUdt
- {
- get
- {
- return type == SqlDbType.Udt && length == Int32.MaxValue;
- }
- }
-
- public object Clone()
- {
- _SqlMetaData result = new _SqlMetaData(ordinal);
- result.CopyFrom(this);
- result.column = column;
- result.baseColumn = baseColumn;
- result.multiPartTableName = multiPartTableName;
- result.tableNum = tableNum;
- result.flags = flags;
- result.op = op;
- result.operand = operand;
- return result;
- }
- }
-
- internal sealed partial class _SqlMetaDataSet
- {
- internal ushort id; // for altrow-columns only
-
- internal DataTable _schemaTable;
- private readonly _SqlMetaData[] _metaDataArray;
-
- private int _hiddenColumnCount;
- private int[] _visibleColumnMap;
-
- internal _SqlMetaDataSet(int count)
- {
- _hiddenColumnCount = -1;
- _metaDataArray = new _SqlMetaData[count];
- for (int i = 0; i < _metaDataArray.Length; ++i)
- {
- _metaDataArray[i] = new _SqlMetaData(i);
- }
- }
-
- internal int VisibleColumnCount
- {
- get
- {
- if (_hiddenColumnCount == -1)
- {
- SetupHiddenColumns();
- }
- return Length - _hiddenColumnCount;
- }
- }
-
- internal int Length
- {
- get
- {
- return _metaDataArray.Length;
- }
- }
-
- internal _SqlMetaData this[int index]
- {
- get
- {
- return _metaDataArray[index];
- }
- set
- {
- Debug.Assert(null == value, "used only by SqlBulkCopy");
- _metaDataArray[index] = value;
- }
- }
-
- public int GetVisibleColumnIndex(int index)
- {
- if (_hiddenColumnCount == -1)
- {
- SetupHiddenColumns();
- }
- if (_visibleColumnMap is null)
- {
- return index;
- }
- else
- {
- return _visibleColumnMap[index];
- }
- }
-
- public _SqlMetaDataSet Clone()
- {
- return new _SqlMetaDataSet(this);
- }
-
- private void SetupHiddenColumns()
- {
- int hiddenColumnCount = 0;
- for (int index = 0; index < Length; index++)
- {
- if (_metaDataArray[index].IsHidden)
- {
- hiddenColumnCount += 1;
- }
- }
-
- if (hiddenColumnCount > 0)
- {
- int[] visibleColumnMap = new int[Length - hiddenColumnCount];
- int mapIndex = 0;
- for (int metaDataIndex = 0; metaDataIndex < Length; metaDataIndex++)
- {
- if (!_metaDataArray[metaDataIndex].IsHidden)
- {
- visibleColumnMap[mapIndex] = metaDataIndex;
- mapIndex += 1;
- }
- }
- _visibleColumnMap = visibleColumnMap;
- }
- _hiddenColumnCount = hiddenColumnCount;
- }
- }
-
- sealed internal class _SqlMetaDataSetCollection
- {
- private readonly List<_SqlMetaDataSet> altMetaDataSetArray;
- internal _SqlMetaDataSet metaDataSet;
-
- internal _SqlMetaDataSetCollection()
- {
- altMetaDataSetArray = new List<_SqlMetaDataSet>();
- }
-
- internal void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
- {
- // VSTFDEVDIV 479675: if altmetadata with same id is found, override it rather than adding a new one
- int newId = altMetaDataSet.id;
- for (int i = 0; i < altMetaDataSetArray.Count; i++)
- {
- if (altMetaDataSetArray[i].id == newId)
- {
- // override the existing metadata with the same id
- altMetaDataSetArray[i] = altMetaDataSet;
- return;
- }
- }
-
- // if we did not find metadata to override, add as new
- altMetaDataSetArray.Add(altMetaDataSet);
- }
-
- internal _SqlMetaDataSet GetAltMetaData(int id)
- {
- foreach (_SqlMetaDataSet altMetaDataSet in altMetaDataSetArray)
- {
- if (altMetaDataSet.id == id)
- {
- return altMetaDataSet;
- }
- }
- Debug.Fail("Can't match up altMetaDataSet with given id");
- return null;
- }
-
- public object Clone()
- {
- _SqlMetaDataSetCollection result = new _SqlMetaDataSetCollection();
- result.metaDataSet = metaDataSet == null ? null : metaDataSet.Clone();
- foreach (_SqlMetaDataSet set in altMetaDataSetArray)
- {
- result.altMetaDataSetArray.Add(set.Clone());
- }
- return result;
- }
- }
-
- internal partial class SqlMetaDataPriv
- {
- [Flags]
- private enum SqlMetaDataPrivFlags : byte
- {
- None = 0,
- IsNullable = 1 << 1,
- IsMultiValued = 1 << 2
- }
-
- internal SqlDbType type; // SqlDbType enum value
- internal byte tdsType; // underlying tds type
- internal byte precision = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
- internal byte scale = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
- private SqlMetaDataPrivFlags flags;
- internal int length;
- internal SqlCollation collation;
- internal int codePage;
- internal Encoding encoding;
- internal MetaType metaType; // cached metaType
- public SqlMetaDataUdt udt;
- public SqlMetaDataXmlSchemaCollection xmlSchemaCollection;
-
- internal SqlMetaDataPriv()
- {
- }
-
- public bool IsNullable
- {
- get => HasFlag(SqlMetaDataPrivFlags.IsNullable);
- set => Set(SqlMetaDataPrivFlags.IsNullable, value);
- }
-
- public bool IsMultiValued
- {
- get => HasFlag(SqlMetaDataPrivFlags.IsMultiValued);
- set => Set(SqlMetaDataPrivFlags.IsMultiValued, value);
- }
-
- private bool HasFlag(SqlMetaDataPrivFlags flag)
- {
- return (flags & flag) != 0;
- }
-
- private void Set(SqlMetaDataPrivFlags flag, bool value)
- {
- flags = value ? flags | flag : flags & ~flag;
- }
-
- internal virtual void CopyFrom(SqlMetaDataPriv original)
- {
- this.type = original.type;
- this.tdsType = original.tdsType;
- this.precision = original.precision;
- this.scale = original.scale;
- this.length = original.length;
- this.collation = original.collation;
- this.codePage = original.codePage;
- this.encoding = original.encoding;
- this.metaType = original.metaType;
- this.flags = original.flags;
-
- if (original.udt != null)
- {
- udt = new SqlMetaDataUdt();
- udt.CopyFrom(original.udt);
- }
-
- if (original.xmlSchemaCollection != null)
- {
- xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
- xmlSchemaCollection.CopyFrom(original.xmlSchemaCollection);
- }
- }
- }
-
- sealed internal class SqlMetaDataXmlSchemaCollection
- {
- internal string Database;
- internal string OwningSchema;
- internal string Name;
-
- public void CopyFrom(SqlMetaDataXmlSchemaCollection original)
- {
- if (original != null)
- {
- Database = original.Database;
- OwningSchema = original.OwningSchema;
- Name = original.Name;
- }
- }
- }
-
- sealed internal class SqlMetaDataUdt
- {
- internal Type Type;
- internal string DatabaseName;
- internal string SchemaName;
- internal string TypeName;
- internal string AssemblyQualifiedName;
-
- public void CopyFrom(SqlMetaDataUdt original)
- {
- if (original != null)
- {
- Type = original.Type;
- DatabaseName = original.DatabaseName;
- SchemaName = original.SchemaName;
- TypeName = original.TypeName;
- AssemblyQualifiedName = original.AssemblyQualifiedName;
- }
- }
- }
-
- sealed internal class _SqlRPC
- {
- internal string rpcName;
- internal ushort ProcID; // Used instead of name
- internal ushort options;
-
- internal SqlParameter[] systemParams;
- internal byte[] systemParamOptions;
- internal int systemParamCount;
-
- internal SqlParameterCollection userParams;
- internal long[] userParamMap;
- internal int userParamCount;
-
- internal int? recordsAffected;
- internal int cumulativeRecordsAffected;
-
- internal int errorsIndexStart;
- internal int errorsIndexEnd;
- internal SqlErrorCollection errors;
-
- internal int warningsIndexStart;
- internal int warningsIndexEnd;
- internal SqlErrorCollection warnings;
- internal bool needsFetchParameterEncryptionMetadata;
-
- internal SqlBatchCommand batchCommand;
-
- internal string GetCommandTextOrRpcName()
- {
- if (TdsEnums.RPC_PROCID_EXECUTESQL == ProcID)
- {
- // Param 0 is the actual sql executing
- return (string)systemParams[0].Value;
- }
- else
- {
- return rpcName;
- }
- }
-
- internal SqlParameter GetParameterByIndex(int index, out byte options)
- {
- SqlParameter retval;
- if (index < systemParamCount)
- {
- retval = systemParams[index];
- options = systemParamOptions[index];
- }
- else
- {
- long data = userParamMap[index - systemParamCount];
- int paramIndex = (int)(data & int.MaxValue);
- options = (byte)((data >> 32) & 0xFF);
- retval = userParams[paramIndex];
- }
- return retval;
- }
- }
-
- internal sealed partial class SqlReturnValue : SqlMetaDataPriv
- {
- internal string parameter;
- internal readonly SqlBuffer value;
-
- internal SqlReturnValue() : base()
- {
- value = new SqlBuffer();
- }
- }
-
- internal struct MultiPartTableName
- {
- private string _multipartName;
- private string _serverName;
- private string _catalogName;
- private string _schemaName;
- private string _tableName;
-
- internal MultiPartTableName(string[] parts)
- {
- _multipartName = null;
- _serverName = parts[0];
- _catalogName = parts[1];
- _schemaName = parts[2];
- _tableName = parts[3];
- }
-
- internal MultiPartTableName(string multipartName)
- {
- _multipartName = multipartName;
- _serverName = null;
- _catalogName = null;
- _schemaName = null;
- _tableName = null;
- }
-
- internal string ServerName
- {
- get
- {
- ParseMultipartName();
- return _serverName;
- }
- set { _serverName = value; }
- }
- internal string CatalogName
- {
- get
- {
- ParseMultipartName();
- return _catalogName;
- }
- set { _catalogName = value; }
- }
- internal string SchemaName
- {
- get
- {
- ParseMultipartName();
- return _schemaName;
- }
- set { _schemaName = value; }
- }
- internal string TableName
- {
- get
- {
- ParseMultipartName();
- return _tableName;
- }
- set { _tableName = value; }
- }
-
- private void ParseMultipartName()
- {
- if (null != _multipartName)
- {
- string[] parts = MultipartIdentifier.ParseMultipartIdentifier(_multipartName, "[\"", "]\"", Strings.SQL_TDSParserTableName, false);
- _serverName = parts[0];
- _catalogName = parts[1];
- _schemaName = parts[2];
- _tableName = parts[3];
- _multipartName = null;
- }
- }
-
- internal static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index 2b7969c42d..621fff894b 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -102,7 +102,7 @@ internal sealed class SqlLogin
internal SecureString newSecurePassword;
}
- internal sealed class SqlLoginAck
+ internal sealed partial class SqlLoginAck
{
internal byte majorVersion;
internal byte minorVersion;
@@ -281,7 +281,7 @@ internal sealed partial class _SqlMetaDataSet
{
internal ushort id; // for altrow-columns only
- internal DataTable schemaTable;
+ internal DataTable _schemaTable;
private readonly _SqlMetaData[] _metaDataArray;
private int _hiddenColumnCount;
From 6b29f40fdc95b57fff6a1ab3c3736259e210e6a9 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Wed, 28 Feb 2024 20:57:07 +0000
Subject: [PATCH 07/14] Applied coding style to the merged TdsParserClasses.cs
file. Less confident in this - a lot of fields were internal which I think
would more properly be public.
---
.../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 90 +--
.../Microsoft/Data/SqlClient/SqlCommand.cs | 200 +++----
.../Microsoft/Data/SqlClient/SqlConnection.cs | 16 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 312 +++++-----
.../Microsoft/Data/SqlClient/SqlDbColumn.cs | 20 +-
.../SqlClient/SqlInternalConnectionTds.cs | 84 +--
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 510 ++++++++--------
.../TdsParserHelperClasses.NetCoreApp.cs | 22 +-
.../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 92 +--
.../Microsoft/Data/SqlClient/SqlCommand.cs | 212 +++----
.../Microsoft/Data/SqlClient/SqlConnection.cs | 16 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 300 +++++-----
.../SqlClient/SqlInternalConnectionTds.cs | 86 +--
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 560 +++++++++---------
.../SqlClient/TdsParserHelperClasses.netfx.cs | 8 +-
...rectoryAuthenticationTimeoutRetryHelper.cs | 2 +-
.../Data/SqlClient/SqlAuthenticationToken.cs | 6 +-
.../Data/SqlClient/SqlCachedBuffer.cs | 2 +-
.../Microsoft/Data/SqlClient/SqlParameter.cs | 18 +-
.../Data/SqlClient/TdsParserHelperClasses.cs | 284 +++++----
20 files changed, 1425 insertions(+), 1415 deletions(-)
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
index 12364261b5..04d25e55dc 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
@@ -556,7 +556,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
rejectColumn = false;
// Check for excluded types
- if ((metadata.type == SqlDbType.Timestamp)
+ if ((metadata._type == SqlDbType.Timestamp)
|| ((metadata.IsIdentity) && !IsCopyOption(SqlBulkCopyOptions.KeepIdentity)))
{
// Remove metadata for excluded columns
@@ -569,8 +569,8 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
int assocId;
for (assocId = 0; assocId < _localColumnMappings.Count; assocId++)
{
- if ((_localColumnMappings[assocId]._destinationColumnOrdinal == metadata.ordinal) ||
- (UnquotedName(_localColumnMappings[assocId]._destinationColumnName) == metadata.column))
+ if ((_localColumnMappings[assocId]._destinationColumnOrdinal == metadata._ordinal) ||
+ (UnquotedName(_localColumnMappings[assocId]._destinationColumnName) == metadata._column))
{
if (rejectColumn)
{
@@ -579,7 +579,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
_sortedColumnMappings.Add(new _ColumnMapping(_localColumnMappings[assocId]._internalSourceColumnOrdinal, metadata));
- destColumnNames.Add(metadata.column);
+ destColumnNames.Add(metadata._column);
nmatched++;
if (nmatched > 1)
@@ -588,25 +588,25 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
// Some datatypes need special handling ...
- if (metadata.type == SqlDbType.Variant)
+ if (metadata._type == SqlDbType.Variant)
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, "sql_variant");
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata._column, "sql_variant");
}
- else if (metadata.type == SqlDbType.Udt)
+ else if (metadata._type == SqlDbType.Udt)
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, "varbinary");
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata._column, "varbinary");
}
else
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, metadata.type.ToString());
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata._column, metadata._type.ToString());
}
- switch (metadata.metaType.NullableType)
+ switch (metadata._metaType.NullableType)
{
case TdsEnums.SQLNUMERICN:
case TdsEnums.SQLDECIMALN:
// Decimal and numeric need to include precision and scale
- updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0},{1})", metadata.precision, metadata.scale);
+ updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0},{1})", metadata._precision, metadata._scale);
break;
case TdsEnums.SQLUDT:
{
@@ -616,7 +616,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
else
{
- int size = metadata.length;
+ int size = metadata._length;
updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", size);
}
break;
@@ -625,15 +625,15 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
case TdsEnums.SQLDATETIME2:
case TdsEnums.SQLDATETIMEOFFSET:
// date, dateime2, and datetimeoffset need to include scale
- updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", metadata.scale);
+ updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", metadata._scale);
break;
default:
{
// For non-long non-fixed types we need to add the Size
- if (!metadata.metaType.IsFixed && !metadata.metaType.IsLong)
+ if (!metadata._metaType.IsFixed && !metadata._metaType.IsLong)
{
- int size = metadata.length;
- switch (metadata.metaType.NullableType)
+ int size = metadata._length;
+ switch (metadata._metaType.NullableType)
{
case TdsEnums.SQLNCHAR:
case TdsEnums.SQLNVARCHAR:
@@ -645,7 +645,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", size);
}
- else if (metadata.metaType.IsPlp && metadata.metaType.SqlDbType != SqlDbType.Xml)
+ else if (metadata._metaType.IsPlp && metadata._metaType.SqlDbType != SqlDbType.Xml)
{
// Partial length column prefix (max)
updateBulkCommandText.Append("(max)");
@@ -659,7 +659,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
object rowvalue = rowset[i][CollationId];
bool shouldSendCollation;
- switch (metadata.type)
+ switch (metadata._type)
{
case SqlDbType.Char:
case SqlDbType.NChar:
@@ -683,15 +683,15 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
{
updateBulkCommandText.Append(" COLLATE " + collation_name.Value);
// Compare collations only if the collation value was set on the metadata
- if (null != _sqlDataReaderRowSource && metadata.collation != null)
+ if (null != _sqlDataReaderRowSource && metadata._collation != null)
{
// On SqlDataReader we can verify the sourcecolumn collation!
int sourceColumnId = _localColumnMappings[assocId]._internalSourceColumnOrdinal;
- int destinationLcid = metadata.collation.LCID;
+ int destinationLcid = metadata._collation.LCID;
int sourceLcid = _sqlDataReaderRowSource.GetLocaleId(sourceColumnId);
if (sourceLcid != destinationLcid)
{
- throw SQL.BulkLoadLcidMismatch(sourceLcid, _sqlDataReaderRowSource.GetName(sourceColumnId), destinationLcid, metadata.column);
+ throw SQL.BulkLoadLcidMismatch(sourceLcid, _sqlDataReaderRowSource.GetName(sourceColumnId), destinationLcid, metadata._column);
}
}
}
@@ -958,7 +958,7 @@ private object GetValueFromSourceRow(int destRowIndex, out bool isSqlType, out b
object value = _sqlDataReaderRowSource.GetValue(sourceOrdinal);
isNull = ((value == null) || (value == DBNull.Value));
- if ((!isNull) && (metadata.type == SqlDbType.Udt))
+ if ((!isNull) && (metadata._type == SqlDbType.Udt))
{
var columnAsINullable = value as INullable;
isNull = (columnAsINullable != null) && columnAsINullable.IsNull;
@@ -1170,7 +1170,7 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
bool isSqlType;
bool isDataFeed;
- if (((_sqlDataReaderRowSource != null) || (_dataTableSource != null)) && ((metadata.metaType.NullableType == TdsEnums.SQLDECIMALN) || (metadata.metaType.NullableType == TdsEnums.SQLNUMERICN)))
+ if (((_sqlDataReaderRowSource != null) || (_dataTableSource != null)) && ((metadata._metaType.NullableType == TdsEnums.SQLDECIMALN) || (metadata._metaType.NullableType == TdsEnums.SQLNUMERICN)))
{
isDataFeed = false;
@@ -1213,28 +1213,28 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
}
// Check for data streams
- else if ((_enableStreaming) && (metadata.length == MAX_LENGTH))
+ else if ((_enableStreaming) && (metadata._length == MAX_LENGTH))
{
isSqlType = false;
if (_sqlDataReaderRowSource != null)
{
// MetaData property is not set for SMI, but since streaming is disabled we do not need it
- MetaType mtSource = _sqlDataReaderRowSource.MetaData[sourceOrdinal].metaType;
+ MetaType mtSource = _sqlDataReaderRowSource.MetaData[sourceOrdinal]._metaType;
// There is no memory gain for non-sequential access for binary
- if ((metadata.type == SqlDbType.VarBinary) && (mtSource.IsBinType) && (mtSource.SqlDbType != SqlDbType.Timestamp) && _sqlDataReaderRowSource.IsCommandBehavior(CommandBehavior.SequentialAccess))
+ if ((metadata._type == SqlDbType.VarBinary) && (mtSource.IsBinType) && (mtSource.SqlDbType != SqlDbType.Timestamp) && _sqlDataReaderRowSource.IsCommandBehavior(CommandBehavior.SequentialAccess))
{
isDataFeed = true;
method = ValueMethod.DataFeedStream;
}
// For text and XML there is memory gain from streaming on destination side even if reader is non-sequential
- else if (((metadata.type == SqlDbType.VarChar) || (metadata.type == SqlDbType.NVarChar)) && (mtSource.IsCharType) && (mtSource.SqlDbType != SqlDbType.Xml))
+ else if (((metadata._type == SqlDbType.VarChar) || (metadata._type == SqlDbType.NVarChar)) && (mtSource.IsCharType) && (mtSource.SqlDbType != SqlDbType.Xml))
{
isDataFeed = true;
method = ValueMethod.DataFeedText;
}
- else if ((metadata.type == SqlDbType.Xml) && (mtSource.SqlDbType == SqlDbType.Xml))
+ else if ((metadata._type == SqlDbType.Xml) && (mtSource.SqlDbType == SqlDbType.Xml))
{
isDataFeed = true;
method = ValueMethod.DataFeedXml;
@@ -1247,12 +1247,12 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
else if (_dbDataReaderRowSource != null)
{
- if (metadata.type == SqlDbType.VarBinary)
+ if (metadata._type == SqlDbType.VarBinary)
{
isDataFeed = true;
method = ValueMethod.DataFeedStream;
}
- else if ((metadata.type == SqlDbType.VarChar) || (metadata.type == SqlDbType.NVarChar))
+ else if ((metadata._type == SqlDbType.VarChar) || (metadata._type == SqlDbType.NVarChar))
{
isDataFeed = true;
method = ValueMethod.DataFeedText;
@@ -1451,28 +1451,28 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
if (!metadata.IsNullable)
{
- throw SQL.BulkLoadBulkLoadNotAllowDBNull(metadata.column);
+ throw SQL.BulkLoadBulkLoadNotAllowDBNull(metadata._column);
}
return value;
}
- MetaType type = metadata.metaType;
+ MetaType type = metadata._metaType;
bool typeChanged = false;
// If the column is encrypted then we are going to transparently encrypt this column
// (based on connection string setting)- Use the metaType for the underlying
// value (unencrypted value) for conversion/casting purposes (below).
// Note - this flag is set if connection string options has TCE turned on
- byte scale = metadata.scale;
- byte precision = metadata.precision;
- int length = metadata.length;
+ byte scale = metadata._scale;
+ byte precision = metadata._precision;
+ int length = metadata._length;
if (metadata._isEncrypted)
{
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- type = metadata._baseTI.metaType;
- scale = metadata._baseTI.scale;
- precision = metadata._baseTI.precision;
- length = metadata._baseTI.length;
+ type = metadata._baseTI._metaType;
+ scale = metadata._baseTI._scale;
+ precision = metadata._baseTI._precision;
+ length = metadata._baseTI._length;
}
try
@@ -1513,7 +1513,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
}
catch (SqlTruncateException)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata._ordinal, RowNumber, metadata._isEncrypted, metadata._column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
}
}
@@ -1568,7 +1568,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
// https://blogs.msdn.microsoft.com/sql_server_team/string-or-binary-data-would-be-truncated-replacing-the-infamous-error-8152/
str = str.Remove(Math.Min(maxStringLength, 100));
}
- throw SQL.BulkLoadStringTooLong(_destinationTableName, metadata.column, str);
+ throw SQL.BulkLoadStringTooLong(_destinationTableName, metadata._column, str);
}
}
break;
@@ -1602,7 +1602,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
default:
Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), null);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata._ordinal, RowNumber, metadata._isEncrypted, metadata._column, value.ToString(), null);
}
if (typeChanged)
@@ -1619,7 +1619,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
throw;
}
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata._isEncrypted, metadata.column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata._ordinal, RowNumber, metadata._isEncrypted, metadata._column, value.ToString(), e);
}
}
@@ -2170,14 +2170,14 @@ private Task ReadWriteColumnValueAsync(int col)
metadata._isEncrypted)
{ // If we are transparently encrypting
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- value = _parser.EncryptColumnValue(value, metadata, metadata.column, _stateObj, isDataFeed, isSqlType);
+ value = _parser.EncryptColumnValue(value, metadata, metadata._column, _stateObj, isDataFeed, isSqlType);
isSqlType = false; // Its not a sql type anymore
}
}
//write part
Task writeTask = null;
- if (metadata.type != SqlDbType.Variant)
+ if (metadata._type != SqlDbType.Variant)
{
//this is the most common path
writeTask = _parser.WriteBulkCopyValue(value, metadata, _stateObj, isSqlType, isDataFeed, isNull); //returns Task/Null
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
index ced7863f55..d5ee81f0b8 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
@@ -4169,9 +4169,9 @@ private SqlDataReader TryFetchInputParameterEncryptionInfo(int timeout,
{
// In BatchRPCMode, the actual T-SQL query is in the first parameter and not present as the rpcName, as is the case with non-BatchRPCMode.
// So input parameters start at parameters[1]. parameters[0] is the actual T-SQL Statement. rpcName is sp_executesql.
- if (_RPCList[i].systemParams.Length > 1)
+ if (_RPCList[i]._systemParams.Length > 1)
{
- _RPCList[i].needsFetchParameterEncryptionMetadata = true;
+ _RPCList[i]._needsFetchParameterEncryptionMetadata = true;
// Since we are going to need multiple RPC objects, allocate a new one here for each command in the batch.
_SqlRPC rpcDescribeParameterEncryptionRequest = new _SqlRPC();
@@ -4218,8 +4218,8 @@ private SqlDataReader TryFetchInputParameterEncryptionInfo(int timeout,
GetRPCObject(0, GetParameterCount(_parameters), ref rpc);
Debug.Assert(rpc != null, "GetRPCObject should not return rpc as null.");
- rpc.rpcName = CommandText;
- rpc.userParams = _parameters;
+ rpc._rpcName = CommandText;
+ rpc._userParams = _parameters;
// Prepare the RPC request for describe parameter encryption procedure.
PrepareDescribeParameterEncryptionRequest(rpc, ref _sqlRPCParameterEncryptionReqArray[0], serializedAttestationParameters);
@@ -4270,7 +4270,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// sp_describe_parameter_encryption always has 2 parameters (stmt, paramlist).
// sp_describe_parameter_encryption can have an optional 3rd parameter (attestationParameters), used to identify and execute attestation protocol
GetRPCObject(attestationParameters == null ? 2 : 3, 0, ref describeParameterEncryptionRequest, forSpDescribeParameterEncryption: true);
- describeParameterEncryptionRequest.rpcName = "sp_describe_parameter_encryption";
+ describeParameterEncryptionRequest._rpcName = "sp_describe_parameter_encryption";
// Prepare @tsql parameter
string text;
@@ -4278,11 +4278,11 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// In _batchRPCMode, The actual T-SQL query is in the first parameter and not present as the rpcName, as is the case with non-_batchRPCMode.
if (_batchRPCMode)
{
- Debug.Assert(originalRpcRequest.systemParamCount > 0,
+ Debug.Assert(originalRpcRequest._systemParamCount > 0,
"originalRpcRequest didn't have at-least 1 parameter in _batchRPCMode, in PrepareDescribeParameterEncryptionRequest.");
- text = (string)originalRpcRequest.systemParams[0].Value;
+ text = (string)originalRpcRequest._systemParams[0].Value;
//@tsql
- SqlParameter tsqlParam = describeParameterEncryptionRequest.systemParams[0];
+ SqlParameter tsqlParam = describeParameterEncryptionRequest._systemParams[0];
tsqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
tsqlParam.Value = text;
tsqlParam.Size = text.Length;
@@ -4290,17 +4290,17 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
}
else
{
- text = originalRpcRequest.rpcName;
+ text = originalRpcRequest._rpcName;
if (CommandType == CommandType.StoredProcedure)
{
// For stored procedures, we need to prepare @tsql in the following format
// N'EXEC sp_name @param1=@param1, @param1=@param2, ..., @paramN=@paramN'
- describeParameterEncryptionRequest.systemParams[0] = BuildStoredProcedureStatementForColumnEncryption(text, originalRpcRequest.userParams);
+ describeParameterEncryptionRequest._systemParams[0] = BuildStoredProcedureStatementForColumnEncryption(text, originalRpcRequest._userParams);
}
else
{
//@tsql
- SqlParameter tsqlParam = describeParameterEncryptionRequest.systemParams[0];
+ SqlParameter tsqlParam = describeParameterEncryptionRequest._systemParams[0];
tsqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
tsqlParam.Value = text;
tsqlParam.Size = text.Length;
@@ -4316,9 +4316,9 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
if (_batchRPCMode)
{
// systemParamCount == 2 when user parameters are supplied to BuildExecuteSql
- if (originalRpcRequest.systemParamCount > 1)
+ if (originalRpcRequest._systemParamCount > 1)
{
- parameterList = (string)originalRpcRequest.systemParams[1].Value;
+ parameterList = (string)originalRpcRequest._systemParams[1].Value;
}
}
else
@@ -4327,11 +4327,11 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// Need to create new parameters as we cannot have the same parameter being part of two SqlCommand objects
SqlParameterCollection tempCollection = new SqlParameterCollection();
- if (originalRpcRequest.userParams != null)
+ if (originalRpcRequest._userParams != null)
{
- for (int i = 0; i < originalRpcRequest.userParams.Count; i++)
+ for (int i = 0; i < originalRpcRequest._userParams.Count; i++)
{
- SqlParameter param = originalRpcRequest.userParams[i];
+ SqlParameter param = originalRpcRequest._userParams[i];
SqlParameter paramCopy = new SqlParameter(
param.ParameterName,
param.SqlDbType,
@@ -4377,7 +4377,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
//@parameters
- SqlParameter paramsParam = describeParameterEncryptionRequest.systemParams[1];
+ SqlParameter paramsParam = describeParameterEncryptionRequest._systemParams[1];
paramsParam.SqlDbType = ((parameterList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
paramsParam.Size = parameterList.Length;
paramsParam.Value = parameterList;
@@ -4385,7 +4385,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
if (attestationParameters != null)
{
- SqlParameter attestationParametersParam = describeParameterEncryptionRequest.systemParams[2];
+ SqlParameter attestationParametersParam = describeParameterEncryptionRequest._systemParams[2];
attestationParametersParam.SqlDbType = SqlDbType.VarBinary;
attestationParametersParam.Size = attestationParameters.Length;
attestationParametersParam.Value = attestationParameters;
@@ -4566,7 +4566,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
Debug.Assert(rpc != null, "rpc should not be null here.");
- int userParamCount = rpc.userParams?.Count ?? 0;
+ int userParamCount = rpc._userParams?.Count ?? 0;
int recievedMetadataCount = 0;
if (!enclaveMetadataExists || ds.NextResult())
{
@@ -4585,7 +4585,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
for (int index = 0; index < userParamCount; index++)
{
- SqlParameter sqlParameter = rpc.userParams[index];
+ SqlParameter sqlParameter = rpc._userParams[index];
Debug.Assert(sqlParameter != null, "sqlParameter should not be null.");
if (SqlParameter.ParameterNamesEqual(sqlParameter.ParameterName,parameterName,StringComparison.Ordinal))
@@ -4620,9 +4620,9 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
// This is effective only for _batchRPCMode even though we set it for non-_batchRPCMode also,
// since for non-_batchRPCMode mode, paramoptions gets thrown away and reconstructed in BuildExecuteSql.
- int options = (int)(rpc.userParamMap[index] >> 32);
+ int options = (int)(rpc._userParamMap[index] >> 32);
options |= TdsEnums.RPC_PARAM_ENCRYPTED;
- rpc.userParamMap[index] = ((((long)options) << 32) | (long)index);
+ rpc._userParamMap[index] = ((((long)options) << 32) | (long)index);
}
break;
@@ -4638,7 +4638,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
for (int index = 0; index < userParamCount; index++)
{
- SqlParameter sqlParameter = rpc.userParams[index];
+ SqlParameter sqlParameter = rpc._userParams[index];
if (!sqlParameter.HasReceivedMetadata && sqlParameter.Direction != ParameterDirection.ReturnValue)
{
// Encryption MD wasn't sent by the server - we expect the metadata to be sent for all the parameters
@@ -4699,7 +4699,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
}
// The server has responded with encryption related information for this rpc request. So clear the needsFetchParameterEncryptionMetadata flag.
- rpc.needsFetchParameterEncryptionMetadata = false;
+ rpc._needsFetchParameterEncryptionMetadata = false;
} while (ds.NextResult());
// Verify that we received response for each rpc call needs tce
@@ -4707,9 +4707,9 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
for (int i = 0; i < _RPCList.Count; i++)
{
- if (_RPCList[i].needsFetchParameterEncryptionMetadata)
+ if (_RPCList[i]._needsFetchParameterEncryptionMetadata)
{
- throw SQL.ProcEncryptionMetadataMissing(_RPCList[i].rpcName);
+ throw SQL.ProcEncryptionMetadataMissing(_RPCList[i]._rpcName);
}
}
}
@@ -5105,10 +5105,10 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi
BuildExecuteSql(cmdBehavior, null, _parameters, ref rpc);
}
- rpc.options = TdsEnums.RPC_NOMETADATA;
+ rpc._options = TdsEnums.RPC_NOMETADATA;
if (returnStream)
{
- SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?.rpcName);
+ SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?._rpcName);
}
Debug.Assert(_rpcArrayOf1[0] == rpc);
@@ -5126,7 +5126,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi
optionSettings = GetSetOptionsString(cmdBehavior);
if (returnStream)
{
- SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?.rpcName);
+ SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?._rpcName);
}
// turn set options ON
@@ -5582,29 +5582,29 @@ private static void OnDone(TdsParserStateObject stateObj, int index, IList<_SqlR
// track the records affected for the just completed rpc batch
// _rowsAffected is cumulative for ExecuteNonQuery across all rpc batches
- current.cumulativeRecordsAffected = rowsAffected;
+ current._cumulativeRecordsAffected = rowsAffected;
- current.recordsAffected =
+ current._recordsAffected =
(((previous != null) && (0 <= rowsAffected))
- ? (rowsAffected - Math.Max(previous.cumulativeRecordsAffected, 0))
+ ? (rowsAffected - Math.Max(previous._cumulativeRecordsAffected, 0))
: rowsAffected);
- if (current.batchCommand != null)
+ if (current._batchCommand != null)
{
- current.batchCommand.SetRecordAffected(current.recordsAffected.GetValueOrDefault());
+ current._batchCommand.SetRecordAffected(current._recordsAffected.GetValueOrDefault());
}
// track the error collection (not available from TdsParser after ExecuteNonQuery)
// and the which errors are associated with the just completed rpc batch
- current.errorsIndexStart = previous?.errorsIndexEnd ?? 0;
- current.errorsIndexEnd = stateObj.ErrorCount;
- current.errors = stateObj._errors;
+ current._errorsIndexStart = previous?._errorsIndexEnd ?? 0;
+ current._errorsIndexEnd = stateObj.ErrorCount;
+ current._errors = stateObj._errors;
// track the warning collection (not available from TdsParser after ExecuteNonQuery)
// and the which warnings are associated with the just completed rpc batch
- current.warningsIndexStart = previous?.warningsIndexEnd ?? 0;
- current.warningsIndexEnd = stateObj.WarningCount;
- current.warnings = stateObj._warnings;
+ current._warningsIndexStart = previous?._warningsIndexEnd ?? 0;
+ current._warningsIndexEnd = stateObj.WarningCount;
+ current._warnings = stateObj._warnings;
}
internal void OnReturnStatus(int status)
@@ -5620,7 +5620,7 @@ internal void OnReturnStatus(int status)
{
if (_RPCList.Count > _currentlyExecutingBatch)
{
- parameters = _RPCList[_currentlyExecutingBatch].userParams;
+ parameters = _RPCList[_currentlyExecutingBatch]._userParams;
}
else
{
@@ -5671,9 +5671,9 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
{
if (_inPrepare)
{
- if (!rec.value.IsNull)
+ if (!rec._value.IsNull)
{
- _prepareHandle = rec.value.Int32;
+ _prepareHandle = rec._value.Int32;
}
_inPrepare = false;
return;
@@ -5682,7 +5682,7 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
SqlParameterCollection parameters = GetCurrentParameterCollection();
int count = GetParameterCount(parameters);
- SqlParameter thisParam = GetParameterForOutputValueExtraction(parameters, rec.parameter, count);
+ SqlParameter thisParam = GetParameterForOutputValueExtraction(parameters, rec._parameter, count);
if (null != thisParam)
{
@@ -5694,9 +5694,9 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
thisParam.Direction == ParameterDirection.InputOutput ||
thisParam.Direction == ParameterDirection.ReturnValue))
{
- if (rec.tdsType != TdsEnums.SQLBIGVARBINARY)
+ if (rec._tdsType != TdsEnums.SQLBIGVARBINARY)
{
- throw SQL.InvalidDataTypeForEncryptedParameter(thisParam.GetPrefixedParameterName(), rec.tdsType, TdsEnums.SQLBIGVARBINARY);
+ throw SQL.InvalidDataTypeForEncryptedParameter(thisParam.GetPrefixedParameterName(), rec._tdsType, TdsEnums.SQLBIGVARBINARY);
}
// Decrypt the ciphertext
@@ -5706,7 +5706,7 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
throw ADP.ClosedConnectionError();
}
- if (!rec.value.IsNull)
+ if (!rec._value.IsNull)
{
try
{
@@ -5714,7 +5714,7 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
// Get the key information from the parameter and decrypt the value.
rec._cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec._cipherMD, _activeConnection, this);
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec._value.ByteArray, rec._cipherMD, _activeConnection, this);
if (unencryptedBytes != null)
{
@@ -5758,13 +5758,13 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
Connection.CheckGetExtendedUDTInfo(rec, true);
//extract the byte array from the param value
- if (rec.value.IsNull)
+ if (rec._value.IsNull)
{
data = DBNull.Value;
}
else
{
- data = rec.value.ByteArray; //should work for both sql and non-sql values
+ data = rec._value.ByteArray; //should work for both sql and non-sql values
}
//call the connection to instantiate the UDT object
@@ -5787,21 +5787,21 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
}
else
{
- thisParam.SetSqlBuffer(rec.value);
+ thisParam.SetSqlBuffer(rec._value);
}
- MetaType mt = MetaType.GetMetaTypeFromSqlDbType(rec.type, false);
+ MetaType mt = MetaType.GetMetaTypeFromSqlDbType(rec._type, false);
- if (rec.type == SqlDbType.Decimal)
+ if (rec._type == SqlDbType.Decimal)
{
- thisParam.ScaleInternal = rec.scale;
- thisParam.PrecisionInternal = rec.precision;
+ thisParam.ScaleInternal = rec._scale;
+ thisParam.PrecisionInternal = rec._precision;
}
else if (mt.IsVarTime)
{
- thisParam.ScaleInternal = rec.scale;
+ thisParam.ScaleInternal = rec._scale;
}
- else if (rec.type == SqlDbType.Xml)
+ else if (rec._type == SqlDbType.Xml)
{
SqlCachedBuffer cachedBuffer = (thisParam.Value as SqlCachedBuffer);
if (null != cachedBuffer)
@@ -5810,10 +5810,10 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
}
}
- if (rec.collation != null)
+ if (rec._collation != null)
{
Debug.Assert(mt.IsCharType, "Invalid collation structure for non-char type");
- thisParam.Collation = rec.collation;
+ thisParam.Collation = rec._collation;
}
}
}
@@ -5827,7 +5827,7 @@ private SqlParameterCollection GetCurrentParameterCollection()
{
if (_RPCList.Count > _currentlyExecutingBatch)
{
- return _RPCList[_currentlyExecutingBatch].userParams;
+ return _RPCList[_currentlyExecutingBatch]._userParams;
}
else
{
@@ -5910,33 +5910,33 @@ private void GetRPCObject(int systemParamCount, int userParamCount, ref _SqlRPC
}
}
- rpc.ProcID = 0;
- rpc.rpcName = null;
- rpc.options = 0;
- rpc.systemParamCount = systemParamCount;
- rpc.needsFetchParameterEncryptionMetadata = false;
+ rpc._procID = 0;
+ rpc._rpcName = null;
+ rpc._options = 0;
+ rpc._systemParamCount = systemParamCount;
+ rpc._needsFetchParameterEncryptionMetadata = false;
- int currentCount = rpc.systemParams?.Length ?? 0;
+ int currentCount = rpc._systemParams?.Length ?? 0;
// Make sure there is enough space in the parameters and paramoptions arrays
if (currentCount < systemParamCount)
{
- Array.Resize(ref rpc.systemParams, systemParamCount);
- Array.Resize(ref rpc.systemParamOptions, systemParamCount);
+ Array.Resize(ref rpc._systemParams, systemParamCount);
+ Array.Resize(ref rpc._systemParamOptions, systemParamCount);
for (int index = currentCount; index < systemParamCount; index++)
{
- rpc.systemParams[index] = new SqlParameter();
+ rpc._systemParams[index] = new SqlParameter();
}
}
for (int ii = 0; ii < systemParamCount; ii++)
{
- rpc.systemParamOptions[ii] = 0;
+ rpc._systemParamOptions[ii] = 0;
}
- if ((rpc.userParamMap?.Length ?? 0) < userParamCount)
+ if ((rpc._userParamMap?.Length ?? 0) < userParamCount)
{
- Array.Resize(ref rpc.userParamMap, userParamCount);
+ Array.Resize(ref rpc._userParamMap, userParamCount);
}
}
@@ -6004,14 +6004,14 @@ private void SetUpRPCParameters(_SqlRPC rpc, bool inSchema, SqlParameterCollecti
}
}
- rpc.userParamMap[userParamCount] = ((((long)options) << 32) | (long)index);
+ rpc._userParamMap[userParamCount] = ((((long)options) << 32) | (long)index);
userParamCount += 1;
// Must set parameter option bit for LOB_COOKIE if unfilled LazyMat blob
}
}
- rpc.userParamCount = userParamCount;
- rpc.userParams = parameters;
+ rpc._userParamCount = userParamCount;
+ rpc._userParams = parameters;
}
private _SqlRPC BuildPrepExec(CommandBehavior behavior)
@@ -6025,20 +6025,20 @@ private _SqlRPC BuildPrepExec(CommandBehavior behavior)
_SqlRPC rpc = null;
GetRPCObject(systemParameterCount, userParameterCount, ref rpc);
- rpc.ProcID = TdsEnums.RPC_PROCID_PREPEXEC;
- rpc.rpcName = TdsEnums.SP_PREPEXEC;
+ rpc._procID = TdsEnums.RPC_PROCID_PREPEXEC;
+ rpc._rpcName = TdsEnums.SP_PREPEXEC;
//@handle
- sqlParam = rpc.systemParams[0];
+ sqlParam = rpc._systemParams[0];
sqlParam.SqlDbType = SqlDbType.Int;
sqlParam.Value = _prepareHandle;
sqlParam.Size = 4;
sqlParam.Direction = ParameterDirection.InputOutput;
- rpc.systemParamOptions[0] = TdsEnums.RPC_PARAM_BYREF;
+ rpc._systemParamOptions[0] = TdsEnums.RPC_PARAM_BYREF;
//@batch_params
string paramList = BuildParamList(_stateObj.Parser, _parameters);
- sqlParam = rpc.systemParams[1];
+ sqlParam = rpc._systemParams[1];
sqlParam.SqlDbType = ((paramList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Value = paramList;
sqlParam.Size = paramList.Length;
@@ -6046,7 +6046,7 @@ private _SqlRPC BuildPrepExec(CommandBehavior behavior)
//@batch_text
string text = GetCommandText(behavior);
- sqlParam = rpc.systemParams[2];
+ sqlParam = rpc._systemParams[2];
sqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = text.Length;
sqlParam.Value = text;
@@ -6111,7 +6111,7 @@ private void BuildRPC(bool inSchema, SqlParameterCollection parameters, ref _Sql
int userParameterCount = CountSendableParameters(parameters);
GetRPCObject(0, userParameterCount, ref rpc);
- rpc.ProcID = 0;
+ rpc._procID = 0;
// TDS Protocol allows rpc name with maximum length of 1046 bytes for ProcName
// 4-part name 1 + 128 + 1 + 1 + 1 + 128 + 1 + 1 + 1 + 128 + 1 + 1 + 1 + 128 + 1 = 523
@@ -6120,7 +6120,7 @@ private void BuildRPC(bool inSchema, SqlParameterCollection parameters, ref _Sql
if (commandTextLength <= MaxRPCNameLength)
{
- rpc.rpcName = CommandText; // just get the raw command text
+ rpc._rpcName = CommandText; // just get the raw command text
}
else
{
@@ -6146,11 +6146,11 @@ private _SqlRPC BuildExecute(bool inSchema)
_SqlRPC rpc = null;
GetRPCObject(systemParameterCount, userParameterCount, ref rpc);
- rpc.ProcID = TdsEnums.RPC_PROCID_EXECUTE;
- rpc.rpcName = TdsEnums.SP_EXECUTE;
+ rpc._procID = TdsEnums.RPC_PROCID_EXECUTE;
+ rpc._rpcName = TdsEnums.SP_EXECUTE;
//@handle
- SqlParameter sqlParam = rpc.systemParams[0];
+ SqlParameter sqlParam = rpc._systemParams[0];
sqlParam.SqlDbType = SqlDbType.Int;
sqlParam.Size = 4;
sqlParam.Value = _prepareHandle;
@@ -6184,15 +6184,15 @@ private void BuildExecuteSql(CommandBehavior behavior, string commandText, SqlPa
}
GetRPCObject(systemParamCount, userParamCount, ref rpc);
- rpc.ProcID = TdsEnums.RPC_PROCID_EXECUTESQL;
- rpc.rpcName = TdsEnums.SP_EXECUTESQL;
+ rpc._procID = TdsEnums.RPC_PROCID_EXECUTESQL;
+ rpc._rpcName = TdsEnums.SP_EXECUTESQL;
// @sql
if (commandText == null)
{
commandText = GetCommandText(behavior);
}
- sqlParam = rpc.systemParams[0];
+ sqlParam = rpc._systemParams[0];
sqlParam.SqlDbType = ((commandText.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = commandText.Length;
sqlParam.Value = commandText;
@@ -6201,7 +6201,7 @@ private void BuildExecuteSql(CommandBehavior behavior, string commandText, SqlPa
if (userParamCount > 0)
{
string paramList = BuildParamList(_stateObj.Parser, _batchRPCMode ? parameters : _parameters);
- sqlParam = rpc.systemParams[1];
+ sqlParam = rpc._systemParams[1];
sqlParam.SqlDbType = ((paramList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = paramList.Length;
sqlParam.Value = paramList;
@@ -6734,7 +6734,7 @@ internal void AddBatchCommand(SqlBatchCommand batchCommand)
_SqlRPC rpc = new _SqlRPC
{
- batchCommand = batchCommand
+ _batchCommand = batchCommand
};
string commandText = batchCommand.CommandText;
CommandType cmdType = batchCommand.CommandType;
@@ -6765,24 +6765,24 @@ internal void AddBatchCommand(SqlBatchCommand batchCommand)
{
Debug.Assert(_batchRPCMode, "Command is not in batch RPC Mode");
Debug.Assert(_RPCList != null, "batch command have been cleared");
- return _RPCList[commandIndex].recordsAffected;
+ return _RPCList[commandIndex]._recordsAffected;
}
internal SqlBatchCommand GetCurrentBatchCommand()
{
if (_batchRPCMode)
{
- return _RPCList[_currentlyExecutingBatch].batchCommand;
+ return _RPCList[_currentlyExecutingBatch]._batchCommand;
}
else
{
- return _rpcArrayOf1[0].batchCommand;
+ return _rpcArrayOf1[0]._batchCommand;
}
}
internal SqlBatchCommand GetBatchCommand(int index)
{
- return _RPCList[index].batchCommand;
+ return _RPCList[index]._batchCommand;
}
internal int GetCurrentBatchIndex()
@@ -6794,17 +6794,17 @@ internal SqlException GetErrors(int commandIndex)
{
SqlException result = null;
_SqlRPC rpc = _RPCList[commandIndex];
- int length = (rpc.errorsIndexEnd - rpc.errorsIndexStart);
+ int length = (rpc._errorsIndexEnd - rpc._errorsIndexStart);
if (0 < length)
{
SqlErrorCollection errors = new SqlErrorCollection();
- for (int i = rpc.errorsIndexStart; i < rpc.errorsIndexEnd; ++i)
+ for (int i = rpc._errorsIndexStart; i < rpc._errorsIndexEnd; ++i)
{
- errors.Add(rpc.errors[i]);
+ errors.Add(rpc._errors[i]);
}
- for (int i = rpc.warningsIndexStart; i < rpc.warningsIndexEnd; ++i)
+ for (int i = rpc._warningsIndexStart; i < rpc._warningsIndexEnd; ++i)
{
- errors.Add(rpc.warnings[i]);
+ errors.Add(rpc._warnings[i]);
}
result = SqlException.CreateException(errors, Connection.ServerVersion, Connection.ClientConnectionId, innerException: null, batchCommand: null);
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
index 4b4e7ccc43..c117d8996a 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
@@ -2457,16 +2457,16 @@ private Assembly ResolveTypeAssembly(AssemblyName asmRef, bool throwOnError)
internal void CheckGetExtendedUDTInfo(SqlMetaDataPriv metaData, bool fThrow)
{
- if (metaData.udt?.Type == null)
+ if (metaData.udt?._type == null)
{ // If null, we have not obtained extended info.
- Debug.Assert(!string.IsNullOrEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
+ Debug.Assert(!string.IsNullOrEmpty(metaData.udt?._assemblyQualifiedName), "Unexpected state on GetUDTInfo");
// Parameter throwOnError determines whether exception from Assembly.Load is thrown.
- metaData.udt.Type =
- Type.GetType(typeName: metaData.udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);
+ metaData.udt._type =
+ Type.GetType(typeName: metaData.udt._assemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);
- if (fThrow && metaData.udt.Type == null)
+ if (fThrow && metaData.udt._type == null)
{
- throw SQL.UDTUnexpectedResult(metaData.udt.AssemblyQualifiedName);
+ throw SQL.UDTUnexpectedResult(metaData.udt._assemblyQualifiedName);
}
}
}
@@ -2483,7 +2483,7 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
// Since the serializer doesn't handle nulls...
if (ADP.IsNull(value))
{
- Type t = metaData.udt?.Type;
+ Type t = metaData.udt?._type;
Debug.Assert(t != null, "Unexpected null of udtType on GetUdtValue!");
o = t.InvokeMember("Null", BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Static, null, null, Array.Empty
internal sealed class SqlEncryptionKeyInfo
{
- internal byte[] _encryptedKey; // the encrypted "column encryption key"
- internal int _databaseId;
- internal int _cekId;
- internal int _cekVersion;
- internal byte[] _cekMdVersion;
- internal string _keyPath;
- internal string _keyStoreName;
- internal string _algorithmName;
+ public byte[] EncryptedKey; // the encrypted "column encryption key"
+ public int DatabaseId;
+ public int CekId;
+ public int CekVersion;
+ public byte[] CekMdVersion;
+ public string KeyPath;
+ public string KeyStoreName;
+ public string AlgorithmName;
}
///
@@ -68,7 +68,7 @@ internal sealed class SqlTceCipherInfoEntry
///
/// Return the ordinal.
///
- internal int Ordinal
+ public int Ordinal
{
get
{
@@ -79,7 +79,7 @@ internal int Ordinal
///
/// Return the DatabaseID.
///
- internal int DatabaseId
+ public int DatabaseId
{
get
{
@@ -90,7 +90,7 @@ internal int DatabaseId
///
/// Return the CEK ID.
///
- internal int CekId
+ public int CekId
{
get
{
@@ -101,7 +101,7 @@ internal int CekId
///
/// Return the CEK Version.
///
- internal int CekVersion
+ public int CekVersion
{
get
{
@@ -112,7 +112,7 @@ internal int CekVersion
///
/// Return the CEK MD Version.
///
- internal byte[] CekMdVersion
+ public byte[] CekMdVersion
{
get
{
@@ -123,7 +123,7 @@ internal byte[] CekMdVersion
///
/// Return the list of Column Encryption Key Values.
///
- internal List ColumnEncryptionKeyValues
+ public List ColumnEncryptionKeyValues
{
get
{
@@ -142,21 +142,21 @@ internal List ColumnEncryptionKeyValues
///
///
///
- internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
+ public void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
{
Debug.Assert(_columnEncryptionKeyValues != null, "_columnEncryptionKeyValues should already be initialized.");
SqlEncryptionKeyInfo encryptionKey = new SqlEncryptionKeyInfo
{
- _encryptedKey = encryptedKey,
- _databaseId = databaseId,
- _cekId = cekId,
- _cekVersion = cekVersion,
- _cekMdVersion = cekMdVersion,
- _keyPath = keyPath,
- _keyStoreName = keyStoreName,
- _algorithmName = algorithmName
+ EncryptedKey = encryptedKey,
+ DatabaseId = databaseId,
+ CekId = cekId,
+ CekVersion = cekVersion,
+ CekMdVersion = cekMdVersion,
+ KeyPath = keyPath,
+ KeyStoreName = keyStoreName,
+ AlgorithmName = algorithmName
};
_columnEncryptionKeyValues.Add(encryptionKey);
@@ -180,7 +180,7 @@ internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion
/// Constructor.
///
///
- internal SqlTceCipherInfoEntry(int ordinal = 0)
+ public SqlTceCipherInfoEntry(int ordinal = 0)
{
_ordinal = ordinal;
_databaseId = 0;
@@ -200,13 +200,13 @@ internal sealed class SqlTceCipherInfoTable
{
private readonly SqlTceCipherInfoEntry[] _keyList;
- internal SqlTceCipherInfoTable(int tabSize)
+ public SqlTceCipherInfoTable(int tabSize)
{
Debug.Assert(0 < tabSize, "Invalid Table Size");
_keyList = new SqlTceCipherInfoEntry[tabSize];
}
- internal SqlTceCipherInfoEntry this[int index]
+ public SqlTceCipherInfoEntry this[int index]
{
get
{
@@ -220,7 +220,7 @@ internal SqlTceCipherInfoEntry this[int index]
}
}
- internal int Size
+ public int Size
{
get
{
@@ -231,12 +231,12 @@ internal int Size
internal sealed partial class _SqlMetaDataSet
{
- internal readonly SqlTceCipherInfoTable _cekTable; // table of "column encryption keys" used for this metadataset
+ public readonly SqlTceCipherInfoTable CekTable; // table of "column encryption keys" used for this metadataset
- internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
+ public _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
: this(count)
{
- _cekTable = cipherTable;
+ CekTable = cipherTable;
}
}
@@ -289,7 +289,7 @@ internal sealed class SqlCipherMetadata
///
/// Return the Encryption Info Entry.
///
- internal SqlTceCipherInfoEntry EncryptionInfo
+ public SqlTceCipherInfoEntry EncryptionInfo
{
get
{
@@ -305,7 +305,7 @@ internal SqlTceCipherInfoEntry EncryptionInfo
///
/// Return the cipher's encryption algorithm id.
///
- internal byte CipherAlgorithmId
+ public byte CipherAlgorithmId
{
get
{
@@ -316,7 +316,7 @@ internal byte CipherAlgorithmId
///
/// Return the cipher's encryption algorithm name (could be null).
///
- internal string CipherAlgorithmName
+ public string CipherAlgorithmName
{
get
{
@@ -327,7 +327,7 @@ internal string CipherAlgorithmName
///
/// Return EncryptionType (Deterministic, Randomized, etc.)
///
- internal byte EncryptionType
+ public byte EncryptionType
{
get
{
@@ -338,7 +338,7 @@ internal byte EncryptionType
///
/// Return normalization rule version.
///
- internal byte NormalizationRuleVersion
+ public byte NormalizationRuleVersion
{
get
{
@@ -349,7 +349,7 @@ internal byte NormalizationRuleVersion
///
/// Return the cipher encryption algorithm handle.
///
- internal SqlClientEncryptionAlgorithm CipherAlgorithm
+ public SqlClientEncryptionAlgorithm CipherAlgorithm
{
get
{
@@ -365,7 +365,7 @@ internal SqlClientEncryptionAlgorithm CipherAlgorithm
///
/// Return Encryption Key Info.
///
- internal SqlEncryptionKeyInfo EncryptionKeyInfo
+ public SqlEncryptionKeyInfo EncryptionKeyInfo
{
get
{
@@ -382,7 +382,7 @@ internal SqlEncryptionKeyInfo EncryptionKeyInfo
///
/// Return Ordinal into Cek Table.
///
- internal ushort CekTableOrdinal
+ public ushort CekTableOrdinal
{
get
{
@@ -399,7 +399,7 @@ internal ushort CekTableOrdinal
///
///
///
- internal SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
+ public SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
ushort ordinal,
byte cipherAlgorithmId,
string cipherAlgorithmName,
@@ -421,7 +421,7 @@ internal SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
/// Do we have an handle to the cipher encryption algorithm already ?
///
///
- internal bool IsAlgorithmInitialized()
+ public bool IsAlgorithmInitialized()
{
return _sqlClientEncryptionAlgorithm != null ? true : false;
}
@@ -429,19 +429,19 @@ internal bool IsAlgorithmInitialized()
internal partial class SqlMetaDataPriv
{
- internal bool _isEncrypted; // TCE encrypted?
- internal SqlMetaDataPriv _baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
- internal SqlCipherMetadata _cipherMD; // Cipher related metadata for encrypted columns.
+ public bool IsEncrypted; // TCE encrypted?
+ public SqlMetaDataPriv BaseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
+ public SqlCipherMetadata CipherMD; // Cipher related metadata for encrypted columns.
///
/// Is the algorithm handle for the cipher encryption initialized ?
///
///
- internal bool IsAlgorithmInitialized()
+ public bool IsAlgorithmInitialized()
{
- if (_cipherMD != null)
+ if (CipherMD != null)
{
- return _cipherMD.IsAlgorithmInitialized();
+ return CipherMD.IsAlgorithmInitialized();
}
return false;
@@ -451,13 +451,13 @@ internal bool IsAlgorithmInitialized()
/// Returns the normalization rule version byte.
///
///
- internal byte NormalizationRuleVersion
+ public byte NormalizationRuleVersion
{
get
{
- if (_cipherMD != null)
+ if (CipherMD != null)
{
- return _cipherMD.NormalizationRuleVersion;
+ return CipherMD.NormalizationRuleVersion;
}
return 0x00;
@@ -489,7 +489,7 @@ internal sealed class SqlColumnEncryptionInputParameterInfo
///
/// Return the SMI Parameter Metadata.
///
- internal SmiParameterMetaData ParameterMetadata
+ public SmiParameterMetaData ParameterMetadata
{
get
{
@@ -502,7 +502,7 @@ internal SmiParameterMetaData ParameterMetadata
/// This is pre-calculated and cached since members are immutable.
/// Does not include _smiParameterMetadata's serialization.
///
- internal byte[] SerializedWireFormat
+ public byte[] SerializedWireFormat
{
get
{
@@ -515,7 +515,7 @@ internal byte[] SerializedWireFormat
///
///
///
- internal SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
+ public SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
{
Debug.Assert(smiParameterMetadata != null, "smiParameterMetadata should not be null.");
Debug.Assert(cipherMetadata != null, "cipherMetadata should not be null");
@@ -549,7 +549,7 @@ private byte[] SerializeToWriteFormat()
totalLength += sizeof(int);
// Metadata version of the encryption key.
- totalLength += _cipherMetadata.EncryptionKeyInfo._cekMdVersion.Length;
+ totalLength += _cipherMetadata.EncryptionKeyInfo.CekMdVersion.Length;
// Normalization Rule Version.
totalLength += sizeof(byte);
@@ -566,17 +566,17 @@ private byte[] SerializeToWriteFormat()
serializedWireFormat[consumedBytes++] = _cipherMetadata.EncryptionType;
// 3 - Write the database id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo._databaseId, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.DatabaseId, serializedWireFormat, ref consumedBytes);
// 4 - Write the id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo._cekId, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.CekId, serializedWireFormat, ref consumedBytes);
// 5 - Write the version of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo._cekVersion, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.CekVersion, serializedWireFormat, ref consumedBytes);
// 6 - Write the metadata version of the encryption key.
- Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo._cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo._cekMdVersion.Length);
- consumedBytes += _cipherMetadata.EncryptionKeyInfo._cekMdVersion.Length;
+ Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.CekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.CekMdVersion.Length);
+ consumedBytes += _cipherMetadata.EncryptionKeyInfo.CekMdVersion.Length;
// 7 - Write Normalization Rule Version.
serializedWireFormat[consumedBytes++] = _cipherMetadata.NormalizationRuleVersion;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
index d6eb859e1b..7d2e51eaed 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
@@ -76,9 +76,9 @@ private List GetDecryptedKeysToBeSentToEnclave(Concurre
decryptedKeysToBeSentToEnclave.Add(
new ColumnEncryptionKeyInfo(
sqlClientSymmetricKey.RootKey,
- cipherInfo.ColumnEncryptionKeyValues[0]._databaseId,
- cipherInfo.ColumnEncryptionKeyValues[0]._cekMdVersion,
- cipherInfo.ColumnEncryptionKeyValues[0]._cekId
+ cipherInfo.ColumnEncryptionKeyValues[0].DatabaseId,
+ cipherInfo.ColumnEncryptionKeyValues[0].CekMdVersion,
+ cipherInfo.ColumnEncryptionKeyValues[0].CekId
)
);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs
index 18c8227c98..d6d40e2b10 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs
@@ -40,9 +40,9 @@ internal SqlFedAuthToken ToSqlFedAuthToken()
var tokenBytes = AccessTokenBytesFromString(AccessToken);
return new SqlFedAuthToken
{
- _accessToken = tokenBytes,
- _dataLen = (uint)tokenBytes.Length,
- _expirationFileTime = ExpiresOn.ToFileTime()
+ AccessToken = tokenBytes,
+ DataLen = (uint)tokenBytes.Length,
+ ExpirationFileTime = ExpiresOn.ToFileTime()
};
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs
index 6fa25c0057..4150c50f26 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs
@@ -50,7 +50,7 @@ internal static TdsOperationStatus TryCreate(SqlMetaDataPriv metadata, TdsParser
}
// For now we only handle Plp data from the parser directly.
- Debug.Assert(metadata._metaType.IsPlp, "SqlCachedBuffer call on a non-plp data");
+ Debug.Assert(metadata.MetaType.IsPlp, "SqlCachedBuffer call on a non-plp data");
do
{
if (plplength == 0)
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs
index ed1d1c0e8b..034a2ac306 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs
@@ -349,9 +349,9 @@ string xmlSchemaCollectionName
if (!string.IsNullOrEmpty(xmlSchemaCollectionDatabase) || !string.IsNullOrEmpty(xmlSchemaCollectionOwningSchema) || !string.IsNullOrEmpty(xmlSchemaCollectionName))
{
EnsureXmlSchemaCollection();
- _xmlSchemaCollection._database = xmlSchemaCollectionDatabase;
- _xmlSchemaCollection._owningSchema = xmlSchemaCollectionOwningSchema;
- _xmlSchemaCollection._name = xmlSchemaCollectionName;
+ _xmlSchemaCollection.Database = xmlSchemaCollectionDatabase;
+ _xmlSchemaCollection.OwningSchema = xmlSchemaCollectionOwningSchema;
+ _xmlSchemaCollection.Name = xmlSchemaCollectionName;
}
}
@@ -427,24 +427,24 @@ public SqlCompareOptions CompareInfo
[ResCategory(StringsHelper.ResourceNames.DataCategory_Xml)]
public string XmlSchemaCollectionDatabase
{
- get => _xmlSchemaCollection?._database ?? string.Empty;
- set => EnsureXmlSchemaCollection()._database = value;
+ get => _xmlSchemaCollection?.Database ?? string.Empty;
+ set => EnsureXmlSchemaCollection().Database = value;
}
///
[ResCategory(StringsHelper.ResourceNames.DataCategory_Xml)]
public string XmlSchemaCollectionOwningSchema
{
- get => _xmlSchemaCollection?._owningSchema ?? string.Empty;
- set => EnsureXmlSchemaCollection()._owningSchema = value;
+ get => _xmlSchemaCollection?.OwningSchema ?? string.Empty;
+ set => EnsureXmlSchemaCollection().OwningSchema = value;
}
///
[ResCategory(StringsHelper.ResourceNames.DataCategory_Xml)]
public string XmlSchemaCollectionName
{
- get => _xmlSchemaCollection?._name ?? string.Empty;
- set => EnsureXmlSchemaCollection()._name = value;
+ get => _xmlSchemaCollection?.Name ?? string.Empty;
+ set => EnsureXmlSchemaCollection().Name = value;
}
///
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
index 940db88287..0ce84a0b07 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
@@ -313,8 +313,8 @@ private ConcurrentDictionary CreateCopyOfEnclaveKeys
SqlTceCipherInfoEntry copy = new(ordinal);
foreach (SqlEncryptionKeyInfo cekInfo in original.ColumnEncryptionKeyValues)
{
- copy.Add(cekInfo._encryptedKey, cekInfo._databaseId, cekInfo._cekId, cekInfo._cekVersion,
- cekInfo._cekMdVersion, cekInfo._keyPath, cekInfo._keyStoreName, cekInfo._algorithmName);
+ copy.Add(cekInfo.EncryptedKey, cekInfo.DatabaseId, cekInfo.CekId, cekInfo.CekVersion,
+ cekInfo.CekMdVersion, cekInfo.KeyPath, cekInfo.KeyStoreName, cekInfo.AlgorithmName);
}
enclaveKeys.TryAdd(ordinal, copy);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
index a7b1781592..4fe330fe95 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
@@ -227,7 +227,7 @@ internal static byte[] DecryptWithKey(byte[] cipherText, SqlCipherMetadata md, S
catch (Exception e)
{
// compute the strings to pass
- string keyStr = GetBytesAsString(md.EncryptionKeyInfo._encryptedKey, fLast: true, countOfBytes: 10);
+ string keyStr = GetBytesAsString(md.EncryptionKeyInfo.EncryptedKey, fLast: true, countOfBytes: 10);
string valStr = GetBytesAsString(cipherText, fLast: false, countOfBytes: 10);
throw SQL.ThrowDecryptionFailed(keyStr, valStr, e);
}
@@ -275,7 +275,7 @@ internal static void DecryptSymmetricKey(SqlTceCipherInfoEntry sqlTceCipherInfoE
{
try
{
- sqlClientSymmetricKey = ShouldUseInstanceLevelProviderFlow(keyInfo._keyStoreName, connection, command) ?
+ sqlClientSymmetricKey = ShouldUseInstanceLevelProviderFlow(keyInfo.KeyStoreName, connection, command) ?
GetKeyFromLocalProviders(keyInfo, connection, command) :
globalCekCache.GetKey(keyInfo, connection, command);
encryptionkeyInfoChosen = keyInfo;
@@ -303,10 +303,10 @@ private static SqlClientSymmetricKey GetKeyFromLocalProviders(SqlEncryptionKeyIn
Debug.Assert(SqlConnection.ColumnEncryptionTrustedMasterKeyPaths is not null, @"SqlConnection.ColumnEncryptionTrustedMasterKeyPaths should not be null");
- ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo._keyPath);
- if (!TryGetColumnEncryptionKeyStoreProvider(keyInfo._keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
+ ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.KeyPath);
+ if (!TryGetColumnEncryptionKeyStoreProvider(keyInfo.KeyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
{
- throw SQL.UnrecognizedKeyStoreProviderName(keyInfo._keyStoreName,
+ throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.KeyStoreName,
SqlConnection.GetColumnEncryptionSystemKeyStoreProvidersNames(),
GetListOfProviderNamesThatWereSearched(connection, command));
}
@@ -316,13 +316,13 @@ private static SqlClientSymmetricKey GetKeyFromLocalProviders(SqlEncryptionKeyIn
byte[] plaintextKey;
try
{
- plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo._keyPath, keyInfo._algorithmName, keyInfo._encryptedKey);
+ plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.KeyPath, keyInfo.AlgorithmName, keyInfo.EncryptedKey);
}
catch (Exception e)
{
// Generate a new exception and throw.
- string keyHex = GetBytesAsString(keyInfo._encryptedKey, fLast: true, countOfBytes: 10);
- throw SQL.KeyDecryptionFailed(keyInfo._keyStoreName, keyHex, e);
+ string keyHex = GetBytesAsString(keyInfo.EncryptedKey, fLast: true, countOfBytes: 10);
+ throw SQL.KeyDecryptionFailed(keyInfo.KeyStoreName, keyHex, e);
}
return new SqlClientSymmetricKey(plaintextKey);
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
index 8fc28f6f88..3e2d318b9a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
@@ -35,16 +35,16 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
string serverName = connection.DataSource;
Debug.Assert(serverName is not null, @"serverName should not be null.");
- StringBuilder cacheLookupKeyBuilder = new StringBuilder(serverName, capacity: serverName.Length + SqlSecurityUtility.GetBase64LengthFromByteLength(keyInfo._encryptedKey.Length) + keyInfo._keyStoreName.Length + 2/*separators*/);
+ StringBuilder cacheLookupKeyBuilder = new StringBuilder(serverName, capacity: serverName.Length + SqlSecurityUtility.GetBase64LengthFromByteLength(keyInfo.EncryptedKey.Length) + keyInfo.KeyStoreName.Length + 2/*separators*/);
#if DEBUG
int capacity = cacheLookupKeyBuilder.Capacity;
#endif //DEBUG
cacheLookupKeyBuilder.Append(":");
- cacheLookupKeyBuilder.Append(Convert.ToBase64String(keyInfo._encryptedKey));
+ cacheLookupKeyBuilder.Append(Convert.ToBase64String(keyInfo.EncryptedKey));
cacheLookupKeyBuilder.Append(":");
- cacheLookupKeyBuilder.Append(keyInfo._keyStoreName);
+ cacheLookupKeyBuilder.Append(keyInfo.KeyStoreName);
string cacheLookupKey = cacheLookupKeyBuilder.ToString();
@@ -58,12 +58,12 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
Debug.Assert(SqlConnection.ColumnEncryptionTrustedMasterKeyPaths is not null, @"SqlConnection.ColumnEncryptionTrustedMasterKeyPaths should not be null");
- SqlSecurityUtility.ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo._keyPath);
+ SqlSecurityUtility.ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.KeyPath);
// Key Not found, attempt to look up the provider and decrypt CEK
- if (!SqlSecurityUtility.TryGetColumnEncryptionKeyStoreProvider(keyInfo._keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
+ if (!SqlSecurityUtility.TryGetColumnEncryptionKeyStoreProvider(keyInfo.KeyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
{
- throw SQL.UnrecognizedKeyStoreProviderName(keyInfo._keyStoreName,
+ throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.KeyStoreName,
SqlConnection.GetColumnEncryptionSystemKeyStoreProvidersNames(),
SqlSecurityUtility.GetListOfProviderNamesThatWereSearched(connection, command));
}
@@ -75,13 +75,13 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
// to prevent conflicts between CEK caches, global providers should not use their own CEK caches
provider.ColumnEncryptionKeyCacheTtl = new TimeSpan(0);
- plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo._keyPath, keyInfo._algorithmName, keyInfo._encryptedKey);
+ plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.KeyPath, keyInfo.AlgorithmName, keyInfo.EncryptedKey);
}
catch (Exception e)
{
// Generate a new exception and throw.
- string keyHex = SqlSecurityUtility.GetBytesAsString(keyInfo._encryptedKey, fLast: true, countOfBytes: 10);
- throw SQL.KeyDecryptionFailed(keyInfo._keyStoreName, keyHex, e);
+ string keyHex = SqlSecurityUtility.GetBytesAsString(keyInfo.EncryptedKey, fLast: true, countOfBytes: 10);
+ throw SQL.KeyDecryptionFailed(keyInfo.KeyStoreName, keyHex, e);
}
encryptionKey = new SqlClientSymmetricKey(plaintextKey);
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
index 71c08f8003..b5e028f01e 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -59,29 +59,29 @@ internal void TdsLogin(
#endif
SqlConnectionEncryptOption encrypt)
{
- _physicalStateObj.SetTimeoutSeconds(rec._timeout);
+ _physicalStateObj.SetTimeoutSeconds(rec.Timeout);
Debug.Assert(recoverySessionData == null || (requestedFeatures & TdsEnums.FeatureExtension.SessionRecovery) != 0, "Recovery session data without session recovery feature request");
- Debug.Assert(TdsEnums.MAXLEN_HOSTNAME >= rec._hostName.Length, "_workstationId.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_HOSTNAME >= rec.HostName.Length, "_workstationId.Length exceeds the max length for this value");
- Debug.Assert(!(rec._useSSPI && _connHandler._fedAuthRequired), "Cannot use SSPI when server has responded 0x01 for FedAuthRequired PreLogin Option.");
- Debug.Assert(!rec._useSSPI || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) == 0, "Cannot use both SSPI and FedAuth");
+ Debug.Assert(!(rec.UseSspi && _connHandler._fedAuthRequired), "Cannot use SSPI when server has responded 0x01 for FedAuthRequired PreLogin Option.");
+ Debug.Assert(!rec.UseSspi || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) == 0, "Cannot use both SSPI and FedAuth");
Debug.Assert(fedAuthFeatureExtensionData == null || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) != 0, "fedAuthFeatureExtensionData provided without fed auth feature request");
Debug.Assert(fedAuthFeatureExtensionData != null || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) == 0, "Fed Auth feature requested without specifying fedAuthFeatureExtensionData.");
- Debug.Assert(rec._userName == null || (rec._userName != null && TdsEnums.MAXLEN_CLIENTID >= rec._userName.Length), "_userID.Length exceeds the max length for this value");
- Debug.Assert(rec._credential == null || (rec._credential != null && TdsEnums.MAXLEN_CLIENTID >= rec._credential.UserId.Length), "_credential.UserId.Length exceeds the max length for this value");
+ Debug.Assert(rec.UserName == null || (rec.UserName != null && TdsEnums.MAXLEN_CLIENTID >= rec.UserName.Length), "_userID.Length exceeds the max length for this value");
+ Debug.Assert(rec.Credential == null || (rec.Credential != null && TdsEnums.MAXLEN_CLIENTID >= rec.Credential.UserId.Length), "_credential.UserId.Length exceeds the max length for this value");
- Debug.Assert(rec._password == null || (rec._password != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec._password.Length), "_password.Length exceeds the max length for this value");
- Debug.Assert(rec._credential == null || (rec._credential != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec._credential.Password.Length), "_credential.Password.Length exceeds the max length for this value");
+ Debug.Assert(rec.Password == null || (rec.Password != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec.Password.Length), "_password.Length exceeds the max length for this value");
+ Debug.Assert(rec.Credential == null || (rec.Credential != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec.Credential.Password.Length), "_credential.Password.Length exceeds the max length for this value");
- Debug.Assert(rec._credential != null || rec._userName != null || rec._password != null, "cannot mix the new secure password system and the connection string based password");
- Debug.Assert(rec._newSecurePassword != null || rec._newPassword != null, "cannot have both new secure change password and string based change password");
- Debug.Assert(TdsEnums.MAXLEN_APPNAME >= rec._applicationName.Length, "_applicationName.Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_SERVERNAME >= rec._serverName.Length, "_dataSource.Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_LANGUAGE >= rec._language.Length, "_currentLanguage .Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_DATABASE >= rec._database.Length, "_initialCatalog.Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_ATTACHDBFILE >= rec._attachDBFilename.Length, "_attachDBFileName.Length exceeds the max length for this value");
+ Debug.Assert(rec.Credential != null || rec.UserName != null || rec.Password != null, "cannot mix the new secure password system and the connection string based password");
+ Debug.Assert(rec.NewSecurePassword != null || rec.NewPassword != null, "cannot have both new secure change password and string based change password");
+ Debug.Assert(TdsEnums.MAXLEN_APPNAME >= rec.ApplicationName.Length, "_applicationName.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_SERVERNAME >= rec.ServerName.Length, "_dataSource.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_LANGUAGE >= rec.Language.Length, "_currentLanguage .Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_DATABASE >= rec.Database.Length, "_initialCatalog.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_ATTACHDBFILE >= rec.AttachDbFilename.Length, "_attachDBFileName.Length exceeds the max length for this value");
Debug.Assert(_connHandler != null, "SqlConnectionInternalTds handler can not be null at this point.");
_connHandler!.TimeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.LoginBegin);
@@ -121,25 +121,25 @@ internal void TdsLogin(
string userName;
- if (rec._credential != null)
+ if (rec.Credential != null)
{
- userName = rec._credential.UserId;
- encryptedPasswordLengthInBytes = rec._credential.Password.Length * 2;
+ userName = rec.Credential.UserId;
+ encryptedPasswordLengthInBytes = rec.Credential.Password.Length * 2;
}
else
{
- userName = rec._userName;
- encryptedPassword = TdsParserStaticMethods.ObfuscatePassword(rec._password);
+ userName = rec.UserName;
+ encryptedPassword = TdsParserStaticMethods.ObfuscatePassword(rec.Password);
encryptedPasswordLengthInBytes = encryptedPassword.Length; // password in clear text is already encrypted and its length is in byte
}
- if (rec._newSecurePassword != null)
+ if (rec.NewSecurePassword != null)
{
- encryptedChangePasswordLengthInBytes = rec._newSecurePassword.Length * 2;
+ encryptedChangePasswordLengthInBytes = rec.NewSecurePassword.Length * 2;
}
else
{
- encryptedChangePassword = TdsParserStaticMethods.ObfuscatePassword(rec._newPassword);
+ encryptedChangePassword = TdsParserStaticMethods.ObfuscatePassword(rec.NewPassword);
encryptedChangePasswordLengthInBytes = encryptedChangePassword.Length;
}
@@ -156,10 +156,10 @@ internal void TdsLogin(
//
checked
{
- length += (rec._hostName.Length + rec._applicationName.Length +
- rec._serverName.Length + clientInterfaceName.Length +
- rec._language.Length + rec._database.Length +
- rec._attachDBFilename.Length) * 2;
+ length += (rec.HostName.Length + rec.ApplicationName.Length +
+ rec.ServerName.Length + clientInterfaceName.Length +
+ rec.Language.Length + rec.Database.Length +
+ rec.AttachDbFilename.Length) * 2;
if (useFeatureExt)
{
length += 4;
@@ -172,7 +172,7 @@ internal void TdsLogin(
uint outSSPILength = 0;
// only add lengths of password and username if not using SSPI or requesting federated authentication info
- if (!rec._useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
checked
{
@@ -182,7 +182,7 @@ internal void TdsLogin(
}
else
{
- if (rec._useSSPI)
+ if (rec.UseSspi)
{
// now allocate proper length of buffer, and set length
outSSPILength = _authenticationProvider.MaxSSPILength;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index bc60ecc188..233126cadc 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -60,10 +60,10 @@ internal enum TdsParserState
///
internal sealed class FederatedAuthenticationFeatureExtensionData
{
- internal TdsEnums.FedAuthLibrary _libraryType;
- internal bool _fedAuthRequiredPreLoginResponse;
- internal SqlAuthenticationMethod _authentication;
- internal byte[] _accessToken;
+ public TdsEnums.FedAuthLibrary LibraryType;
+ public bool FedAuthRequiredPreLoginResponse;
+ public SqlAuthenticationMethod Authentication;
+ public byte[] AccessToken;
}
internal sealed class RoutingInfo
@@ -82,49 +82,49 @@ internal RoutingInfo(byte protocol, ushort port, string servername)
internal sealed class SqlLogin
{
- internal SqlAuthenticationMethod _authentication = SqlAuthenticationMethod.NotSpecified; // Authentication type
- internal int _timeout; // login timeout
- internal bool _userInstance = false; // user instance
- internal string _hostName = ""; // client machine name
- internal string _userName = ""; // user id
- internal string _password = ""; // password
- internal string _applicationName = ""; // application name
- internal string _serverName = ""; // server name
- internal string _language = ""; // initial language
- internal string _database = ""; // initial database
- internal string _attachDBFilename = ""; // DB filename to be attached
- internal bool _useReplication = false; // user login for replication
- internal string _newPassword = ""; // new password for reset password
- internal bool _useSSPI = false; // use integrated security
- internal int _packetSize = SqlConnectionString.DEFAULT.Packet_Size; // packet size
- internal bool _readOnlyIntent = false; // read-only intent
- internal SqlCredential _credential; // user id and password in SecureString
- internal SecureString _newSecurePassword;
+ public SqlAuthenticationMethod Authentication = SqlAuthenticationMethod.NotSpecified; // Authentication type
+ public int Timeout; // login timeout
+ public bool UserInstance = false; // user instance
+ public string HostName = ""; // client machine name
+ public string UserName = ""; // user id
+ public string Password = ""; // password
+ public string ApplicationName = ""; // application name
+ public string ServerName = ""; // server name
+ public string Language = ""; // initial language
+ public string Database = ""; // initial database
+ public string AttachDbFilename = ""; // DB filename to be attached
+ public bool UseReplication = false; // user login for replication
+ public string NewPassword = ""; // new password for reset password
+ public bool UseSspi = false; // use integrated security
+ public int PacketSize = SqlConnectionString.DEFAULT.Packet_Size; // packet size
+ public bool ReadOnlyIntent = false; // read-only intent
+ public SqlCredential Credential; // user id and password in SecureString
+ public SecureString NewSecurePassword;
}
internal sealed partial class SqlLoginAck
{
- internal byte _majorVersion;
- internal byte _minorVersion;
- internal short _buildNum;
- internal uint _tdsVersion;
+ public byte MajorVersion;
+ public byte MinorVersion;
+ public short BuildNum;
+ public uint TdsVersion;
}
internal sealed class SqlFedAuthInfo
{
- internal string _spn;
- internal string _stsurl;
+ public string Spn;
+ public string StsUrl;
public override string ToString()
{
- return $"STSURL: {_stsurl}, SPN: {_spn}";
+ return $"STSURL: {StsUrl}, SPN: {Spn}";
}
}
internal sealed class SqlFedAuthToken
{
- internal uint _dataLen;
- internal byte[] _accessToken;
- internal long _expirationFileTime;
+ public uint DataLen;
+ public byte[] AccessToken;
+ public long ExpirationFileTime;
}
internal sealed class _SqlMetaData : SqlMetaDataPriv
@@ -146,18 +146,18 @@ private enum _SqlMetadataFlags : int
IsUpdatableMask = (Updatable | UpdateableUnknown) // two bit field (0 is read only, 1 is updatable, 2 is updatability unknown)
}
- internal string _column;
- internal string _baseColumn;
- internal MultiPartTableName _multiPartTableName;
- internal readonly int _ordinal;
- internal byte _tableNum;
- internal byte _op; // for altrow-columns only
- internal ushort _operand; // for altrow-columns only
+ public string Column;
+ public string BaseColumn;
+ public MultiPartTableName MultiPartTableName;
+ public readonly int Ordinal;
+ public byte TableNum;
+ public byte Op; // for altrow-columns only
+ public ushort Operand; // for altrow-columns only
private _SqlMetadataFlags _flags;
- internal _SqlMetaData(int ordinal) : base()
+ public _SqlMetaData(int ordinal) : base()
{
- _ordinal = ordinal;
+ Ordinal = ordinal;
}
private bool HasFlag(_SqlMetadataFlags flag)
@@ -165,32 +165,32 @@ private bool HasFlag(_SqlMetadataFlags flag)
return (_flags & flag) != 0;
}
- internal string serverName
+ public string ServerName
{
get
{
- return _multiPartTableName.ServerName;
+ return MultiPartTableName.ServerName;
}
}
- internal string catalogName
+ public string CatalogName
{
get
{
- return _multiPartTableName.CatalogName;
+ return MultiPartTableName.CatalogName;
}
}
- internal string schemaName
+ public string SchemaName
{
get
{
- return _multiPartTableName.SchemaName;
+ return MultiPartTableName.SchemaName;
}
}
- internal string tableName
+ public string TableName
{
get
{
- return _multiPartTableName.TableName;
+ return MultiPartTableName.TableName;
}
}
@@ -246,48 +246,48 @@ private void Set(_SqlMetadataFlags flag, bool value)
_flags = value ? _flags | flag : _flags & ~flag;
}
- internal bool Is2008DateTimeType
+ public bool Is2008DateTimeType
{
get
{
- return SqlDbType.Date == _type || SqlDbType.Time == _type || SqlDbType.DateTime2 == _type || SqlDbType.DateTimeOffset == _type;
+ return SqlDbType.Date == Type || SqlDbType.Time == Type || SqlDbType.DateTime2 == Type || SqlDbType.DateTimeOffset == Type;
}
}
- internal bool IsLargeUdt
+ public bool IsLargeUdt
{
get
{
- return _type == SqlDbType.Udt && _length == int.MaxValue;
+ return Type == SqlDbType.Udt && Length == int.MaxValue;
}
}
public object Clone()
{
- _SqlMetaData result = new(_ordinal);
+ _SqlMetaData result = new(Ordinal);
result.CopyFrom(this);
- result._column = _column;
- result._baseColumn = _baseColumn;
- result._multiPartTableName = _multiPartTableName;
- result._tableNum = _tableNum;
+ result.Column = Column;
+ result.BaseColumn = BaseColumn;
+ result.MultiPartTableName = MultiPartTableName;
+ result.TableNum = TableNum;
result._flags = _flags;
- result._op = _op;
- result._operand = _operand;
+ result.Op = Op;
+ result.Operand = Operand;
return result;
}
}
internal sealed partial class _SqlMetaDataSet
{
- internal ushort _id; // for altrow-columns only
+ public ushort Id; // for altrow-columns only
- internal DataTable _schemaTable;
+ public DataTable SchemaTable;
private readonly _SqlMetaData[] _metaDataArray;
private int _hiddenColumnCount;
private int[] _visibleColumnMap;
- internal _SqlMetaDataSet(int count)
+ public _SqlMetaDataSet(int count)
{
_hiddenColumnCount = -1;
_metaDataArray = new _SqlMetaData[count];
@@ -297,7 +297,7 @@ internal _SqlMetaDataSet(int count)
}
}
- internal int Length
+ public int Length
{
get
{
@@ -305,7 +305,7 @@ internal int Length
}
}
- internal int VisibleColumnCount
+ public int VisibleColumnCount
{
get
{
@@ -317,7 +317,7 @@ internal int VisibleColumnCount
}
}
- internal _SqlMetaData this[int index]
+ public _SqlMetaData this[int index]
{
get
{
@@ -383,20 +383,20 @@ private void SetupHiddenColumns()
internal sealed class _SqlMetaDataSetCollection
{
private readonly List<_SqlMetaDataSet> _altMetaDataSetArray;
- internal _SqlMetaDataSet _metaDataSet;
+ public _SqlMetaDataSet MetaDataSet;
- internal _SqlMetaDataSetCollection()
+ public _SqlMetaDataSetCollection()
{
_altMetaDataSetArray = new List<_SqlMetaDataSet>();
}
- internal void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
+ public void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
{
// If altmetadata with same id is found, override it rather than adding a new one
- int newId = altMetaDataSet._id;
+ int newId = altMetaDataSet.Id;
for (int i = 0; i < _altMetaDataSetArray.Count; i++)
{
- if (_altMetaDataSetArray[i]._id == newId)
+ if (_altMetaDataSetArray[i].Id == newId)
{
// override the existing metadata with the same id
_altMetaDataSetArray[i] = altMetaDataSet;
@@ -408,11 +408,11 @@ internal void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
_altMetaDataSetArray.Add(altMetaDataSet);
}
- internal _SqlMetaDataSet GetAltMetaData(int id)
+ public _SqlMetaDataSet GetAltMetaData(int id)
{
foreach (_SqlMetaDataSet altMetaDataSet in _altMetaDataSetArray)
{
- if (altMetaDataSet._id == id)
+ if (altMetaDataSet.Id == id)
{
return altMetaDataSet;
}
@@ -423,7 +423,7 @@ internal _SqlMetaDataSet GetAltMetaData(int id)
public object Clone()
{
- _SqlMetaDataSetCollection result = new() { _metaDataSet = _metaDataSet?.Clone() };
+ _SqlMetaDataSetCollection result = new() { MetaDataSet = MetaDataSet?.Clone() };
foreach (_SqlMetaDataSet set in _altMetaDataSetArray)
{
@@ -443,19 +443,19 @@ private enum SqlMetaDataPrivFlags : byte
IsMultiValued = 1 << 2
}
- internal SqlDbType _type; // SqlDbType enum value
- internal byte _tdsType; // underlying tds type
- internal byte _precision = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
- internal byte _scale = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
+ public SqlDbType Type; // SqlDbType enum value
+ public byte TdsType; // underlying tds type
+ public byte Precision = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
+ public byte Scale = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
private SqlMetaDataPrivFlags _flags;
- internal int _length;
- internal SqlCollation _collation;
- internal int _codePage;
- internal Encoding _encoding;
+ public int Length;
+ public SqlCollation Collation;
+ public int CodePage;
+ public Encoding Encoding;
- internal MetaType _metaType; // cached metaType
- public SqlMetaDataUdt udt;
- public SqlMetaDataXmlSchemaCollection xmlSchemaCollection;
+ public MetaType MetaType; // cached metaType
+ public SqlMetaDataUdt Udt;
+ public SqlMetaDataXmlSchemaCollection XmlSchemaCollection;
internal SqlMetaDataPriv()
{
@@ -485,44 +485,44 @@ private void Set(SqlMetaDataPrivFlags flag, bool value)
internal void CopyFrom(SqlMetaDataPriv original)
{
- _type = original._type;
- _tdsType = original._tdsType;
- _precision = original._precision;
- _scale = original._scale;
- _length = original._length;
- _collation = original._collation;
- _codePage = original._codePage;
- _encoding = original._encoding;
- _metaType = original._metaType;
+ Type = original.Type;
+ TdsType = original.TdsType;
+ Precision = original.Precision;
+ Scale = original.Scale;
+ Length = original.Length;
+ Collation = original.Collation;
+ CodePage = original.CodePage;
+ Encoding = original.Encoding;
+ MetaType = original.MetaType;
_flags = original._flags;
- if (original.udt != null)
+ if (original.Udt != null)
{
- udt = new SqlMetaDataUdt();
- udt.CopyFrom(original.udt);
+ Udt = new SqlMetaDataUdt();
+ Udt.CopyFrom(original.Udt);
}
- if (original.xmlSchemaCollection != null)
+ if (original.XmlSchemaCollection != null)
{
- xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
- xmlSchemaCollection.CopyFrom(original.xmlSchemaCollection);
+ XmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
+ XmlSchemaCollection.CopyFrom(original.XmlSchemaCollection);
}
}
}
internal sealed class SqlMetaDataXmlSchemaCollection
{
- internal string _database;
- internal string _owningSchema;
- internal string _name;
+ public string Database;
+ public string OwningSchema;
+ public string Name;
public void CopyFrom(SqlMetaDataXmlSchemaCollection original)
{
if (original != null)
{
- _database = original._database;
- _owningSchema = original._owningSchema;
- _name = original._name;
+ Database = original.Database;
+ OwningSchema = original.OwningSchema;
+ Name = original.Name;
}
}
}
@@ -532,82 +532,82 @@ internal sealed class SqlMetaDataUdt
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
- internal Type _type;
- internal string _databaseName;
- internal string _schemaName;
- internal string _typeName;
- internal string _assemblyQualifiedName;
+ public Type Type;
+ public string DatabaseName;
+ public string SchemaName;
+ public string TypeName;
+ public string AssemblyQualifiedName;
public void CopyFrom(SqlMetaDataUdt original)
{
if (original != null)
{
- _type = original._type;
- _databaseName = original._databaseName;
- _schemaName = original._schemaName;
- _typeName = original._typeName;
- _assemblyQualifiedName = original._assemblyQualifiedName;
+ Type = original.Type;
+ DatabaseName = original.DatabaseName;
+ SchemaName = original.SchemaName;
+ TypeName = original.TypeName;
+ AssemblyQualifiedName = original.AssemblyQualifiedName;
}
}
}
internal sealed class _SqlRPC
{
- internal string _rpcName;
- internal ushort _procID; // Used instead of name
- internal ushort _options;
+ public string RpcName;
+ public ushort ProcId; // Used instead of name
+ public ushort Options;
- internal SqlParameter[] _systemParams;
- internal byte[] _systemParamOptions;
- internal int _systemParamCount;
+ public SqlParameter[] SystemParams;
+ public byte[] SystemParamOptions;
+ public int SystemParamCount;
- internal SqlParameterCollection _userParams;
- internal long[] _userParamMap;
- internal int _userParamCount;
+ public SqlParameterCollection UserParams;
+ public long[] UserParamMap;
+ public int UserParamCount;
- internal int? _recordsAffected;
- internal int _cumulativeRecordsAffected;
+ public int? RecordsAffected;
+ public int CumulativeRecordsAffected;
- internal int _errorsIndexStart;
- internal int _errorsIndexEnd;
- internal SqlErrorCollection _errors;
+ public int ErrorsIndexStart;
+ public int ErrorsIndexEnd;
+ public SqlErrorCollection Errors;
- internal int _warningsIndexStart;
- internal int _warningsIndexEnd;
- internal SqlErrorCollection _warnings;
+ public int WarningsIndexStart;
+ public int WarningsIndexEnd;
+ public SqlErrorCollection Warnings;
- internal bool _needsFetchParameterEncryptionMetadata;
+ public bool NeedsFetchParameterEncryptionMetadata;
- internal SqlBatchCommand _batchCommand;
+ public SqlBatchCommand BatchCommand;
- internal string GetCommandTextOrRpcName()
+ public string GetCommandTextOrRpcName()
{
- if (TdsEnums.RPC_PROCID_EXECUTESQL == _procID)
+ if (TdsEnums.RPC_PROCID_EXECUTESQL == ProcId)
{
// Param 0 is the actual sql executing
- return (string)_systemParams[0].Value;
+ return (string)SystemParams[0].Value;
}
else
{
- return _rpcName;
+ return RpcName;
}
}
- internal SqlParameter GetParameterByIndex(int index, out byte options)
+ public SqlParameter GetParameterByIndex(int index, out byte options)
{
SqlParameter retval;
- if (index < _systemParamCount)
+ if (index < SystemParamCount)
{
- retval = _systemParams[index];
- options = _systemParamOptions[index];
+ retval = SystemParams[index];
+ options = SystemParamOptions[index];
}
else
{
- long data = _userParamMap[index - _systemParamCount];
+ long data = UserParamMap[index - SystemParamCount];
int paramIndex = (int)(data & int.MaxValue);
options = (byte)((data >> 32) & 0xFF);
- retval = _userParams[paramIndex];
+ retval = UserParams[paramIndex];
}
return retval;
}
@@ -615,12 +615,12 @@ internal SqlParameter GetParameterByIndex(int index, out byte options)
internal sealed partial class SqlReturnValue : SqlMetaDataPriv
{
- internal string _parameter;
- internal readonly SqlBuffer _value;
+ public string Parameter;
+ public readonly SqlBuffer Value;
- internal SqlReturnValue() : base()
+ public SqlReturnValue() : base()
{
- _value = new SqlBuffer();
+ Value = new SqlBuffer();
}
}
@@ -700,6 +700,6 @@ private void ParseMultipartName()
}
}
- internal static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
+ public static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
}
}
From b015e326033115d12fa688b30cad12ba931b8c69 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Thu, 22 Aug 2024 21:54:11 +0100
Subject: [PATCH 10/14] Merged TdsParserHelperClasses - removed per-platform
files
---
.../src/Microsoft.Data.SqlClient.csproj | 1 -
.../TdsParserHelperClasses.NetCoreApp.cs | 127 -----------
.../netfx/src/Microsoft.Data.SqlClient.csproj | 1 -
.../SqlClient/TdsParserHelperClasses.netfx.cs | 140 ------------
.../Data/SqlClient/TdsParserHelperClasses.cs | 209 +++++++++++++++++-
5 files changed, 208 insertions(+), 270 deletions(-)
delete mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs
delete mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.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 07c82c4759..501849a752 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -688,7 +688,6 @@
-
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs
deleted file mode 100644
index adc7616228..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.NetCoreApp.cs
+++ /dev/null
@@ -1,127 +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.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Data;
-using System.Data.Common;
-using System.Data.SqlTypes;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Security;
-using System.Security.Authentication;
-using System.Text;
-using Microsoft.Data.Common;
-using Microsoft.Data.SqlTypes;
-
-namespace Microsoft.Data.SqlClient
-{
- internal enum EncryptionOptions
- {
- OFF,
- ON,
- NOT_SUP,
- REQ,
- LOGIN
- }
-
- internal sealed partial class _SqlMetaDataSet
- {
- public ReadOnlyCollection DbColumnSchema;
-
- private _SqlMetaDataSet(_SqlMetaDataSet original)
- {
- Id = original.Id;
- _hiddenColumnCount = original._hiddenColumnCount;
- _visibleColumnMap = original._visibleColumnMap;
- DbColumnSchema = original.DbColumnSchema;
- if (original._metaDataArray == null)
- {
- _metaDataArray = null;
- }
- else
- {
- _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
- for (int idx = 0; idx < _metaDataArray.Length; idx++)
- {
- _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
- }
- }
- }
- }
-
- internal static class SslProtocolsHelper
- {
- private static string ToFriendlyName(this SslProtocols protocol)
- {
- string name;
-
- /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
- * This driver does not support this version yet!
- if ((protocol & SslProtocols.Tls13) == SslProtocols.Tls13)
- {
- name = "TLS 1.3";
- }*/
- if ((protocol & SslProtocols.Tls12) == SslProtocols.Tls12)
- {
- name = "TLS 1.2";
- }
-#if NET8_0_OR_GREATER
-#pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated
-#endif
- else if ((protocol & SslProtocols.Tls11) == SslProtocols.Tls11)
- {
- name = "TLS 1.1";
- }
- else if ((protocol & SslProtocols.Tls) == SslProtocols.Tls)
- {
- name = "TLS 1.0";
- }
-#if NET8_0_OR_GREATER
-#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
-#endif
-#pragma warning disable CS0618 // Type or member is obsolete: SSL is deprecated
- else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
- {
- name = "SSL 3.0";
- }
- else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
-#pragma warning restore CS0618 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
- {
- name = "SSL 2.0";
- }
- else
- {
- name = protocol.ToString();
- }
-
- return name;
- }
-
- ///
- /// check the negotiated secure protocol if it's under TLS 1.2
- ///
- ///
- /// Localized warning message
- public static string GetProtocolWarning(this SslProtocols protocol)
- {
- string message = string.Empty;
-#if NET8_0_OR_GREATER
-#pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated
-#endif
-#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
- if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
-#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
-#if NET8_0_OR_GREATER
-#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
-#endif
- {
- message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
- }
- 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 cedd7527f1..53f2aa04a9 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -718,7 +718,6 @@
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.cs
deleted file mode 100644
index 8a4bc76654..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.netfx.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Data.Common;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Microsoft.Data.SqlClient
-{
- internal enum EncryptionOptions
- {
- OFF,
- ON,
- NOT_SUP,
- REQ,
- LOGIN,
- OPTIONS_MASK = 0x3f,
- CTAIP = 0x40,
- CLIENT_CERT = 0x80,
- }
-
- internal sealed partial class SqlLoginAck
- {
- public string ProgramName;
-
- public bool IsVersion8;
- }
-
- internal sealed partial class _SqlMetaDataSet
- {
- private _SqlMetaDataSet(_SqlMetaDataSet original)
- {
- Id = original.Id;
- _hiddenColumnCount = original._hiddenColumnCount;
- _visibleColumnMap = original._visibleColumnMap;
- SchemaTable = original.SchemaTable;
- if (original._metaDataArray == null)
- {
- _metaDataArray = null;
- }
- else
- {
- _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
- for (int idx = 0; idx < _metaDataArray.Length; idx++)
- {
- _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
- }
- }
- }
- }
-
- internal sealed partial class SqlReturnValue
- {
- public ushort ParmIndex; //2005 or later only
- }
-
- internal static class SslProtocolsHelper
- {
- // protocol versions from native sni
- [Flags]
- private enum NativeProtocols
- {
- SP_PROT_SSL2_SERVER = 0x00000004,
- SP_PROT_SSL2_CLIENT = 0x00000008,
- SP_PROT_SSL3_SERVER = 0x00000010,
- SP_PROT_SSL3_CLIENT = 0x00000020,
- SP_PROT_TLS1_0_SERVER = 0x00000040,
- SP_PROT_TLS1_0_CLIENT = 0x00000080,
- SP_PROT_TLS1_1_SERVER = 0x00000100,
- SP_PROT_TLS1_1_CLIENT = 0x00000200,
- SP_PROT_TLS1_2_SERVER = 0x00000400,
- SP_PROT_TLS1_2_CLIENT = 0x00000800,
- SP_PROT_TLS1_3_SERVER = 0x00001000,
- SP_PROT_TLS1_3_CLIENT = 0x00002000,
- SP_PROT_SSL2 = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT,
- SP_PROT_SSL3 = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT,
- SP_PROT_TLS1_0 = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT,
- SP_PROT_TLS1_1 = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT,
- SP_PROT_TLS1_2 = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT,
- SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
- SP_PROT_NONE = 0x0
- }
-
- private static string ToFriendlyName(this NativeProtocols protocol)
- {
- string name;
-
- if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
- {
- name = "TLS 1.3";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
- {
- name = "TLS 1.2";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_SERVER))
- {
- name = "TLS 1.1";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_SERVER))
- {
- name = "TLS 1.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
- {
- name = "SSL 3.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
- {
- name = "SSL 2.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_NONE))
- {
- name = "None";
- }
- else
- {
- throw new ArgumentException(StringsHelper.GetString(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
- }
- return name;
- }
-
- ///
- /// check the negotiated secure protocol if it's under TLS 1.2
- ///
- ///
- /// Localized warning message
- public static string GetProtocolWarning(uint protocol)
- {
- var nativeProtocol = (NativeProtocols)protocol;
- string message = string.Empty;
- if ((nativeProtocol & (NativeProtocols.SP_PROT_SSL2 | NativeProtocols.SP_PROT_SSL3 | NativeProtocols.SP_PROT_TLS1_1)) != NativeProtocols.SP_PROT_NONE)
- {
- message = StringsHelper.GetString(Strings.SEC_ProtocolWarning, nativeProtocol.ToFriendlyName());
- }
- return message;
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index 233126cadc..f5336cbd33 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -4,11 +4,14 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Data;
+using System.Data.Common;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Security;
+using System.Security.Authentication;
using System.Text;
using Microsoft.Data.Common;
@@ -20,6 +23,20 @@ internal enum CallbackType
Write = 1
}
+ internal enum EncryptionOptions
+ {
+ OFF,
+ ON,
+ NOT_SUP,
+ REQ,
+ LOGIN,
+#if NETFRAMEWORK
+ OPTIONS_MASK = 0x3f,
+ CTAIP = 0x40,
+ CLIENT_CERT = 0x80,
+#endif
+ }
+
internal enum PreLoginHandshakeStatus
{
Successful,
@@ -102,12 +119,17 @@ internal sealed class SqlLogin
public SecureString NewSecurePassword;
}
- internal sealed partial class SqlLoginAck
+ internal sealed class SqlLoginAck
{
public byte MajorVersion;
public byte MinorVersion;
public short BuildNum;
public uint TdsVersion;
+#if NETFRAMEWORK
+ public string ProgramName;
+
+ public bool IsVersion8;
+#endif
}
internal sealed class SqlFedAuthInfo
@@ -282,6 +304,10 @@ internal sealed partial class _SqlMetaDataSet
public ushort Id; // for altrow-columns only
public DataTable SchemaTable;
+#if NET
+ public ReadOnlyCollection DbColumnSchema;
+#endif
+
private readonly _SqlMetaData[] _metaDataArray;
private int _hiddenColumnCount;
@@ -297,6 +323,30 @@ public _SqlMetaDataSet(int count)
}
}
+ private _SqlMetaDataSet(_SqlMetaDataSet original)
+ {
+ Id = original.Id;
+ _hiddenColumnCount = original._hiddenColumnCount;
+ _visibleColumnMap = original._visibleColumnMap;
+#if NET
+ DbColumnSchema = original.DbColumnSchema;
+#else
+ SchemaTable = original.SchemaTable;
+#endif
+ if (original._metaDataArray == null)
+ {
+ _metaDataArray = null;
+ }
+ else
+ {
+ _metaDataArray = new _SqlMetaData[original._metaDataArray.Length];
+ for (int idx = 0; idx < _metaDataArray.Length; idx++)
+ {
+ _metaDataArray[idx] = (_SqlMetaData)original._metaDataArray[idx].Clone();
+ }
+ }
+ }
+
public int Length
{
get
@@ -617,6 +667,9 @@ internal sealed partial class SqlReturnValue : SqlMetaDataPriv
{
public string Parameter;
public readonly SqlBuffer Value;
+#if NETFRAMEWORK
+ public ushort ParmIndex; //2005 or later only
+#endif
public SqlReturnValue() : base()
{
@@ -702,4 +755,158 @@ private void ParseMultipartName()
public static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
}
+
+ internal static class SslProtocolsHelper
+ {
+#if NET
+ private static string ToFriendlyName(this SslProtocols protocol)
+ {
+ string name;
+
+ /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
+ * This driver does not support this version yet!
+ if ((protocol & SslProtocols.Tls13) == SslProtocols.Tls13)
+ {
+ name = "TLS 1.3";
+ }*/
+ if ((protocol & SslProtocols.Tls12) == SslProtocols.Tls12)
+ {
+ name = "TLS 1.2";
+ }
+#if NET8_0_OR_GREATER
+#pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated
+#endif
+ else if ((protocol & SslProtocols.Tls11) == SslProtocols.Tls11)
+ {
+ name = "TLS 1.1";
+ }
+ else if ((protocol & SslProtocols.Tls) == SslProtocols.Tls)
+ {
+ name = "TLS 1.0";
+ }
+#if NET8_0_OR_GREATER
+#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
+#endif
+#pragma warning disable CS0618 // Type or member is obsolete: SSL is deprecated
+ else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
+ {
+ name = "SSL 3.0";
+ }
+ else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
+#pragma warning restore CS0618 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
+ {
+ name = "SSL 2.0";
+ }
+ else
+ {
+ name = protocol.ToString();
+ }
+
+ return name;
+ }
+
+ ///
+ /// check the negotiated secure protocol if it's under TLS 1.2
+ ///
+ ///
+ /// Localized warning message
+ public static string GetProtocolWarning(this SslProtocols protocol)
+ {
+ string message = string.Empty;
+#if NET8_0_OR_GREATER
+#pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated
+#endif
+#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
+ if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
+#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
+#if NET8_0_OR_GREATER
+#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
+#endif
+ {
+ message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
+ }
+ return message;
+ }
+#else
+ // protocol versions from native sni
+ [Flags]
+ private enum NativeProtocols
+ {
+ SP_PROT_SSL2_SERVER = 0x00000004,
+ SP_PROT_SSL2_CLIENT = 0x00000008,
+ SP_PROT_SSL3_SERVER = 0x00000010,
+ SP_PROT_SSL3_CLIENT = 0x00000020,
+ SP_PROT_TLS1_0_SERVER = 0x00000040,
+ SP_PROT_TLS1_0_CLIENT = 0x00000080,
+ SP_PROT_TLS1_1_SERVER = 0x00000100,
+ SP_PROT_TLS1_1_CLIENT = 0x00000200,
+ SP_PROT_TLS1_2_SERVER = 0x00000400,
+ SP_PROT_TLS1_2_CLIENT = 0x00000800,
+ SP_PROT_TLS1_3_SERVER = 0x00001000,
+ SP_PROT_TLS1_3_CLIENT = 0x00002000,
+ SP_PROT_SSL2 = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT,
+ SP_PROT_SSL3 = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT,
+ SP_PROT_TLS1_0 = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT,
+ SP_PROT_TLS1_1 = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT,
+ SP_PROT_TLS1_2 = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT,
+ SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
+ SP_PROT_NONE = 0x0
+ }
+
+ private static string ToFriendlyName(this NativeProtocols protocol)
+ {
+ string name;
+
+ if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
+ {
+ name = "TLS 1.3";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
+ {
+ name = "TLS 1.2";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_SERVER))
+ {
+ name = "TLS 1.1";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_SERVER))
+ {
+ name = "TLS 1.0";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
+ {
+ name = "SSL 3.0";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
+ {
+ name = "SSL 2.0";
+ }
+ else if (protocol.HasFlag(NativeProtocols.SP_PROT_NONE))
+ {
+ name = "None";
+ }
+ else
+ {
+ throw new ArgumentException(StringsHelper.GetString(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
+ }
+ return name;
+ }
+
+ ///
+ /// check the negotiated secure protocol if it's under TLS 1.2
+ ///
+ ///
+ /// Localized warning message
+ public static string GetProtocolWarning(uint protocol)
+ {
+ var nativeProtocol = (NativeProtocols)protocol;
+ string message = string.Empty;
+ if ((nativeProtocol & (NativeProtocols.SP_PROT_SSL2 | NativeProtocols.SP_PROT_SSL3 | NativeProtocols.SP_PROT_TLS1_1)) != NativeProtocols.SP_PROT_NONE)
+ {
+ message = StringsHelper.GetString(Strings.SEC_ProtocolWarning, nativeProtocol.ToFriendlyName());
+ }
+ return message;
+ }
+#endif
+ }
}
From 6487b504bfbfeea89979d658ff34597b142a7c50 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Thu, 22 Aug 2024 22:19:15 +0100
Subject: [PATCH 11/14] Further correction to reflection-based test
---
.../tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs | 6 +++---
.../SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs
index ae7d860a42..8feaa5f5fc 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs
@@ -29,9 +29,9 @@ public static class Utility
public static Type SqlCipherMetadata = systemData.GetType("Microsoft.Data.SqlClient.SqlCipherMetadata");
public static FieldInfo sqlTceCipherInfoEntryField = SqlCipherMetadata.GetField("_sqlTceCipherInfoEntry", BindingFlags.Instance | BindingFlags.NonPublic);
public static Type SqlTceCipherInfoEntry = systemData.GetType("Microsoft.Data.SqlClient.SqlTceCipherInfoEntry");
- public static MethodInfo SqlTceCipherInfoEntryAdd = SqlTceCipherInfoEntry.GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic);
- public static ConstructorInfo SqlCipherMetadataConstructor = SqlCipherMetadata.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { SqlTceCipherInfoEntry, typeof(ushort), typeof(byte), typeof(string), typeof(byte), typeof(byte) }, null);
- public static ConstructorInfo SqlTceCipherInfoEntryConstructor = SqlTceCipherInfoEntry.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
+ public static MethodInfo SqlTceCipherInfoEntryAdd = SqlTceCipherInfoEntry.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public);
+ public static ConstructorInfo SqlCipherMetadataConstructor = SqlCipherMetadata.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { SqlTceCipherInfoEntry, typeof(ushort), typeof(byte), typeof(string), typeof(byte), typeof(byte) }, null);
+ public static ConstructorInfo SqlTceCipherInfoEntryConstructor = SqlTceCipherInfoEntry.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
public static Type SqlSecurityUtil = systemData.GetType("Microsoft.Data.SqlClient.SqlSecurityUtility", throwOnError: true);
public static MethodInfo SqlSecurityUtilEncryptWithKey = SqlSecurityUtil.GetMethod("EncryptWithKey", BindingFlags.Static | BindingFlags.NonPublic);
public static MethodInfo SqlSecurityUtilDecryptWithKey = SqlSecurityUtil.GetMethod("DecryptWithKey", BindingFlags.Static | BindingFlags.NonPublic);
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs
index 5661551771..6e22d25db5 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs
@@ -77,7 +77,7 @@ internal static string GetTokenHash(object authenticationContextValueObj)
byte[] tokenBytes = (byte[])authenticationContextValueObj.GetType().GetProperty("AccessToken", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(authenticationContextValueObj, null);
object sqlFedAuthTokenObj = sqlFedAuthTokenConstructorInfo.Invoke(new object[] { });
- FieldInfo accessTokenInfo = sqlFedAuthTokenObj.GetType().GetField("_accessToken", BindingFlags.NonPublic | BindingFlags.Instance);
+ FieldInfo accessTokenInfo = sqlFedAuthTokenObj.GetType().GetField("AccessToken", BindingFlags.NonPublic | BindingFlags.Instance);
accessTokenInfo.SetValue(sqlFedAuthTokenObj, tokenBytes);
string tokenHash = (string)tokenHashInfo.Invoke(activeDirectoryAuthenticationTimeoutRetryHelperObj, new object[] { sqlFedAuthTokenObj });
From 4629659a240a7d04b85440a41fe08e7363ca1800 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Sat, 24 Aug 2024 09:21:10 +0100
Subject: [PATCH 12/14] Reverting member name/visibility linting
This will be tackled in a future PR
---
.../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 98 +--
.../Microsoft/Data/SqlClient/SqlCommand.cs | 204 +++---
.../Microsoft/Data/SqlClient/SqlConnection.cs | 16 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 394 ++++++------
.../Microsoft/Data/SqlClient/SqlDbColumn.cs | 28 +-
.../SqlClient/SqlInternalConnectionTds.cs | 84 +--
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 532 ++++++++--------
.../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 100 +--
.../Microsoft/Data/SqlClient/SqlCommand.cs | 216 +++----
.../Microsoft/Data/SqlClient/SqlConnection.cs | 16 +-
.../Microsoft/Data/SqlClient/SqlDataReader.cs | 384 ++++++------
.../SqlClient/SqlInternalConnectionTds.cs | 86 +--
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 580 +++++++++---------
...rectoryAuthenticationTimeoutRetryHelper.cs | 2 +-
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 116 ++--
.../Data/SqlClient/EnclaveDelegate.cs | 6 +-
.../Data/SqlClient/SqlAuthenticationToken.cs | 6 +-
.../Data/SqlClient/SqlCachedBuffer.cs | 2 +-
.../Data/SqlClient/SqlQueryMetadataCache.cs | 4 +-
.../Data/SqlClient/SqlSecurityUtility.cs | 16 +-
.../Data/SqlClient/SqlSymmetricKeyCache.cs | 18 +-
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 58 +-
.../Data/SqlClient/TdsParserHelperClasses.cs | 323 +++++-----
.../AlwaysEncryptedTests/Utility.cs | 6 +-
.../SystemDataInternals/FedAuthTokenHelper.cs | 2 +-
25 files changed, 1648 insertions(+), 1649 deletions(-)
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
index 5c71ad8cc4..93bf6e119f 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
@@ -556,7 +556,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
rejectColumn = false;
// Check for excluded types
- if ((metadata.Type == SqlDbType.Timestamp)
+ if ((metadata.type == SqlDbType.Timestamp)
|| ((metadata.IsIdentity) && !IsCopyOption(SqlBulkCopyOptions.KeepIdentity)))
{
// Remove metadata for excluded columns
@@ -569,8 +569,8 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
int assocId;
for (assocId = 0; assocId < _localColumnMappings.Count; assocId++)
{
- if ((_localColumnMappings[assocId]._destinationColumnOrdinal == metadata.Ordinal) ||
- (UnquotedName(_localColumnMappings[assocId]._destinationColumnName) == metadata.Column))
+ if ((_localColumnMappings[assocId]._destinationColumnOrdinal == metadata.ordinal) ||
+ (UnquotedName(_localColumnMappings[assocId]._destinationColumnName) == metadata.column))
{
if (rejectColumn)
{
@@ -579,7 +579,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
_sortedColumnMappings.Add(new _ColumnMapping(_localColumnMappings[assocId]._internalSourceColumnOrdinal, metadata));
- destColumnNames.Add(metadata.Column);
+ destColumnNames.Add(metadata.column);
nmatched++;
if (nmatched > 1)
@@ -588,25 +588,25 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
// Some datatypes need special handling ...
- if (metadata.Type == SqlDbType.Variant)
+ if (metadata.type == SqlDbType.Variant)
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.Column, "sql_variant");
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, "sql_variant");
}
- else if (metadata.Type == SqlDbType.Udt)
+ else if (metadata.type == SqlDbType.Udt)
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.Column, "varbinary");
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, "varbinary");
}
else
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.Column, metadata.Type.ToString());
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, metadata.type.ToString());
}
- switch (metadata.MetaType.NullableType)
+ switch (metadata.metaType.NullableType)
{
case TdsEnums.SQLNUMERICN:
case TdsEnums.SQLDECIMALN:
// Decimal and numeric need to include precision and scale
- updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0},{1})", metadata.Precision, metadata.Scale);
+ updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0},{1})", metadata.precision, metadata.scale);
break;
case TdsEnums.SQLUDT:
{
@@ -616,7 +616,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
else
{
- int size = metadata.Length;
+ int size = metadata.length;
updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", size);
}
break;
@@ -625,15 +625,15 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
case TdsEnums.SQLDATETIME2:
case TdsEnums.SQLDATETIMEOFFSET:
// date, dateime2, and datetimeoffset need to include scale
- updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", metadata.Scale);
+ updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", metadata.scale);
break;
default:
{
// For non-long non-fixed types we need to add the Size
- if (!metadata.MetaType.IsFixed && !metadata.MetaType.IsLong)
+ if (!metadata.metaType.IsFixed && !metadata.metaType.IsLong)
{
- int size = metadata.Length;
- switch (metadata.MetaType.NullableType)
+ int size = metadata.length;
+ switch (metadata.metaType.NullableType)
{
case TdsEnums.SQLNCHAR:
case TdsEnums.SQLNVARCHAR:
@@ -645,7 +645,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", size);
}
- else if (metadata.MetaType.IsPlp && metadata.MetaType.SqlDbType != SqlDbType.Xml)
+ else if (metadata.metaType.IsPlp && metadata.metaType.SqlDbType != SqlDbType.Xml)
{
// Partial length column prefix (max)
updateBulkCommandText.Append("(max)");
@@ -659,7 +659,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
object rowvalue = rowset[i][CollationId];
bool shouldSendCollation;
- switch (metadata.Type)
+ switch (metadata.type)
{
case SqlDbType.Char:
case SqlDbType.NChar:
@@ -683,15 +683,15 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
{
updateBulkCommandText.Append(" COLLATE " + collation_name.Value);
// Compare collations only if the collation value was set on the metadata
- if (_sqlDataReaderRowSource != null && metadata.Collation != null)
+ if (_sqlDataReaderRowSource != null && metadata.collation != null)
{
// On SqlDataReader we can verify the sourcecolumn collation!
int sourceColumnId = _localColumnMappings[assocId]._internalSourceColumnOrdinal;
- int destinationLcid = metadata.Collation.LCID;
+ int destinationLcid = metadata.collation.LCID;
int sourceLcid = _sqlDataReaderRowSource.GetLocaleId(sourceColumnId);
if (sourceLcid != destinationLcid)
{
- throw SQL.BulkLoadLcidMismatch(sourceLcid, _sqlDataReaderRowSource.GetName(sourceColumnId), destinationLcid, metadata.Column);
+ throw SQL.BulkLoadLcidMismatch(sourceLcid, _sqlDataReaderRowSource.GetName(sourceColumnId), destinationLcid, metadata.column);
}
}
}
@@ -958,7 +958,7 @@ private object GetValueFromSourceRow(int destRowIndex, out bool isSqlType, out b
object value = _sqlDataReaderRowSource.GetValue(sourceOrdinal);
isNull = ((value == null) || (value == DBNull.Value));
- if ((!isNull) && (metadata.Type == SqlDbType.Udt))
+ if ((!isNull) && (metadata.type == SqlDbType.Udt))
{
var columnAsINullable = value as INullable;
isNull = (columnAsINullable != null) && columnAsINullable.IsNull;
@@ -1170,7 +1170,7 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
bool isSqlType;
bool isDataFeed;
- if (((_sqlDataReaderRowSource != null) || (_dataTableSource != null)) && ((metadata.MetaType.NullableType == TdsEnums.SQLDECIMALN) || (metadata.MetaType.NullableType == TdsEnums.SQLNUMERICN)))
+ if (((_sqlDataReaderRowSource != null) || (_dataTableSource != null)) && ((metadata.metaType.NullableType == TdsEnums.SQLDECIMALN) || (metadata.metaType.NullableType == TdsEnums.SQLNUMERICN)))
{
isDataFeed = false;
@@ -1213,28 +1213,28 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
}
// Check for data streams
- else if ((_enableStreaming) && (metadata.Length == MAX_LENGTH))
+ else if ((_enableStreaming) && (metadata.length == MAX_LENGTH))
{
isSqlType = false;
if (_sqlDataReaderRowSource != null)
{
// MetaData property is not set for SMI, but since streaming is disabled we do not need it
- MetaType mtSource = _sqlDataReaderRowSource.MetaData[sourceOrdinal].MetaType;
+ MetaType mtSource = _sqlDataReaderRowSource.MetaData[sourceOrdinal].metaType;
// There is no memory gain for non-sequential access for binary
- if ((metadata.Type == SqlDbType.VarBinary) && (mtSource.IsBinType) && (mtSource.SqlDbType != SqlDbType.Timestamp) && _sqlDataReaderRowSource.IsCommandBehavior(CommandBehavior.SequentialAccess))
+ if ((metadata.type == SqlDbType.VarBinary) && (mtSource.IsBinType) && (mtSource.SqlDbType != SqlDbType.Timestamp) && _sqlDataReaderRowSource.IsCommandBehavior(CommandBehavior.SequentialAccess))
{
isDataFeed = true;
method = ValueMethod.DataFeedStream;
}
// For text and XML there is memory gain from streaming on destination side even if reader is non-sequential
- else if (((metadata.Type == SqlDbType.VarChar) || (metadata.Type == SqlDbType.NVarChar)) && (mtSource.IsCharType) && (mtSource.SqlDbType != SqlDbType.Xml))
+ else if (((metadata.type == SqlDbType.VarChar) || (metadata.type == SqlDbType.NVarChar)) && (mtSource.IsCharType) && (mtSource.SqlDbType != SqlDbType.Xml))
{
isDataFeed = true;
method = ValueMethod.DataFeedText;
}
- else if ((metadata.Type == SqlDbType.Xml) && (mtSource.SqlDbType == SqlDbType.Xml))
+ else if ((metadata.type == SqlDbType.Xml) && (mtSource.SqlDbType == SqlDbType.Xml))
{
isDataFeed = true;
method = ValueMethod.DataFeedXml;
@@ -1247,12 +1247,12 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
else if (_dbDataReaderRowSource != null)
{
- if (metadata.Type == SqlDbType.VarBinary)
+ if (metadata.type == SqlDbType.VarBinary)
{
isDataFeed = true;
method = ValueMethod.DataFeedStream;
}
- else if ((metadata.Type == SqlDbType.VarChar) || (metadata.Type == SqlDbType.NVarChar))
+ else if ((metadata.type == SqlDbType.VarChar) || (metadata.type == SqlDbType.NVarChar))
{
isDataFeed = true;
method = ValueMethod.DataFeedText;
@@ -1451,28 +1451,28 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
if (!metadata.IsNullable)
{
- throw SQL.BulkLoadBulkLoadNotAllowDBNull(metadata.Column);
+ throw SQL.BulkLoadBulkLoadNotAllowDBNull(metadata.column);
}
return value;
}
- MetaType type = metadata.MetaType;
+ MetaType type = metadata.metaType;
bool typeChanged = false;
// If the column is encrypted then we are going to transparently encrypt this column
// (based on connection string setting)- Use the metaType for the underlying
// value (unencrypted value) for conversion/casting purposes (below).
// Note - this flag is set if connection string options has TCE turned on
- byte scale = metadata.Scale;
- byte precision = metadata.Precision;
- int length = metadata.Length;
- if (metadata.IsEncrypted)
+ byte scale = metadata.scale;
+ byte precision = metadata.precision;
+ int length = metadata.length;
+ if (metadata.isEncrypted)
{
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- type = metadata.BaseTI.MetaType;
- scale = metadata.BaseTI.Scale;
- precision = metadata.BaseTI.Precision;
- length = metadata.BaseTI.Length;
+ type = metadata.baseTI.metaType;
+ scale = metadata.baseTI.scale;
+ precision = metadata.baseTI.precision;
+ length = metadata.baseTI.length;
}
try
@@ -1513,7 +1513,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
}
catch (SqlTruncateException)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
}
}
@@ -1558,7 +1558,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
int maxStringLength = length / 2;
if (str.Length > maxStringLength)
{
- if (metadata.IsEncrypted)
+ if (metadata.isEncrypted)
{
str = "";
}
@@ -1568,7 +1568,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
// https://blogs.msdn.microsoft.com/sql_server_team/string-or-binary-data-would-be-truncated-replacing-the-infamous-error-8152/
str = str.Remove(Math.Min(maxStringLength, 100));
}
- throw SQL.BulkLoadStringTooLong(_destinationTableName, metadata.Column, str);
+ throw SQL.BulkLoadStringTooLong(_destinationTableName, metadata.column, str);
}
}
break;
@@ -1602,7 +1602,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
default:
Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), null);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), null);
}
if (typeChanged)
@@ -1619,7 +1619,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
throw;
}
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), e);
}
}
@@ -2160,17 +2160,17 @@ private Task ReadWriteColumnValueAsync(int col)
// If column encryption is requested via connection string option, perform encryption here
if (!isNull && // if value is not NULL
- metadata.IsEncrypted)
+ metadata.isEncrypted)
{ // If we are transparently encrypting
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- value = _parser.EncryptColumnValue(value, metadata, metadata.Column, _stateObj, isDataFeed, isSqlType);
+ value = _parser.EncryptColumnValue(value, metadata, metadata.column, _stateObj, isDataFeed, isSqlType);
isSqlType = false; // Its not a sql type anymore
}
}
//write part
Task writeTask = null;
- if (metadata.Type != SqlDbType.Variant)
+ if (metadata.type != SqlDbType.Variant)
{
//this is the most common path
writeTask = _parser.WriteBulkCopyValue(value, metadata, _stateObj, isSqlType, isDataFeed, isNull); //returns Task/Null
@@ -2178,7 +2178,7 @@ private Task ReadWriteColumnValueAsync(int col)
else
{
// Target type shouldn't be encrypted
- Debug.Assert(!metadata.IsEncrypted, "Can't encrypt SQL Variant type");
+ Debug.Assert(!metadata.isEncrypted, "Can't encrypt SQL Variant type");
SqlBuffer.StorageType variantInternalType = SqlBuffer.StorageType.Empty;
if ((_sqlDataReaderRowSource != null) && (_connection.Is2008OrNewer))
{
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
index 8e9e329ecb..91d6e3e744 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
@@ -4168,9 +4168,9 @@ private SqlDataReader TryFetchInputParameterEncryptionInfo(int timeout,
{
// In BatchRPCMode, the actual T-SQL query is in the first parameter and not present as the rpcName, as is the case with non-BatchRPCMode.
// So input parameters start at parameters[1]. parameters[0] is the actual T-SQL Statement. rpcName is sp_executesql.
- if (_RPCList[i].SystemParams.Length > 1)
+ if (_RPCList[i].systemParams.Length > 1)
{
- _RPCList[i].NeedsFetchParameterEncryptionMetadata = true;
+ _RPCList[i].needsFetchParameterEncryptionMetadata = true;
// Since we are going to need multiple RPC objects, allocate a new one here for each command in the batch.
_SqlRPC rpcDescribeParameterEncryptionRequest = new _SqlRPC();
@@ -4217,8 +4217,8 @@ private SqlDataReader TryFetchInputParameterEncryptionInfo(int timeout,
GetRPCObject(0, GetParameterCount(_parameters), ref rpc);
Debug.Assert(rpc != null, "GetRPCObject should not return rpc as null.");
- rpc.RpcName = CommandText;
- rpc.UserParams = _parameters;
+ rpc.rpcName = CommandText;
+ rpc.userParams = _parameters;
// Prepare the RPC request for describe parameter encryption procedure.
PrepareDescribeParameterEncryptionRequest(rpc, ref _sqlRPCParameterEncryptionReqArray[0], serializedAttestationParameters);
@@ -4269,7 +4269,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// sp_describe_parameter_encryption always has 2 parameters (stmt, paramlist).
// sp_describe_parameter_encryption can have an optional 3rd parameter (attestationParameters), used to identify and execute attestation protocol
GetRPCObject(attestationParameters == null ? 2 : 3, 0, ref describeParameterEncryptionRequest, forSpDescribeParameterEncryption: true);
- describeParameterEncryptionRequest.RpcName = "sp_describe_parameter_encryption";
+ describeParameterEncryptionRequest.rpcName = "sp_describe_parameter_encryption";
// Prepare @tsql parameter
string text;
@@ -4277,11 +4277,11 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// In _batchRPCMode, The actual T-SQL query is in the first parameter and not present as the rpcName, as is the case with non-_batchRPCMode.
if (_batchRPCMode)
{
- Debug.Assert(originalRpcRequest.SystemParamCount > 0,
+ Debug.Assert(originalRpcRequest.systemParamCount > 0,
"originalRpcRequest didn't have at-least 1 parameter in _batchRPCMode, in PrepareDescribeParameterEncryptionRequest.");
- text = (string)originalRpcRequest.SystemParams[0].Value;
+ text = (string)originalRpcRequest.systemParams[0].Value;
//@tsql
- SqlParameter tsqlParam = describeParameterEncryptionRequest.SystemParams[0];
+ SqlParameter tsqlParam = describeParameterEncryptionRequest.systemParams[0];
tsqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
tsqlParam.Value = text;
tsqlParam.Size = text.Length;
@@ -4289,17 +4289,17 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
}
else
{
- text = originalRpcRequest.RpcName;
+ text = originalRpcRequest.rpcName;
if (CommandType == CommandType.StoredProcedure)
{
// For stored procedures, we need to prepare @tsql in the following format
// N'EXEC sp_name @param1=@param1, @param1=@param2, ..., @paramN=@paramN'
- describeParameterEncryptionRequest.SystemParams[0] = BuildStoredProcedureStatementForColumnEncryption(text, originalRpcRequest.UserParams);
+ describeParameterEncryptionRequest.systemParams[0] = BuildStoredProcedureStatementForColumnEncryption(text, originalRpcRequest.userParams);
}
else
{
//@tsql
- SqlParameter tsqlParam = describeParameterEncryptionRequest.SystemParams[0];
+ SqlParameter tsqlParam = describeParameterEncryptionRequest.systemParams[0];
tsqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
tsqlParam.Value = text;
tsqlParam.Size = text.Length;
@@ -4315,9 +4315,9 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
if (_batchRPCMode)
{
// systemParamCount == 2 when user parameters are supplied to BuildExecuteSql
- if (originalRpcRequest.SystemParamCount > 1)
+ if (originalRpcRequest.systemParamCount > 1)
{
- parameterList = (string)originalRpcRequest.SystemParams[1].Value;
+ parameterList = (string)originalRpcRequest.systemParams[1].Value;
}
}
else
@@ -4326,11 +4326,11 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// Need to create new parameters as we cannot have the same parameter being part of two SqlCommand objects
SqlParameterCollection tempCollection = new SqlParameterCollection();
- if (originalRpcRequest.UserParams != null)
+ if (originalRpcRequest.userParams != null)
{
- for (int i = 0; i < originalRpcRequest.UserParams.Count; i++)
+ for (int i = 0; i < originalRpcRequest.userParams.Count; i++)
{
- SqlParameter param = originalRpcRequest.UserParams[i];
+ SqlParameter param = originalRpcRequest.userParams[i];
SqlParameter paramCopy = new SqlParameter(
param.ParameterName,
param.SqlDbType,
@@ -4376,7 +4376,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
//@parameters
- SqlParameter paramsParam = describeParameterEncryptionRequest.SystemParams[1];
+ SqlParameter paramsParam = describeParameterEncryptionRequest.systemParams[1];
paramsParam.SqlDbType = ((parameterList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
paramsParam.Size = parameterList.Length;
paramsParam.Value = parameterList;
@@ -4384,7 +4384,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
if (attestationParameters != null)
{
- SqlParameter attestationParametersParam = describeParameterEncryptionRequest.SystemParams[2];
+ SqlParameter attestationParametersParam = describeParameterEncryptionRequest.systemParams[2];
attestationParametersParam.SqlDbType = SqlDbType.VarBinary;
attestationParametersParam.Size = attestationParameters.Length;
attestationParametersParam.Value = attestationParameters;
@@ -4565,7 +4565,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
Debug.Assert(rpc != null, "rpc should not be null here.");
- int userParamCount = rpc.UserParams?.Count ?? 0;
+ int userParamCount = rpc.userParams?.Count ?? 0;
int recievedMetadataCount = 0;
if (!enclaveMetadataExists || ds.NextResult())
{
@@ -4584,7 +4584,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
for (int index = 0; index < userParamCount; index++)
{
- SqlParameter sqlParameter = rpc.UserParams[index];
+ SqlParameter sqlParameter = rpc.userParams[index];
Debug.Assert(sqlParameter != null, "sqlParameter should not be null.");
if (SqlParameter.ParameterNamesEqual(sqlParameter.ParameterName, parameterName, StringComparison.Ordinal))
@@ -4619,9 +4619,9 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
// This is effective only for _batchRPCMode even though we set it for non-_batchRPCMode also,
// since for non-_batchRPCMode mode, paramoptions gets thrown away and reconstructed in BuildExecuteSql.
- int options = (int)(rpc.UserParamMap[index] >> 32);
+ int options = (int)(rpc.userParamMap[index] >> 32);
options |= TdsEnums.RPC_PARAM_ENCRYPTED;
- rpc.UserParamMap[index] = ((((long)options) << 32) | (long)index);
+ rpc.userParamMap[index] = ((((long)options) << 32) | (long)index);
}
break;
@@ -4637,7 +4637,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
for (int index = 0; index < userParamCount; index++)
{
- SqlParameter sqlParameter = rpc.UserParams[index];
+ SqlParameter sqlParameter = rpc.userParams[index];
if (!sqlParameter.HasReceivedMetadata && sqlParameter.Direction != ParameterDirection.ReturnValue)
{
// Encryption MD wasn't sent by the server - we expect the metadata to be sent for all the parameters
@@ -4698,7 +4698,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
}
// The server has responded with encryption related information for this rpc request. So clear the needsFetchParameterEncryptionMetadata flag.
- rpc.NeedsFetchParameterEncryptionMetadata = false;
+ rpc.needsFetchParameterEncryptionMetadata = false;
} while (ds.NextResult());
// Verify that we received response for each rpc call needs tce
@@ -4706,9 +4706,9 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
for (int i = 0; i < _RPCList.Count; i++)
{
- if (_RPCList[i].NeedsFetchParameterEncryptionMetadata)
+ if (_RPCList[i].needsFetchParameterEncryptionMetadata)
{
- throw SQL.ProcEncryptionMetadataMissing(_RPCList[i].RpcName);
+ throw SQL.ProcEncryptionMetadataMissing(_RPCList[i].rpcName);
}
}
}
@@ -5104,10 +5104,10 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi
BuildExecuteSql(cmdBehavior, null, _parameters, ref rpc);
}
- rpc.Options = TdsEnums.RPC_NOMETADATA;
+ rpc.options = TdsEnums.RPC_NOMETADATA;
if (returnStream)
{
- SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?.RpcName);
+ SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?.rpcName);
}
Debug.Assert(_rpcArrayOf1[0] == rpc);
@@ -5125,7 +5125,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi
optionSettings = GetSetOptionsString(cmdBehavior);
if (returnStream)
{
- SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?.RpcName);
+ SqlClientEventSource.Log.TryTraceEvent("SqlCommand.RunExecuteReaderTds | Info | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command executed as RPC, RPC Name '{3}' ", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, rpc?.rpcName);
}
// turn set options ON
@@ -5584,29 +5584,29 @@ private static void OnDone(TdsParserStateObject stateObj, int index, IList<_SqlR
// track the records affected for the just completed rpc batch
// _rowsAffected is cumulative for ExecuteNonQuery across all rpc batches
- current.CumulativeRecordsAffected = rowsAffected;
+ current.cumulativeRecordsAffected = rowsAffected;
- current.RecordsAffected =
+ current.recordsAffected =
(((previous != null) && (0 <= rowsAffected))
- ? (rowsAffected - Math.Max(previous.CumulativeRecordsAffected, 0))
+ ? (rowsAffected - Math.Max(previous.cumulativeRecordsAffected, 0))
: rowsAffected);
- if (current.BatchCommand != null)
+ if (current.batchCommand != null)
{
- current.BatchCommand.SetRecordAffected(current.RecordsAffected.GetValueOrDefault());
+ current.batchCommand.SetRecordAffected(current.recordsAffected.GetValueOrDefault());
}
// track the error collection (not available from TdsParser after ExecuteNonQuery)
// and the which errors are associated with the just completed rpc batch
- current.ErrorsIndexStart = previous?.ErrorsIndexEnd ?? 0;
- current.ErrorsIndexEnd = stateObj.ErrorCount;
- current.Errors = stateObj._errors;
+ current.errorsIndexStart = previous?.errorsIndexEnd ?? 0;
+ current.errorsIndexEnd = stateObj.ErrorCount;
+ current.errors = stateObj._errors;
// track the warning collection (not available from TdsParser after ExecuteNonQuery)
// and the which warnings are associated with the just completed rpc batch
- current.WarningsIndexStart = previous?.WarningsIndexEnd ?? 0;
- current.WarningsIndexEnd = stateObj.WarningCount;
- current.Warnings = stateObj._warnings;
+ current.warningsIndexStart = previous?.warningsIndexEnd ?? 0;
+ current.warningsIndexEnd = stateObj.WarningCount;
+ current.warnings = stateObj._warnings;
}
internal void OnReturnStatus(int status)
@@ -5622,7 +5622,7 @@ internal void OnReturnStatus(int status)
{
if (_RPCList.Count > _currentlyExecutingBatch)
{
- parameters = _RPCList[_currentlyExecutingBatch].UserParams;
+ parameters = _RPCList[_currentlyExecutingBatch].userParams;
}
else
{
@@ -5673,9 +5673,9 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
{
if (_inPrepare)
{
- if (!rec.Value.IsNull)
+ if (!rec.value.IsNull)
{
- _prepareHandle = rec.Value.Int32;
+ _prepareHandle = rec.value.Int32;
}
_inPrepare = false;
return;
@@ -5684,21 +5684,21 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
SqlParameterCollection parameters = GetCurrentParameterCollection();
int count = GetParameterCount(parameters);
- SqlParameter thisParam = GetParameterForOutputValueExtraction(parameters, rec.Parameter, count);
+ SqlParameter thisParam = GetParameterForOutputValueExtraction(parameters, rec.parameter, count);
if (thisParam != null)
{
// If the parameter's direction is InputOutput, Output or ReturnValue and it needs to be transparently encrypted/decrypted
// then simply decrypt, deserialize and set the value.
- if (rec.CipherMD != null &&
+ if (rec.cipherMD != null &&
thisParam.CipherMetadata != null &&
(thisParam.Direction == ParameterDirection.Output ||
thisParam.Direction == ParameterDirection.InputOutput ||
thisParam.Direction == ParameterDirection.ReturnValue))
{
- if (rec.TdsType != TdsEnums.SQLBIGVARBINARY)
+ if (rec.tdsType != TdsEnums.SQLBIGVARBINARY)
{
- throw SQL.InvalidDataTypeForEncryptedParameter(thisParam.GetPrefixedParameterName(), rec.TdsType, TdsEnums.SQLBIGVARBINARY);
+ throw SQL.InvalidDataTypeForEncryptedParameter(thisParam.GetPrefixedParameterName(), rec.tdsType, TdsEnums.SQLBIGVARBINARY);
}
// Decrypt the ciphertext
@@ -5708,15 +5708,15 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
throw ADP.ClosedConnectionError();
}
- if (!rec.Value.IsNull)
+ if (!rec.value.IsNull)
{
try
{
Debug.Assert(_activeConnection != null, @"_activeConnection should not be null");
// Get the key information from the parameter and decrypt the value.
- rec.CipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.Value.ByteArray, rec.CipherMD, _activeConnection, this);
+ rec.cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec.cipherMD, _activeConnection, this);
if (unencryptedBytes != null)
{
@@ -5760,13 +5760,13 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
Connection.CheckGetExtendedUDTInfo(rec, true);
//extract the byte array from the param value
- if (rec.Value.IsNull)
+ if (rec.value.IsNull)
{
data = DBNull.Value;
}
else
{
- data = rec.Value.ByteArray; //should work for both sql and non-sql values
+ data = rec.value.ByteArray; //should work for both sql and non-sql values
}
//call the connection to instantiate the UDT object
@@ -5789,21 +5789,21 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
}
else
{
- thisParam.SetSqlBuffer(rec.Value);
+ thisParam.SetSqlBuffer(rec.value);
}
- MetaType mt = MetaType.GetMetaTypeFromSqlDbType(rec.Type, false);
+ MetaType mt = MetaType.GetMetaTypeFromSqlDbType(rec.type, false);
- if (rec.Type == SqlDbType.Decimal)
+ if (rec.type == SqlDbType.Decimal)
{
- thisParam.ScaleInternal = rec.Scale;
- thisParam.PrecisionInternal = rec.Precision;
+ thisParam.ScaleInternal = rec.scale;
+ thisParam.PrecisionInternal = rec.precision;
}
else if (mt.IsVarTime)
{
- thisParam.ScaleInternal = rec.Scale;
+ thisParam.ScaleInternal = rec.scale;
}
- else if (rec.Type == SqlDbType.Xml)
+ else if (rec.type == SqlDbType.Xml)
{
SqlCachedBuffer cachedBuffer = (thisParam.Value as SqlCachedBuffer);
if (cachedBuffer != null)
@@ -5812,10 +5812,10 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
}
}
- if (rec.Collation != null)
+ if (rec.collation != null)
{
Debug.Assert(mt.IsCharType, "Invalid collation structure for non-char type");
- thisParam.Collation = rec.Collation;
+ thisParam.Collation = rec.collation;
}
}
}
@@ -5829,7 +5829,7 @@ private SqlParameterCollection GetCurrentParameterCollection()
{
if (_RPCList.Count > _currentlyExecutingBatch)
{
- return _RPCList[_currentlyExecutingBatch].UserParams;
+ return _RPCList[_currentlyExecutingBatch].userParams;
}
else
{
@@ -5912,33 +5912,33 @@ private void GetRPCObject(int systemParamCount, int userParamCount, ref _SqlRPC
}
}
- rpc.ProcId = 0;
- rpc.RpcName = null;
- rpc.Options = 0;
- rpc.SystemParamCount = systemParamCount;
- rpc.NeedsFetchParameterEncryptionMetadata = false;
+ rpc.ProcID = 0;
+ rpc.rpcName = null;
+ rpc.options = 0;
+ rpc.systemParamCount = systemParamCount;
+ rpc.needsFetchParameterEncryptionMetadata = false;
- int currentCount = rpc.SystemParams?.Length ?? 0;
+ int currentCount = rpc.systemParams?.Length ?? 0;
// Make sure there is enough space in the parameters and paramoptions arrays
if (currentCount < systemParamCount)
{
- Array.Resize(ref rpc.SystemParams, systemParamCount);
- Array.Resize(ref rpc.SystemParamOptions, systemParamCount);
+ Array.Resize(ref rpc.systemParams, systemParamCount);
+ Array.Resize(ref rpc.systemParamOptions, systemParamCount);
for (int index = currentCount; index < systemParamCount; index++)
{
- rpc.SystemParams[index] = new SqlParameter();
+ rpc.systemParams[index] = new SqlParameter();
}
}
for (int ii = 0; ii < systemParamCount; ii++)
{
- rpc.SystemParamOptions[ii] = 0;
+ rpc.systemParamOptions[ii] = 0;
}
- if ((rpc.UserParamMap?.Length ?? 0) < userParamCount)
+ if ((rpc.userParamMap?.Length ?? 0) < userParamCount)
{
- Array.Resize(ref rpc.UserParamMap, userParamCount);
+ Array.Resize(ref rpc.userParamMap, userParamCount);
}
}
@@ -6006,14 +6006,14 @@ private void SetUpRPCParameters(_SqlRPC rpc, bool inSchema, SqlParameterCollecti
}
}
- rpc.UserParamMap[userParamCount] = ((((long)options) << 32) | (long)index);
+ rpc.userParamMap[userParamCount] = ((((long)options) << 32) | (long)index);
userParamCount += 1;
// Must set parameter option bit for LOB_COOKIE if unfilled LazyMat blob
}
}
- rpc.UserParamCount = userParamCount;
- rpc.UserParams = parameters;
+ rpc.userParamCount = userParamCount;
+ rpc.userParams = parameters;
}
private _SqlRPC BuildPrepExec(CommandBehavior behavior)
@@ -6027,20 +6027,20 @@ private _SqlRPC BuildPrepExec(CommandBehavior behavior)
_SqlRPC rpc = null;
GetRPCObject(systemParameterCount, userParameterCount, ref rpc);
- rpc.ProcId = TdsEnums.RPC_PROCID_PREPEXEC;
- rpc.RpcName = TdsEnums.SP_PREPEXEC;
+ rpc.ProcID = TdsEnums.RPC_PROCID_PREPEXEC;
+ rpc.rpcName = TdsEnums.SP_PREPEXEC;
//@handle
- sqlParam = rpc.SystemParams[0];
+ sqlParam = rpc.systemParams[0];
sqlParam.SqlDbType = SqlDbType.Int;
sqlParam.Value = _prepareHandle;
sqlParam.Size = 4;
sqlParam.Direction = ParameterDirection.InputOutput;
- rpc.SystemParamOptions[0] = TdsEnums.RPC_PARAM_BYREF;
+ rpc.systemParamOptions[0] = TdsEnums.RPC_PARAM_BYREF;
//@batch_params
string paramList = BuildParamList(_stateObj.Parser, _parameters);
- sqlParam = rpc.SystemParams[1];
+ sqlParam = rpc.systemParams[1];
sqlParam.SqlDbType = ((paramList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Value = paramList;
sqlParam.Size = paramList.Length;
@@ -6048,7 +6048,7 @@ private _SqlRPC BuildPrepExec(CommandBehavior behavior)
//@batch_text
string text = GetCommandText(behavior);
- sqlParam = rpc.SystemParams[2];
+ sqlParam = rpc.systemParams[2];
sqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = text.Length;
sqlParam.Value = text;
@@ -6113,7 +6113,7 @@ private void BuildRPC(bool inSchema, SqlParameterCollection parameters, ref _Sql
int userParameterCount = CountSendableParameters(parameters);
GetRPCObject(0, userParameterCount, ref rpc);
- rpc.ProcId = 0;
+ rpc.ProcID = 0;
// TDS Protocol allows rpc name with maximum length of 1046 bytes for ProcName
// 4-part name 1 + 128 + 1 + 1 + 1 + 128 + 1 + 1 + 1 + 128 + 1 + 1 + 1 + 128 + 1 = 523
@@ -6122,7 +6122,7 @@ private void BuildRPC(bool inSchema, SqlParameterCollection parameters, ref _Sql
if (commandTextLength <= MaxRPCNameLength)
{
- rpc.RpcName = CommandText; // just get the raw command text
+ rpc.rpcName = CommandText; // just get the raw command text
}
else
{
@@ -6148,11 +6148,11 @@ private _SqlRPC BuildExecute(bool inSchema)
_SqlRPC rpc = null;
GetRPCObject(systemParameterCount, userParameterCount, ref rpc);
- rpc.ProcId = TdsEnums.RPC_PROCID_EXECUTE;
- rpc.RpcName = TdsEnums.SP_EXECUTE;
+ rpc.ProcID = TdsEnums.RPC_PROCID_EXECUTE;
+ rpc.rpcName = TdsEnums.SP_EXECUTE;
//@handle
- SqlParameter sqlParam = rpc.SystemParams[0];
+ SqlParameter sqlParam = rpc.systemParams[0];
sqlParam.SqlDbType = SqlDbType.Int;
sqlParam.Size = 4;
sqlParam.Value = _prepareHandle;
@@ -6186,15 +6186,15 @@ private void BuildExecuteSql(CommandBehavior behavior, string commandText, SqlPa
}
GetRPCObject(systemParamCount, userParamCount, ref rpc);
- rpc.ProcId = TdsEnums.RPC_PROCID_EXECUTESQL;
- rpc.RpcName = TdsEnums.SP_EXECUTESQL;
+ rpc.ProcID = TdsEnums.RPC_PROCID_EXECUTESQL;
+ rpc.rpcName = TdsEnums.SP_EXECUTESQL;
// @sql
if (commandText == null)
{
commandText = GetCommandText(behavior);
}
- sqlParam = rpc.SystemParams[0];
+ sqlParam = rpc.systemParams[0];
sqlParam.SqlDbType = ((commandText.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = commandText.Length;
sqlParam.Value = commandText;
@@ -6203,7 +6203,7 @@ private void BuildExecuteSql(CommandBehavior behavior, string commandText, SqlPa
if (userParamCount > 0)
{
string paramList = BuildParamList(_stateObj.Parser, _batchRPCMode ? parameters : _parameters);
- sqlParam = rpc.SystemParams[1];
+ sqlParam = rpc.systemParams[1];
sqlParam.SqlDbType = ((paramList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = paramList.Length;
sqlParam.Value = paramList;
@@ -6736,7 +6736,7 @@ internal void AddBatchCommand(SqlBatchCommand batchCommand)
_SqlRPC rpc = new _SqlRPC
{
- BatchCommand = batchCommand
+ batchCommand = batchCommand
};
string commandText = batchCommand.CommandText;
CommandType cmdType = batchCommand.CommandType;
@@ -6767,24 +6767,24 @@ internal void AddBatchCommand(SqlBatchCommand batchCommand)
{
Debug.Assert(_batchRPCMode, "Command is not in batch RPC Mode");
Debug.Assert(_RPCList != null, "batch command have been cleared");
- return _RPCList[commandIndex].RecordsAffected;
+ return _RPCList[commandIndex].recordsAffected;
}
internal SqlBatchCommand GetCurrentBatchCommand()
{
if (_batchRPCMode)
{
- return _RPCList[_currentlyExecutingBatch].BatchCommand;
+ return _RPCList[_currentlyExecutingBatch].batchCommand;
}
else
{
- return _rpcArrayOf1?[0].BatchCommand;
+ return _rpcArrayOf1?[0].batchCommand;
}
}
internal SqlBatchCommand GetBatchCommand(int index)
{
- return _RPCList[index].BatchCommand;
+ return _RPCList[index].batchCommand;
}
internal int GetCurrentBatchIndex()
@@ -6796,17 +6796,17 @@ internal SqlException GetErrors(int commandIndex)
{
SqlException result = null;
_SqlRPC rpc = _RPCList[commandIndex];
- int length = (rpc.ErrorsIndexEnd - rpc.ErrorsIndexStart);
+ int length = (rpc.errorsIndexEnd - rpc.errorsIndexStart);
if (0 < length)
{
SqlErrorCollection errors = new SqlErrorCollection();
- for (int i = rpc.ErrorsIndexStart; i < rpc.ErrorsIndexEnd; ++i)
+ for (int i = rpc.errorsIndexStart; i < rpc.errorsIndexEnd; ++i)
{
- errors.Add(rpc.Errors[i]);
+ errors.Add(rpc.errors[i]);
}
- for (int i = rpc.WarningsIndexStart; i < rpc.WarningsIndexEnd; ++i)
+ for (int i = rpc.warningsIndexStart; i < rpc.warningsIndexEnd; ++i)
{
- errors.Add(rpc.Warnings[i]);
+ errors.Add(rpc.warnings[i]);
}
result = SqlException.CreateException(errors, Connection.ServerVersion, Connection.ClientConnectionId, innerException: null, batchCommand: null);
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
index 074c7c8315..7da530b12a 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
@@ -2458,16 +2458,16 @@ private Assembly ResolveTypeAssembly(AssemblyName asmRef, bool throwOnError)
internal void CheckGetExtendedUDTInfo(SqlMetaDataPriv metaData, bool fThrow)
{
- if (metaData.Udt?.Type == null)
+ if (metaData.udt?.Type == null)
{ // If null, we have not obtained extended info.
- Debug.Assert(!string.IsNullOrEmpty(metaData.Udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
+ Debug.Assert(!string.IsNullOrEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
// Parameter throwOnError determines whether exception from Assembly.Load is thrown.
- metaData.Udt.Type =
- Type.GetType(typeName: metaData.Udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);
+ metaData.udt.Type =
+ Type.GetType(typeName: metaData.udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);
- if (fThrow && metaData.Udt.Type == null)
+ if (fThrow && metaData.udt.Type == null)
{
- throw SQL.UDTUnexpectedResult(metaData.Udt.AssemblyQualifiedName);
+ throw SQL.UDTUnexpectedResult(metaData.udt.AssemblyQualifiedName);
}
}
}
@@ -2484,7 +2484,7 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
// Since the serializer doesn't handle nulls...
if (ADP.IsNull(value))
{
- Type t = metaData.Udt?.Type;
+ Type t = metaData.udt?.Type;
Debug.Assert(t != null, "Unexpected null of udtType on GetUdtValue!");
o = t.InvokeMember("Null", BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Static, null, null, Array.Empty(), CultureInfo.InvariantCulture);
Debug.Assert(o != null);
@@ -2495,7 +2495,7 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
MemoryStream stm = new MemoryStream((byte[])value);
- o = Server.SerializationHelperSql9.Deserialize(stm, metaData.Udt?.Type);
+ o = Server.SerializationHelperSql9.Deserialize(stm, metaData.udt?.Type);
Debug.Assert(o != null, "object could NOT be created");
return o;
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
index 90d1825849..bc6d66ecae 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs
@@ -280,60 +280,60 @@ internal virtual SmiExtendedMetaData[] GetInternalSmiMetaData()
if (!colMetaData.IsHidden)
{
- SqlCollation collation = colMetaData.Collation;
+ SqlCollation collation = colMetaData.collation;
string typeSpecificNamePart1 = null;
string typeSpecificNamePart2 = null;
string typeSpecificNamePart3 = null;
- if (SqlDbType.Xml == colMetaData.Type)
+ if (SqlDbType.Xml == colMetaData.type)
{
- typeSpecificNamePart1 = colMetaData.XmlSchemaCollection?.Database;
- typeSpecificNamePart2 = colMetaData.XmlSchemaCollection?.OwningSchema;
- typeSpecificNamePart3 = colMetaData.XmlSchemaCollection?.Name;
+ typeSpecificNamePart1 = colMetaData.xmlSchemaCollection?.Database;
+ typeSpecificNamePart2 = colMetaData.xmlSchemaCollection?.OwningSchema;
+ typeSpecificNamePart3 = colMetaData.xmlSchemaCollection?.Name;
}
- else if (SqlDbType.Udt == colMetaData.Type)
+ else if (SqlDbType.Udt == colMetaData.type)
{
Connection.CheckGetExtendedUDTInfo(colMetaData, true); // Ensure that colMetaData.udtType is set
- typeSpecificNamePart1 = colMetaData.Udt?.DatabaseName;
- typeSpecificNamePart2 = colMetaData.Udt?.SchemaName;
- typeSpecificNamePart3 = colMetaData.Udt?.TypeName;
+ typeSpecificNamePart1 = colMetaData.udt?.DatabaseName;
+ typeSpecificNamePart2 = colMetaData.udt?.SchemaName;
+ typeSpecificNamePart3 = colMetaData.udt?.TypeName;
}
- int length = colMetaData.Length;
+ int length = colMetaData.length;
if (length > TdsEnums.MAXSIZE)
{
length = (int)SmiMetaData.UnlimitedMaxLengthIndicator;
}
- else if (SqlDbType.NChar == colMetaData.Type
- || SqlDbType.NVarChar == colMetaData.Type)
+ else if (SqlDbType.NChar == colMetaData.type
+ || SqlDbType.NVarChar == colMetaData.type)
{
length /= ADP.CharSize;
}
metaDataReturn[returnIndex] =
new SmiQueryMetaData(
- colMetaData.Type,
+ colMetaData.type,
length,
- colMetaData.Precision,
- colMetaData.Scale,
+ colMetaData.precision,
+ colMetaData.scale,
collation != null ? collation.LCID : _defaultLCID,
collation != null ? collation.SqlCompareOptions : SqlCompareOptions.None,
- colMetaData.Udt?.Type,
+ colMetaData.udt?.Type,
false, // isMultiValued
null, // fieldmetadata
null, // extended properties
- colMetaData.Column,
+ colMetaData.column,
typeSpecificNamePart1,
typeSpecificNamePart2,
typeSpecificNamePart3,
colMetaData.IsNullable,
- colMetaData.ServerName,
- colMetaData.CatalogName,
- colMetaData.SchemaName,
- colMetaData.TableName,
- colMetaData.BaseColumn,
+ colMetaData.serverName,
+ colMetaData.catalogName,
+ colMetaData.schemaName,
+ colMetaData.tableName,
+ colMetaData.baseColumn,
colMetaData.IsKey,
colMetaData.IsIdentity,
colMetaData.IsReadOnly,
@@ -537,47 +537,47 @@ internal DataTable BuildSchemaTable()
_SqlMetaData col = md[i];
DataRow schemaRow = schemaTable.NewRow();
- schemaRow[columnName] = col.Column;
- schemaRow[ordinal] = col.Ordinal;
+ schemaRow[columnName] = col.column;
+ schemaRow[ordinal] = col.ordinal;
//
// be sure to return character count for string types, byte count otherwise
// col.length is always byte count so for unicode types, half the length
//
// For MAX and XML datatypes, we get 0x7fffffff from the server. Do not divide this.
- if (col.CipherMD != null)
+ if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null && col.BaseTI.MetaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
- schemaRow[size] = (col.BaseTI.MetaType.IsSizeInCharacters && (col.BaseTI.Length != 0x7fffffff)) ? (col.BaseTI.Length / 2) : col.BaseTI.Length;
+ Debug.Assert(col.baseTI != null && col.baseTI.metaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
+ schemaRow[size] = (col.baseTI.metaType.IsSizeInCharacters && (col.baseTI.length != 0x7fffffff)) ? (col.baseTI.length / 2) : col.baseTI.length;
}
else
{
- schemaRow[size] = (col.MetaType.IsSizeInCharacters && (col.Length != 0x7fffffff)) ? (col.Length / 2) : col.Length;
+ schemaRow[size] = (col.metaType.IsSizeInCharacters && (col.length != 0x7fffffff)) ? (col.length / 2) : col.length;
}
schemaRow[dataType] = GetFieldTypeInternal(col);
schemaRow[providerSpecificDataType] = GetProviderSpecificFieldTypeInternal(col);
- schemaRow[nonVersionedProviderType] = (int)(col.CipherMD != null ? col.BaseTI.Type : col.Type); // SqlDbType enum value - does not change with TypeSystem.
+ schemaRow[nonVersionedProviderType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type); // SqlDbType enum value - does not change with TypeSystem.
schemaRow[dataTypeName] = GetDataTypeNameInternal(col);
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.Is2008DateTimeType)
{
schemaRow[providerType] = SqlDbType.NVarChar;
- switch (col.Type)
+ switch (col.type)
{
case SqlDbType.Date:
schemaRow[size] = TdsEnums.WHIDBEY_DATE_LENGTH;
break;
case SqlDbType.Time:
- Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.Scale || (0 <= col.Scale && col.Scale <= 7), "Invalid scale for Time column: " + col.Scale);
- schemaRow[size] = TdsEnums.WHIDBEY_TIME_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale ? col.Scale : col.MetaType.Scale];
+ Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.scale || (0 <= col.scale && col.scale <= 7), "Invalid scale for Time column: " + col.scale);
+ schemaRow[size] = TdsEnums.WHIDBEY_TIME_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale ? col.scale : col.metaType.Scale];
break;
case SqlDbType.DateTime2:
- Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.Scale || (0 <= col.Scale && col.Scale <= 7), "Invalid scale for DateTime2 column: " + col.Scale);
- schemaRow[size] = TdsEnums.WHIDBEY_DATETIME2_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale ? col.Scale : col.MetaType.Scale];
+ Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.scale || (0 <= col.scale && col.scale <= 7), "Invalid scale for DateTime2 column: " + col.scale);
+ schemaRow[size] = TdsEnums.WHIDBEY_DATETIME2_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale ? col.scale : col.metaType.Scale];
break;
case SqlDbType.DateTimeOffset:
- Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.Scale || (0 <= col.Scale && col.Scale <= 7), "Invalid scale for DateTimeOffset column: " + col.Scale);
- schemaRow[size] = TdsEnums.WHIDBEY_DATETIMEOFFSET_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale ? col.Scale : col.MetaType.Scale];
+ Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.scale || (0 <= col.scale && col.scale <= 7), "Invalid scale for DateTimeOffset column: " + col.scale);
+ schemaRow[size] = TdsEnums.WHIDBEY_DATETIMEOFFSET_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale ? col.scale : col.metaType.Scale];
break;
}
}
@@ -598,19 +598,19 @@ internal DataTable BuildSchemaTable()
// TypeSystem.SQLServer2005 and above
// SqlDbType enum value - always the actual type for SQLServer2005.
- schemaRow[providerType] = (int)(col.CipherMD != null ? col.BaseTI.Type : col.Type);
+ schemaRow[providerType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type);
- if (col.Type == SqlDbType.Udt)
+ if (col.type == SqlDbType.Udt)
{ // Additional metadata for UDTs.
Debug.Assert(Connection.Is2008OrNewer, "Invalid Column type received from the server");
- schemaRow[udtAssemblyQualifiedName] = col.Udt?.AssemblyQualifiedName;
+ schemaRow[udtAssemblyQualifiedName] = col.udt?.AssemblyQualifiedName;
}
- else if (col.Type == SqlDbType.Xml)
+ else if (col.type == SqlDbType.Xml)
{ // Additional metadata for Xml.
Debug.Assert(Connection.Is2008OrNewer, "Invalid DataType (Xml) for the column");
- schemaRow[xmlSchemaCollectionDatabase] = col.XmlSchemaCollection?.Database;
- schemaRow[xmlSchemaCollectionOwningSchema] = col.XmlSchemaCollection?.OwningSchema;
- schemaRow[xmlSchemaCollectionName] = col.XmlSchemaCollection?.Name;
+ schemaRow[xmlSchemaCollectionDatabase] = col.xmlSchemaCollection?.Database;
+ schemaRow[xmlSchemaCollectionOwningSchema] = col.xmlSchemaCollection?.OwningSchema;
+ schemaRow[xmlSchemaCollectionName] = col.xmlSchemaCollection?.Name;
}
}
else
@@ -618,53 +618,53 @@ internal DataTable BuildSchemaTable()
// TypeSystem.SQLServer2000
// SqlDbType enum value - variable for certain types when SQLServer2000.
- schemaRow[providerType] = GetVersionedMetaType(col.MetaType).SqlDbType;
+ schemaRow[providerType] = GetVersionedMetaType(col.metaType).SqlDbType;
}
- if (col.CipherMD != null)
+ if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.BaseTI.Precision)
+ Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.precision)
{
- schemaRow[precision] = col.BaseTI.Precision;
+ schemaRow[precision] = col.baseTI.precision;
}
else
{
- schemaRow[precision] = col.BaseTI.MetaType.Precision;
+ schemaRow[precision] = col.baseTI.metaType.Precision;
}
}
- else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.Precision)
+ else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.precision)
{
- schemaRow[precision] = col.Precision;
+ schemaRow[precision] = col.precision;
}
else
{
- schemaRow[precision] = col.MetaType.Precision;
+ schemaRow[precision] = col.metaType.Precision;
}
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.Is2008DateTimeType)
{
schemaRow[scale] = MetaType.MetaNVarChar.Scale;
}
- else if (col.CipherMD != null)
+ else if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.BaseTI.Scale)
+ Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.scale)
{
- schemaRow[scale] = col.BaseTI.Scale;
+ schemaRow[scale] = col.baseTI.scale;
}
else
{
- schemaRow[scale] = col.BaseTI.MetaType.Scale;
+ schemaRow[scale] = col.baseTI.metaType.Scale;
}
}
- else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale)
+ else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale)
{
- schemaRow[scale] = col.Scale;
+ schemaRow[scale] = col.scale;
}
else
{
- schemaRow[scale] = col.MetaType.Scale;
+ schemaRow[scale] = col.metaType.Scale;
}
schemaRow[allowDBNull] = col.IsNullable;
@@ -681,19 +681,19 @@ internal DataTable BuildSchemaTable()
schemaRow[isIdentity] = col.IsIdentity;
schemaRow[isAutoIncrement] = col.IsIdentity;
- if (col.CipherMD != null)
+ if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null, @"col.baseTI should not be null.");
- Debug.Assert(col.BaseTI.MetaType != null, @"col.baseTI.metaType should not be null.");
- schemaRow[isLong] = col.BaseTI.MetaType.IsLong;
+ Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
+ Debug.Assert(col.baseTI.metaType != null, @"col.baseTI.metaType should not be null.");
+ schemaRow[isLong] = col.baseTI.metaType.IsLong;
}
else
{
- schemaRow[isLong] = col.MetaType.IsLong;
+ schemaRow[isLong] = col.metaType.IsLong;
}
// mark unique for timestamp columns
- if (SqlDbType.Timestamp == col.Type)
+ if (SqlDbType.Timestamp == col.type)
{
schemaRow[isUnique] = true;
schemaRow[isRowVersion] = true;
@@ -707,29 +707,29 @@ internal DataTable BuildSchemaTable()
schemaRow[isReadOnly] = col.IsReadOnly;
schemaRow[isColumnSet] = col.IsColumnSet;
- if (!string.IsNullOrEmpty(col.ServerName))
+ if (!string.IsNullOrEmpty(col.serverName))
{
- schemaRow[baseServerName] = col.ServerName;
+ schemaRow[baseServerName] = col.serverName;
}
- if (!string.IsNullOrEmpty(col.CatalogName))
+ if (!string.IsNullOrEmpty(col.catalogName))
{
- schemaRow[baseCatalogName] = col.CatalogName;
+ schemaRow[baseCatalogName] = col.catalogName;
}
- if (!string.IsNullOrEmpty(col.SchemaName))
+ if (!string.IsNullOrEmpty(col.schemaName))
{
- schemaRow[baseSchemaName] = col.SchemaName;
+ schemaRow[baseSchemaName] = col.schemaName;
}
- if (!string.IsNullOrEmpty(col.TableName))
+ if (!string.IsNullOrEmpty(col.tableName))
{
- schemaRow[baseTableName] = col.TableName;
+ schemaRow[baseTableName] = col.tableName;
}
- if (!string.IsNullOrEmpty(col.BaseColumn))
+ if (!string.IsNullOrEmpty(col.baseColumn))
{
- schemaRow[baseColumnName] = col.BaseColumn;
+ schemaRow[baseColumnName] = col.baseColumn;
}
- else if (!string.IsNullOrEmpty(col.Column))
+ else if (!string.IsNullOrEmpty(col.column))
{
- schemaRow[baseColumnName] = col.Column;
+ schemaRow[baseColumnName] = col.column;
}
schemaTable.Rows.Add(schemaRow);
@@ -1208,20 +1208,20 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
- dataTypeName = metaData.Udt?.DatabaseName + "." + metaData.Udt?.SchemaName + "." + metaData.Udt?.TypeName;
+ dataTypeName = metaData.udt?.DatabaseName + "." + metaData.udt?.SchemaName + "." + metaData.udt?.TypeName;
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null && metaData.BaseTI.MetaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- dataTypeName = metaData.BaseTI.MetaType.TypeName;
+ Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ dataTypeName = metaData.baseTI.metaType.TypeName;
}
else
{
- dataTypeName = metaData.MetaType.TypeName;
+ dataTypeName = metaData.metaType.TypeName;
}
}
}
@@ -1229,7 +1229,7 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2000
- dataTypeName = GetVersionedMetaType(metaData.MetaType).TypeName;
+ dataTypeName = GetVersionedMetaType(metaData.metaType).TypeName;
}
return dataTypeName;
@@ -1298,28 +1298,28 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
Connection.CheckGetExtendedUDTInfo(metaData, false);
- fieldType = metaData.Udt?.Type;
+ fieldType = metaData.udt?.Type;
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null && metaData.BaseTI.MetaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- fieldType = metaData.BaseTI.MetaType.ClassType;
+ Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ fieldType = metaData.baseTI.metaType.ClassType;
}
else
{
- fieldType = metaData.MetaType.ClassType; // Com+ type.
+ fieldType = metaData.metaType.ClassType; // Com+ type.
}
}
}
else
{
// TypeSystem.SQLServer2000
- fieldType = GetVersionedMetaType(metaData.MetaType).ClassType; // Com+ type.
+ fieldType = GetVersionedMetaType(metaData.metaType).ClassType; // Com+ type.
}
return fieldType;
@@ -1330,13 +1330,13 @@ virtual internal int GetLocaleId(int i)
_SqlMetaData sqlMetaData = MetaData[i];
int lcid;
- if (sqlMetaData.CipherMD != null)
+ if (sqlMetaData.cipherMD != null)
{
// If this column is encrypted, get the collation from baseTI
//
- if (sqlMetaData.BaseTI.Collation != null)
+ if (sqlMetaData.baseTI.collation != null)
{
- lcid = sqlMetaData.BaseTI.Collation.LCID;
+ lcid = sqlMetaData.baseTI.collation.LCID;
}
else
{
@@ -1345,9 +1345,9 @@ virtual internal int GetLocaleId(int i)
}
else
{
- if (sqlMetaData.Collation != null)
+ if (sqlMetaData.collation != null)
{
- lcid = sqlMetaData.Collation.LCID;
+ lcid = sqlMetaData.collation.LCID;
}
else
{
@@ -1362,7 +1362,7 @@ virtual internal int GetLocaleId(int i)
override public string GetName(int i)
{
CheckMetaDataIsReady(columnIndex: i);
- return _metaData[i].Column;
+ return _metaData[i].column;
}
///
@@ -1411,30 +1411,30 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
else if (_typeSystem != SqlConnectionString.TypeSystem.SQLServer2000)
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
Connection.CheckGetExtendedUDTInfo(metaData, false);
- providerSpecificFieldType = metaData.Udt?.Type;
+ providerSpecificFieldType = metaData.udt?.Type;
}
else
{
// For all other types, including Xml - use data in MetaType.
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null && metaData.BaseTI.MetaType != null,
+ Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null,
"metaData.baseTI and metaData.baseTI.metaType should not be null.");
- providerSpecificFieldType = metaData.BaseTI.MetaType.SqlType; // SqlType type.
+ providerSpecificFieldType = metaData.baseTI.metaType.SqlType; // SqlType type.
}
else
{
- providerSpecificFieldType = metaData.MetaType.SqlType; // SqlType type.
+ providerSpecificFieldType = metaData.metaType.SqlType; // SqlType type.
}
}
}
else
{
// TypeSystem.SQLServer2000
- providerSpecificFieldType = GetVersionedMetaType(metaData.MetaType).SqlType; // SqlType type.
+ providerSpecificFieldType = GetVersionedMetaType(metaData.metaType).SqlType; // SqlType type.
}
return providerSpecificFieldType;
@@ -1482,15 +1482,15 @@ public override DataTable GetSchemaTable()
try
{
statistics = SqlStatistics.StartTimer(Statistics);
- if (_metaData == null || _metaData.SchemaTable == null)
+ if (_metaData == null || _metaData.schemaTable == null)
{
if (this.MetaData != null)
{
- _metaData.SchemaTable = BuildSchemaTable();
- Debug.Assert(_metaData.SchemaTable != null, "No schema information yet!");
+ _metaData.schemaTable = BuildSchemaTable();
+ Debug.Assert(_metaData.schemaTable != null, "No schema information yet!");
}
}
- return _metaData?.SchemaTable;
+ return _metaData?.schemaTable;
}
finally
{
@@ -1513,12 +1513,12 @@ virtual public XmlReader GetXmlReader(int i)
// If this ever changes, the following code should be changed to be like GetStream/GetTextReader
CheckDataIsReady(columnIndex: i);
- MetaType mt = _metaData[i].MetaType;
+ MetaType mt = _metaData[i].metaType;
// XmlReader only allowed on XML types
if (mt.SqlDbType != SqlDbType.Xml)
{
- throw SQL.XmlReaderNotSupportOnColumnType(_metaData[i].Column);
+ throw SQL.XmlReaderNotSupportOnColumnType(_metaData[i].column);
}
if (IsCommandBehavior(CommandBehavior.SequentialAccess))
@@ -1552,17 +1552,17 @@ override public Stream GetStream(int i)
CheckDataIsReady(columnIndex: i);
// Streaming is not supported on encrypted columns.
- if (_metaData[i] != null && _metaData[i].CipherMD != null)
+ if (_metaData[i] != null && _metaData[i].cipherMD != null)
{
- throw SQL.StreamNotSupportOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.StreamNotSupportOnEncryptedColumn(_metaData[i].column);
}
// Stream is only for Binary, Image, VarBinary, Udt and Xml types
// NOTE: IsBinType also includes Timestamp for some reason...
- MetaType mt = _metaData[i].MetaType;
+ MetaType mt = _metaData[i].metaType;
if (((!mt.IsBinType) || (mt.SqlDbType == SqlDbType.Timestamp)) && (mt.SqlDbType != SqlDbType.Variant))
{
- throw SQL.StreamNotSupportOnColumnType(_metaData[i].Column);
+ throw SQL.StreamNotSupportOnColumnType(_metaData[i].column);
}
// For non-variant types with sequential access, we support proper streaming
@@ -1610,10 +1610,10 @@ override public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIn
CheckDataIsReady(columnIndex: i, allowPartiallyReadColumn: true);
// don't allow get bytes on non-long or non-binary columns
- MetaType mt = _metaData[i].MetaType;
+ MetaType mt = _metaData[i].metaType;
if (!(mt.IsLong || mt.IsBinType) || (SqlDbType.Xml == mt.SqlDbType))
{
- throw SQL.NonBlobColumn(_metaData[i].Column);
+ throw SQL.NonBlobColumn(_metaData[i].column);
}
try
@@ -1660,9 +1660,9 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
{
Debug.Assert(!HasActiveStreamOrTextReaderOnColumn(i), "Column has an active Stream or TextReader");
- if (_metaData[i] != null && _metaData[i].CipherMD != null)
+ if (_metaData[i] != null && _metaData[i].cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
if (_sharedState._nextColumnHeaderToRead <= i)
@@ -1681,7 +1681,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
}
// If there are an unknown (-1) number of bytes left for a PLP, read its size
- if ((-1 == _sharedState._columnDataBytesRemaining) && (_metaData[i].MetaType.IsPlp))
+ if ((-1 == _sharedState._columnDataBytesRemaining) && (_metaData[i].metaType.IsPlp))
{
ulong left;
result = _parser.TryPlpBytesLeft(_stateObj, out left);
@@ -1700,7 +1700,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
// if no buffer is passed in, return the number total of bytes, or -1
if (buffer == null)
{
- if (_metaData[i].MetaType.IsPlp)
+ if (_metaData[i].metaType.IsPlp)
{
remaining = (long)_parser.PlpBytesTotalLength(_stateObj);
return TdsOperationStatus.Done;
@@ -1721,7 +1721,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
long cb = dataIndex - _columnDataBytesRead;
// if dataIndex is outside of the data range, return 0
- if ((cb > _sharedState._columnDataBytesRemaining) && !_metaData[i].MetaType.IsPlp)
+ if ((cb > _sharedState._columnDataBytesRemaining) && !_metaData[i].metaType.IsPlp)
{
return TdsOperationStatus.Done;
}
@@ -1740,7 +1740,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
// Skip if needed
if (cb > 0)
{
- if (_metaData[i].MetaType.IsPlp)
+ if (_metaData[i].metaType.IsPlp)
{
ulong skipped;
result = _parser.TrySkipPlpValue((ulong)cb, _stateObj, out skipped);
@@ -1786,17 +1786,17 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
// the use of GetBytes on string data columns, but
// GetSqlBinary isn't supposed to. What we end up
// doing isn't exactly pretty, but it does work.
- if (_metaData[i].MetaType.IsBinType)
+ if (_metaData[i].metaType.IsBinType)
{
data = GetSqlBinary(i).Value;
}
else
{
- Debug.Assert(_metaData[i].MetaType.IsLong, "non long type?");
- Debug.Assert(_metaData[i].MetaType.IsCharType, "non-char type?");
+ Debug.Assert(_metaData[i].metaType.IsLong, "non long type?");
+ Debug.Assert(_metaData[i].metaType.IsCharType, "non-char type?");
SqlString temp = GetSqlString(i);
- if (_metaData[i].MetaType.IsNCharType)
+ if (_metaData[i].metaType.IsNCharType)
{
data = temp.GetUnicodeBytes();
}
@@ -1918,7 +1918,7 @@ internal TdsOperationStatus TryGetBytesInternalSequential(int i, byte[] buffer,
else
{
// if plp columns, do partial reads. Don't read the entire value in one shot.
- if (_metaData[i].MetaType.IsPlp)
+ if (_metaData[i].metaType.IsPlp)
{
// Read in data
result = _stateObj.TryReadPlpBytes(ref buffer, index, length, out bytesRead);
@@ -1959,29 +1959,29 @@ override public TextReader GetTextReader(int i)
// Xml type is not supported
MetaType mt = null;
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- Debug.Assert(_metaData[i].BaseTI != null, "_metaData[i].baseTI should not be null.");
- mt = _metaData[i].BaseTI.MetaType;
+ Debug.Assert(_metaData[i].baseTI != null, "_metaData[i].baseTI should not be null.");
+ mt = _metaData[i].baseTI.metaType;
}
else
{
- mt = _metaData[i].MetaType;
+ mt = _metaData[i].metaType;
}
Debug.Assert(mt != null, @"mt should not be null.");
if (((!mt.IsCharType) && (mt.SqlDbType != SqlDbType.Variant)) || (mt.SqlDbType == SqlDbType.Xml))
{
- throw SQL.TextReaderNotSupportOnColumnType(_metaData[i].Column);
+ throw SQL.TextReaderNotSupportOnColumnType(_metaData[i].column);
}
// For non-variant types with sequential access, we support proper streaming
if ((mt.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)))
{
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
System.Text.Encoding encoding;
@@ -1992,7 +1992,7 @@ override public TextReader GetTextReader(int i)
}
else
{
- encoding = _metaData[i].Encoding;
+ encoding = _metaData[i].encoding;
}
_currentTextReader = new SqlSequentialTextReader(this, i, encoding);
@@ -2040,27 +2040,27 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
}
MetaType mt = null;
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- Debug.Assert(_metaData[i].BaseTI != null, @"_metaData[i].baseTI should not be null.");
- mt = _metaData[i].BaseTI.MetaType;
+ Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
+ mt = _metaData[i].baseTI.metaType;
}
else
{
- mt = _metaData[i].MetaType;
+ mt = _metaData[i].metaType;
}
Debug.Assert(mt != null, "mt should not be null.");
SqlDbType sqlDbType;
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- Debug.Assert(_metaData[i].BaseTI != null, @"_metaData[i].baseTI should not be null.");
- sqlDbType = _metaData[i].BaseTI.Type;
+ Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
+ sqlDbType = _metaData[i].baseTI.type;
}
else
{
- sqlDbType = _metaData[i].Type;
+ sqlDbType = _metaData[i].type;
}
try
@@ -2075,9 +2075,9 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
throw ADP.InvalidDataLength(length);
}
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
// if bad buffer index, throw
@@ -2209,13 +2209,13 @@ private long GetCharsFromPlpData(int i, long dataIndex, char[] buffer, int buffe
AssertReaderState(requireData: true, permitAsync: false, columnIndex: i, enforceSequentialAccess: true);
Debug.Assert(!HasActiveStreamOrTextReaderOnColumn(i), "Column has active Stream or TextReader");
// don't allow get bytes on non-long or non-binary columns
- Debug.Assert(_metaData[i].MetaType.IsPlp, "GetCharsFromPlpData called on a non-plp column!");
+ Debug.Assert(_metaData[i].metaType.IsPlp, "GetCharsFromPlpData called on a non-plp column!");
// Must be sequential reading
Debug.Assert(IsCommandBehavior(CommandBehavior.SequentialAccess), "GetCharsFromPlpData called for non-Sequential access");
- if (!_metaData[i].MetaType.IsCharType)
+ if (!_metaData[i].metaType.IsCharType)
{
- throw SQL.NonCharColumn(_metaData[i].Column);
+ throw SQL.NonCharColumn(_metaData[i].column);
}
if (_sharedState._nextColumnHeaderToRead <= i)
@@ -2241,7 +2241,7 @@ private long GetCharsFromPlpData(int i, long dataIndex, char[] buffer, int buffe
if (dataIndex == 0)
_stateObj._plpdecoder = null;
- bool isUnicode = _metaData[i].MetaType.IsNCharType;
+ bool isUnicode = _metaData[i].metaType.IsNCharType;
// If there are an unknown (-1) number of bytes left for a PLP, read its size
if (-1 == _sharedState._columnDataBytesRemaining)
@@ -2579,7 +2579,7 @@ private object GetSqlValueInternal(int i)
// Always make sure to take reference copies of anything set to null in TryCloseInternal()
private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaData)
{
- Debug.Assert(!data.IsEmpty || data.IsNull || metaData.Type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
+ Debug.Assert(!data.IsEmpty || data.IsNull || metaData.type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
// Convert 2008 types to string
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.Is2008DateTimeType)
@@ -2594,7 +2594,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
SqlConnection connection = _connection;
if (connection != null)
@@ -2616,7 +2616,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// TypeSystem.SQLServer2000
- if (metaData.Type == SqlDbType.Xml)
+ if (metaData.type == SqlDbType.Xml)
{
return data.SqlString;
}
@@ -2769,7 +2769,7 @@ private object GetValueInternal(int i)
// Always make sure to take reference copies of anything set to null in TryCloseInternal()
private object GetValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaData)
{
- Debug.Assert(!data.IsEmpty || data.IsNull || metaData.Type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
+ Debug.Assert(!data.IsEmpty || data.IsNull || metaData.type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.Is2008DateTimeType)
{
@@ -2790,7 +2790,7 @@ private object GetValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaDa
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type != SqlDbType.Udt)
+ if (metaData.type != SqlDbType.Udt)
{
return data.Value;
}
@@ -2896,16 +2896,16 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
else if (typeof(T) == typeof(XmlReader))
{
// XmlReader only allowed on XML types
- if (metaData.MetaType.SqlDbType != SqlDbType.Xml)
+ if (metaData.metaType.SqlDbType != SqlDbType.Xml)
{
- throw SQL.XmlReaderNotSupportOnColumnType(metaData.Column);
+ throw SQL.XmlReaderNotSupportOnColumnType(metaData.column);
}
if (IsCommandBehavior(CommandBehavior.SequentialAccess))
{
// Wrap the sequential stream in an XmlReader
- _currentStream = new SqlSequentialStream(this, metaData.Ordinal);
- _lastColumnWithDataChunkRead = metaData.Ordinal;
+ _currentStream = new SqlSequentialStream(this, metaData.ordinal);
+ _lastColumnWithDataChunkRead = metaData.ordinal;
return (T)(object)SqlTypeWorkarounds.SqlXmlCreateSqlXmlReader(_currentStream, closeInput: true, async: isAsync);
}
else
@@ -2925,11 +2925,11 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
else if (typeof(T) == typeof(TextReader))
{
// Xml type is not supported
- MetaType metaType = metaData.MetaType;
- if (metaData.CipherMD != null)
+ MetaType metaType = metaData.metaType;
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null, "_metaData[i].baseTI should not be null.");
- metaType = metaData.BaseTI.MetaType;
+ Debug.Assert(metaData.baseTI != null, "_metaData[i].baseTI should not be null.");
+ metaType = metaData.baseTI.metaType;
}
if (
@@ -2937,25 +2937,25 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
(metaType.SqlDbType == SqlDbType.Xml)
)
{
- throw SQL.TextReaderNotSupportOnColumnType(metaData.Column);
+ throw SQL.TextReaderNotSupportOnColumnType(metaData.column);
}
// For non-variant types with sequential access, we support proper streaming
if ((metaType.SqlDbType != SqlDbType.Variant) && IsCommandBehavior(CommandBehavior.SequentialAccess))
{
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(metaData.Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(metaData.column);
}
System.Text.Encoding encoding = SqlUnicodeEncoding.SqlUnicodeEncodingInstance;
if (!metaType.IsNCharType)
{
- encoding = metaData.Encoding;
+ encoding = metaData.encoding;
}
- _currentTextReader = new SqlSequentialTextReader(this, metaData.Ordinal, encoding);
- _lastColumnWithDataChunkRead = metaData.Ordinal;
+ _currentTextReader = new SqlSequentialTextReader(this, metaData.ordinal, encoding);
+ _lastColumnWithDataChunkRead = metaData.ordinal;
return (T)(object)_currentTextReader;
}
else
@@ -2967,25 +2967,25 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
}
else if (typeof(T) == typeof(Stream))
{
- if (metaData != null && metaData.CipherMD != null)
+ if (metaData != null && metaData.cipherMD != null)
{
- throw SQL.StreamNotSupportOnEncryptedColumn(metaData.Column);
+ throw SQL.StreamNotSupportOnEncryptedColumn(metaData.column);
}
// Stream is only for Binary, Image, VarBinary, Udt, Xml and Timestamp(RowVersion) types
- MetaType metaType = metaData.MetaType;
+ MetaType metaType = metaData.metaType;
if (
(!metaType.IsBinType || metaType.SqlDbType == SqlDbType.Timestamp) &&
metaType.SqlDbType != SqlDbType.Variant
)
{
- throw SQL.StreamNotSupportOnColumnType(metaData.Column);
+ throw SQL.StreamNotSupportOnColumnType(metaData.column);
}
if ((metaType.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)))
{
- _currentStream = new SqlSequentialStream(this, metaData.Ordinal);
- _lastColumnWithDataChunkRead = metaData.Ordinal;
+ _currentStream = new SqlSequentialStream(this, metaData.ordinal);
+ _lastColumnWithDataChunkRead = metaData.ordinal;
return (T)(object)_currentStream;
}
else
@@ -3191,7 +3191,7 @@ private TdsOperationStatus TryHasMoreResults(out bool moreResults)
if (_altRowStatus == ALTROWSTATUS.Null)
{
// cache the regular metadata
- _altMetaDataSetCollection.MetaDataSet = _metaData;
+ _altMetaDataSetCollection.metaDataSet = _metaData;
_metaData = null;
}
else
@@ -3448,7 +3448,7 @@ private TdsOperationStatus TryNextResult(out bool more)
break;
case ALTROWSTATUS.Done:
// restore the row-metaData
- _metaData = _altMetaDataSetCollection.MetaDataSet;
+ _metaData = _altMetaDataSetCollection.metaDataSet;
Debug.Assert(_altRowStatus == ALTROWSTATUS.Done, "invalid AltRowStatus");
_altRowStatus = ALTROWSTATUS.Null;
break;
@@ -3785,7 +3785,7 @@ private TdsOperationStatus TryReadColumnData()
TdsOperationStatus result = _parser.TryReadSqlValue(_data[_sharedState._nextColumnDataToRead], columnMetaData, (int)_sharedState._columnDataBytesRemaining, _stateObj,
_command != null ? _command.ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting.UseConnectionSetting,
- columnMetaData.Column);
+ columnMetaData.column);
if (result != TdsOperationStatus.Done)
{
// will read UDTs as VARBINARY.
@@ -3835,7 +3835,7 @@ internal TdsOperationStatus TryReadColumnInternal(int i, bool readHeaderOnly = f
Debug.Assert(i == _sharedState._nextColumnDataToRead || // Either we haven't read the column yet
((i + 1 < _sharedState._nextColumnDataToRead) && (IsCommandBehavior(CommandBehavior.SequentialAccess))) || // Or we're in sequential mode and we've read way past the column (i.e. it was not the last column we read)
(!_data[i].IsEmpty || _data[i].IsNull) || // Or we should have data stored for the column (unless the column was null)
- (_metaData[i].Type == SqlDbType.Timestamp), // Or SqlClient: IsDBNull always returns false for timestamp datatype
+ (_metaData[i].type == SqlDbType.Timestamp), // Or SqlClient: IsDBNull always returns false for timestamp datatype
"Gone past column, be we have no data stored for it");
return TdsOperationStatus.Done;
@@ -3914,7 +3914,7 @@ internal TdsOperationStatus TryReadColumnInternal(int i, bool readHeaderOnly = f
if (isNull)
{
- if (columnMetaData.Type != SqlDbType.Timestamp)
+ if (columnMetaData.type != SqlDbType.Timestamp)
{
TdsParser.GetNullSqlValue(_data[_sharedState._nextColumnDataToRead],
columnMetaData,
@@ -3930,7 +3930,7 @@ internal TdsOperationStatus TryReadColumnInternal(int i, bool readHeaderOnly = f
// state so there are no remaining bytes and advance the next column to read
result = _parser.TryReadSqlValue(_data[_sharedState._nextColumnDataToRead], columnMetaData, (int)dataLength, _stateObj,
_command != null ? _command.ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting.UseConnectionSetting,
- columnMetaData.Column);
+ columnMetaData.column);
if (result != TdsOperationStatus.Done)
{
// will read UDTs as VARBINARY.
@@ -3966,7 +3966,7 @@ internal TdsOperationStatus TryReadColumnInternal(int i, bool readHeaderOnly = f
// Trigger new behavior for RowVersion to send DBNull.Value by allowing entry for Timestamp or discard entry for Timestamp for legacy support.
// if LegacyRowVersionNullBehavior is enabled, Timestamp type must enter "else" block.
- if (isNull && (!LocalAppContextSwitches.LegacyRowVersionNullBehavior || columnMetaData.Type != SqlDbType.Timestamp))
+ if (isNull && (!LocalAppContextSwitches.LegacyRowVersionNullBehavior || columnMetaData.type != SqlDbType.Timestamp))
{
TdsParser.GetNullSqlValue(_data[_sharedState._nextColumnDataToRead],
columnMetaData,
@@ -3987,7 +3987,7 @@ internal TdsOperationStatus TryReadColumnInternal(int i, bool readHeaderOnly = f
// can read it out of order
result = _parser.TryReadSqlValue(_data[_sharedState._nextColumnDataToRead], columnMetaData, (int)dataLength, _stateObj,
_command != null ? _command.ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting.UseConnectionSetting,
- columnMetaData.Column, _command);
+ columnMetaData.column, _command);
if (result != TdsOperationStatus.Done)
{
// will read UDTs as VARBINARY.
@@ -4023,7 +4023,7 @@ private bool WillHaveEnoughData(int targetColumn, bool headerOnly = false)
{
AssertReaderState(requireData: true, permitAsync: true, columnIndex: targetColumn);
- if ((_lastColumnWithDataChunkRead == _sharedState._nextColumnDataToRead) && (_metaData[_lastColumnWithDataChunkRead].MetaType.IsPlp))
+ if ((_lastColumnWithDataChunkRead == _sharedState._nextColumnDataToRead) && (_metaData[_lastColumnWithDataChunkRead].metaType.IsPlp))
{
// In the middle of reading a Plp - no idea how much is left
return false;
@@ -4059,22 +4059,22 @@ private bool WillHaveEnoughData(int targetColumn, bool headerOnly = false)
if (!_stateObj.IsNullCompressionBitSet(currentColumn))
{
// NOTE: This is mostly duplicated from TryProcessColumnHeaderNoNBC and TryGetTokenLength
- var metaType = _metaData[currentColumn].MetaType;
+ var metaType = _metaData[currentColumn].metaType;
if ((metaType.IsLong) || (metaType.IsPlp) || (metaType.SqlDbType == SqlDbType.Udt) || (metaType.SqlDbType == SqlDbType.Structured))
{
// Plp, Udt and TVP types have an unknowable size - so return that the estimate failed
return false;
}
int maxHeaderSize;
- byte typeAndMask = (byte)(_metaData[currentColumn].TdsType & TdsEnums.SQLLenMask);
+ byte typeAndMask = (byte)(_metaData[currentColumn].tdsType & TdsEnums.SQLLenMask);
if ((typeAndMask == TdsEnums.SQLVarLen) || (typeAndMask == TdsEnums.SQLVarCnt))
{
- if (0 != (_metaData[currentColumn].TdsType & 0x80))
+ if (0 != (_metaData[currentColumn].tdsType & 0x80))
{
// UInt16 represents size
maxHeaderSize = 2;
}
- else if (0 == (_metaData[currentColumn].TdsType & 0x0c))
+ else if (0 == (_metaData[currentColumn].tdsType & 0x0c))
{
// UInt32 represents size
maxHeaderSize = 4;
@@ -4093,7 +4093,7 @@ private bool WillHaveEnoughData(int targetColumn, bool headerOnly = false)
bytesRemaining = checked(bytesRemaining - maxHeaderSize);
if ((currentColumn < targetColumn) || (!headerOnly))
{
- bytesRemaining = checked(bytesRemaining - _metaData[currentColumn].Length);
+ bytesRemaining = checked(bytesRemaining - _metaData[currentColumn].length);
}
}
@@ -4113,7 +4113,7 @@ private TdsOperationStatus TryResetBlobState()
// If we haven't already entirely read the column
if (_sharedState._nextColumnDataToRead < _sharedState._nextColumnHeaderToRead)
{
- if ((_sharedState._nextColumnHeaderToRead > 0) && (_metaData[_sharedState._nextColumnHeaderToRead - 1].MetaType.IsPlp))
+ if ((_sharedState._nextColumnHeaderToRead > 0) && (_metaData[_sharedState._nextColumnHeaderToRead - 1].metaType.IsPlp))
{
if (_stateObj._longlen != 0)
{
@@ -5830,19 +5830,19 @@ public ReadOnlyCollection GetColumnSchema()
try
{
statistics = SqlStatistics.StartTimer(Statistics);
- if (_metaData == null || _metaData.DbColumnSchema == null)
+ if (_metaData == null || _metaData.dbColumnSchema == null)
{
if (this.MetaData != null)
{
- _metaData.DbColumnSchema = BuildColumnSchema();
- Debug.Assert(_metaData.DbColumnSchema != null, "No schema information yet!");
+ _metaData.dbColumnSchema = BuildColumnSchema();
+ Debug.Assert(_metaData.dbColumnSchema != null, "No schema information yet!");
// filter table?
}
}
if (_metaData != null)
{
- return _metaData.DbColumnSchema;
+ return _metaData.dbColumnSchema;
}
return s_emptySchema;
}
@@ -5865,13 +5865,13 @@ private ReadOnlyCollection BuildColumnSchema()
{
dbColumn.SqlNumericScale = MetaType.MetaNVarChar.Scale;
}
- else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale)
+ else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale)
{
- dbColumn.SqlNumericScale = col.Scale;
+ dbColumn.SqlNumericScale = col.scale;
}
else
{
- dbColumn.SqlNumericScale = col.MetaType.Scale;
+ dbColumn.SqlNumericScale = col.metaType.Scale;
}
if (_browseModeInfoConsumed)
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDbColumn.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDbColumn.cs
index 63cc67da5c..bebe02b575 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDbColumn.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDbColumn.cs
@@ -21,19 +21,19 @@ internal SqlDbColumn(_SqlMetaData md)
private void Populate()
{
AllowDBNull = _metadata.IsNullable;
- BaseCatalogName = _metadata.CatalogName;
- BaseColumnName = _metadata.BaseColumn;
- BaseSchemaName = _metadata.SchemaName;
- BaseServerName = _metadata.ServerName;
- BaseTableName = _metadata.TableName;
- ColumnName = _metadata.Column;
- ColumnOrdinal = _metadata.Ordinal;
- ColumnSize = (_metadata.MetaType.IsSizeInCharacters && (_metadata.Length != 0x7fffffff)) ? (_metadata.Length / 2) : _metadata.Length;
+ BaseCatalogName = _metadata.catalogName;
+ BaseColumnName = _metadata.baseColumn;
+ BaseSchemaName = _metadata.schemaName;
+ BaseServerName = _metadata.serverName;
+ BaseTableName = _metadata.tableName;
+ ColumnName = _metadata.column;
+ ColumnOrdinal = _metadata.ordinal;
+ ColumnSize = (_metadata.metaType.IsSizeInCharacters && (_metadata.length != 0x7fffffff)) ? (_metadata.length / 2) : _metadata.length;
IsAutoIncrement = _metadata.IsIdentity;
IsIdentity = _metadata.IsIdentity;
- IsLong = _metadata.MetaType.IsLong;
+ IsLong = _metadata.metaType.IsLong;
- if (SqlDbType.Timestamp == _metadata.Type)
+ if (SqlDbType.Timestamp == _metadata.type)
{
IsUnique = true;
}
@@ -42,18 +42,18 @@ private void Populate()
IsUnique = false;
}
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != _metadata.Precision)
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != _metadata.precision)
{
- NumericPrecision = _metadata.Precision;
+ NumericPrecision = _metadata.precision;
}
else
{
- NumericPrecision = _metadata.MetaType.Precision;
+ NumericPrecision = _metadata.metaType.Precision;
}
IsReadOnly = _metadata.IsReadOnly;
- UdtAssemblyQualifiedName = _metadata.Udt?.AssemblyQualifiedName;
+ UdtAssemblyQualifiedName = _metadata.udt?.AssemblyQualifiedName;
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
index 61c414156d..f4df2b11f9 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
@@ -698,8 +698,8 @@ public override string ServerVersion
{
get
{
- return (string.Format("{0:00}.{1:00}.{2:0000}", _loginAck.MajorVersion,
- (short)_loginAck.MinorVersion, _loginAck.BuildNum));
+ return (string.Format("{0:00}.{1:00}.{2:0000}", _loginAck.majorVersion,
+ (short)_loginAck.minorVersion, _loginAck.buildNum));
}
}
@@ -722,7 +722,7 @@ protected override bool UnbindOnTransactionCompletion
///
/// Validates if federated authentication is used, Access Token used by this connection is active for the value of 'accessTokenExpirationBufferTime'.
///
- internal override bool IsAccessTokenExpired => _federatedAuthenticationInfoRequested && DateTime.FromFileTimeUtc(_fedAuthToken.ExpirationFileTime) < DateTime.UtcNow.AddSeconds(accessTokenExpirationBufferTime);
+ internal override bool IsAccessTokenExpired => _federatedAuthenticationInfoRequested && DateTime.FromFileTimeUtc(_fedAuthToken.expirationFileTime) < DateTime.UtcNow.AddSeconds(accessTokenExpirationBufferTime);
////////////////////////////////////////////////////////////////////////////////////////
// GENERAL METHODS
@@ -1278,37 +1278,37 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
}
}
- login.Authentication = ConnectionOptions.Authentication;
- login.Timeout = timeoutInSeconds;
- login.UserInstance = ConnectionOptions.UserInstance;
- login.HostName = ConnectionOptions.ObtainWorkstationId();
- login.UserName = ConnectionOptions.UserID;
- login.Password = ConnectionOptions.Password;
- login.ApplicationName = ConnectionOptions.ApplicationName;
+ login.authentication = ConnectionOptions.Authentication;
+ login.timeout = timeoutInSeconds;
+ login.userInstance = ConnectionOptions.UserInstance;
+ login.hostName = ConnectionOptions.ObtainWorkstationId();
+ login.userName = ConnectionOptions.UserID;
+ login.password = ConnectionOptions.Password;
+ login.applicationName = ConnectionOptions.ApplicationName;
- login.Language = _currentLanguage;
- if (!login.UserInstance)
+ login.language = _currentLanguage;
+ if (!login.userInstance)
{
// Do not send attachdbfilename or database to SSE primary instance
- login.Database = CurrentDatabase;
- login.AttachDbFilename = ConnectionOptions.AttachDBFilename;
+ login.database = CurrentDatabase;
+ login.attachDBFilename = ConnectionOptions.AttachDBFilename;
}
// VSTS#795621 - Ensure ServerName is Sent During TdsLogin To Enable Sql Azure Connectivity.
// Using server.UserServerName (versus ConnectionOptions.DataSource) since TdsLogin requires
// serverName to always be non-null.
- login.ServerName = server.UserServerName;
+ login.serverName = server.UserServerName;
- login.UseReplication = ConnectionOptions.Replication;
- login.UseSspi = ConnectionOptions.IntegratedSecurity // Treat AD Integrated like Windows integrated when against a non-FedAuth endpoint
+ login.useReplication = ConnectionOptions.Replication;
+ login.useSSPI = ConnectionOptions.IntegratedSecurity // Treat AD Integrated like Windows integrated when against a non-FedAuth endpoint
|| (ConnectionOptions.Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated && !_fedAuthRequired);
- login.PacketSize = _currentPacketSize;
- login.NewPassword = newPassword;
- login.ReadOnlyIntent = ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly;
- login.Credential = _credential;
+ login.packetSize = _currentPacketSize;
+ login.newPassword = newPassword;
+ login.readOnlyIntent = ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly;
+ login.credential = _credential;
if (newSecurePassword != null)
{
- login.NewSecurePassword = newSecurePassword;
+ login.newSecurePassword = newSecurePassword;
}
TdsEnums.FeatureExtension requestedFeatures = TdsEnums.FeatureExtension.None;
@@ -1338,9 +1338,9 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
_fedAuthFeatureExtensionData =
new FederatedAuthenticationFeatureExtensionData
{
- LibraryType = TdsEnums.FedAuthLibrary.MSAL,
- Authentication = ConnectionOptions.Authentication,
- FedAuthRequiredPreLoginResponse = _fedAuthRequired
+ libraryType = TdsEnums.FedAuthLibrary.MSAL,
+ authentication = ConnectionOptions.Authentication,
+ fedAuthRequiredPreLoginResponse = _fedAuthRequired
};
}
@@ -1349,9 +1349,9 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
requestedFeatures |= TdsEnums.FeatureExtension.FedAuth;
_fedAuthFeatureExtensionData = new FederatedAuthenticationFeatureExtensionData
{
- LibraryType = TdsEnums.FedAuthLibrary.SecurityToken,
- FedAuthRequiredPreLoginResponse = _fedAuthRequired,
- AccessToken = _accessTokenInBytes
+ libraryType = TdsEnums.FedAuthLibrary.SecurityToken,
+ fedAuthRequiredPreLoginResponse = _fedAuthRequired,
+ accessToken = _accessTokenInBytes
};
// No need any further info from the server for token based authentication. So set _federatedAuthenticationRequested to true
_federatedAuthenticationRequested = true;
@@ -2134,14 +2134,14 @@ internal void OnLoginAck(SqlLoginAck rec)
_loginAck = rec;
if (_recoverySessionData != null)
{
- if (_recoverySessionData._tdsVersion != rec.TdsVersion)
+ if (_recoverySessionData._tdsVersion != rec.tdsVersion)
{
throw SQL.CR_TDSVersionNotPreserved(this);
}
}
if (_currentSessionData != null)
{
- _currentSessionData._tdsVersion = rec.TdsVersion;
+ _currentSessionData._tdsVersion = rec.tdsVersion;
}
}
@@ -2179,7 +2179,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo)
Debug.Assert(_dbConnectionPool.AuthenticationContexts != null);
// Construct the dbAuthenticationContextKey with information from FedAuthInfo and store for later use, when inserting in to the token cache.
- _dbConnectionPoolAuthenticationContextKey = new DbConnectionPoolAuthenticationContextKey(fedAuthInfo.StsUrl, fedAuthInfo.Spn);
+ _dbConnectionPoolAuthenticationContextKey = new DbConnectionPoolAuthenticationContextKey(fedAuthInfo.stsurl, fedAuthInfo.spn);
// Try to retrieve the authentication context from the pool, if one does exist for this key.
if (_dbConnectionPool.AuthenticationContexts.TryGetValue(_dbConnectionPoolAuthenticationContextKey, out dbConnectionPoolAuthenticationContext))
@@ -2272,11 +2272,11 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo)
// If the code flow is here, then we are re-using the context from the cache for this connection attempt and not
// generating a new access token on this thread.
- _fedAuthToken.AccessToken = dbConnectionPoolAuthenticationContext.AccessToken;
- _fedAuthToken.ExpirationFileTime = dbConnectionPoolAuthenticationContext.ExpirationTime.ToFileTime();
+ _fedAuthToken.accessToken = dbConnectionPoolAuthenticationContext.AccessToken;
+ _fedAuthToken.expirationFileTime = dbConnectionPoolAuthenticationContext.ExpirationTime.ToFileTime();
}
- Debug.Assert(_fedAuthToken != null && _fedAuthToken.AccessToken != null, "fedAuthToken and fedAuthToken.accessToken cannot be null.");
+ Debug.Assert(_fedAuthToken != null && _fedAuthToken.accessToken != null, "fedAuthToken and fedAuthToken.accessToken cannot be null.");
_parser.SendFedAuthToken(_fedAuthToken);
}
@@ -2374,8 +2374,8 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
{
var authParamsBuilder = new SqlAuthenticationParameters.Builder(
authenticationMethod: ConnectionOptions.Authentication,
- resource: fedAuthInfo.Spn,
- authority: fedAuthInfo.StsUrl,
+ resource: fedAuthInfo.spn,
+ authority: fedAuthInfo.stsurl,
serverName: ConnectionOptions.DataSource,
databaseName: ConnectionOptions.InitialCatalog)
.WithConnectionId(_clientConnectionId)
@@ -2482,7 +2482,7 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
break;
}
- Debug.Assert(_fedAuthToken.AccessToken != null, "AccessToken should not be null.");
+ Debug.Assert(_fedAuthToken.accessToken != null, "AccessToken should not be null.");
#if DEBUG
if (_forceMsalRetry)
{
@@ -2569,13 +2569,13 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
}
Debug.Assert(_fedAuthToken != null, "fedAuthToken should not be null.");
- Debug.Assert(_fedAuthToken.AccessToken != null && _fedAuthToken.AccessToken.Length > 0, "fedAuthToken.accessToken should not be null or empty.");
+ Debug.Assert(_fedAuthToken.accessToken != null && _fedAuthToken.accessToken.Length > 0, "fedAuthToken.accessToken should not be null or empty.");
// Store the newly generated token in _newDbConnectionPoolAuthenticationContext, only if using pooling.
if (_dbConnectionPool != null)
{
- DateTime expirationTime = DateTime.FromFileTimeUtc(_fedAuthToken.ExpirationFileTime);
- _newDbConnectionPoolAuthenticationContext = new DbConnectionPoolAuthenticationContext(_fedAuthToken.AccessToken, expirationTime);
+ DateTime expirationTime = DateTime.FromFileTimeUtc(_fedAuthToken.expirationFileTime);
+ _newDbConnectionPoolAuthenticationContext = new DbConnectionPoolAuthenticationContext(_fedAuthToken.accessToken, expirationTime);
}
SqlClientEventSource.Log.TryTraceEvent(" {0}, Finished generating federated authentication token.", ObjectID);
return _fedAuthToken;
@@ -2667,7 +2667,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data)
Debug.Assert(_fedAuthFeatureExtensionData != null, "_fedAuthFeatureExtensionData must not be null when _federatedAuthenticationRequested == true");
- switch (_fedAuthFeatureExtensionData.LibraryType)
+ switch (_fedAuthFeatureExtensionData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
case TdsEnums.FedAuthLibrary.SecurityToken:
@@ -2682,7 +2682,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data)
default:
Debug.Fail("Unknown _fedAuthLibrary type");
SqlClientEventSource.Log.TryTraceEvent(" {0}, Attempting to use unknown federated authentication library", ObjectID);
- throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.LibraryType);
+ throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.libraryType);
}
_federatedAuthenticationAcknowledged = true;
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
index 5587eb3a52..a6b19e8f50 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -3808,9 +3808,9 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
{
return result;
}
- a.TdsVersion = (uint)((((((b[0] << 8) | b[1]) << 8) | b[2]) << 8) | b[3]); // bytes are in motorola order (high byte first)
- uint majorMinor = a.TdsVersion & 0xff00ffff;
- uint increment = (a.TdsVersion >> 16) & 0xff;
+ a.tdsVersion = (uint)((((((b[0] << 8) | b[1]) << 8) | b[2]) << 8) | b[3]); // bytes are in motorola order (high byte first)
+ uint majorMinor = a.tdsVersion & 0xff00ffff;
+ uint increment = (a.tdsVersion >> 16) & 0xff;
// Server responds:
// 0x07000000 -> 7.0 // Notice server response format is different for bwd compat
@@ -3868,12 +3868,12 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
{
return result;
}
- result = stateObj.TryReadByte(out a.MajorVersion);
+ result = stateObj.TryReadByte(out a.majorVersion);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out a.MinorVersion);
+ result = stateObj.TryReadByte(out a.minorVersion);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -3890,7 +3890,7 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
return result;
}
- a.BuildNum = (short)((buildNumHi << 8) + buildNumLo);
+ a.buildNum = (short)((buildNumHi << 8) + buildNumLo);
Debug.Assert(_state == TdsParserState.OpenNotLoggedIn, "ProcessLoginAck called with state not TdsParserState.OpenNotLoggedIn");
_state = TdsParserState.OpenLoggedIn;
@@ -4014,11 +4014,11 @@ private TdsOperationStatus TryProcessFedAuthInfo(TdsParserStateObject stateObj,
switch ((TdsEnums.FedAuthInfoId)id)
{
case TdsEnums.FedAuthInfoId.Spn:
- tempFedAuthInfo.Spn = data;
+ tempFedAuthInfo.spn = data;
break;
case TdsEnums.FedAuthInfoId.Stsurl:
- tempFedAuthInfo.StsUrl = data;
+ tempFedAuthInfo.stsurl = data;
break;
default:
@@ -4034,7 +4034,7 @@ private TdsOperationStatus TryProcessFedAuthInfo(TdsParserStateObject stateObj,
}
SqlClientEventSource.Log.TryTraceEvent(" Processed FEDAUTHINFO token stream: {0}", tempFedAuthInfo);
- if (string.IsNullOrWhiteSpace(tempFedAuthInfo.StsUrl) || string.IsNullOrWhiteSpace(tempFedAuthInfo.Spn))
+ if (string.IsNullOrWhiteSpace(tempFedAuthInfo.stsurl) || string.IsNullOrWhiteSpace(tempFedAuthInfo.spn))
{
// We should be receiving both stsurl and spn
SqlClientEventSource.Log.TryTraceEvent(" FEDAUTHINFO token stream does not contain both STSURL and SPN.");
@@ -4140,7 +4140,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
{
returnValue = null;
SqlReturnValue rec = new SqlReturnValue();
- rec.Length = length; // In 2005 this length is -1
+ rec.length = length; // In 2005 this length is -1
TdsOperationStatus result = stateObj.TryReadUInt16(out _);
if (result != TdsOperationStatus.Done)
{
@@ -4153,10 +4153,10 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
return result;
}
- rec.Parameter = null;
+ rec.parameter = null;
if (len > 0)
{
- result = stateObj.TryReadString(len, out rec.Parameter);
+ result = stateObj.TryReadString(len, out rec.parameter);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4197,7 +4197,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
// Check if the column is encrypted.
if (IsColumnEncryptionSupported)
{
- rec.IsEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ rec.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// read the type
@@ -4231,35 +4231,35 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
}
}
- rec.MetaType = MetaType.GetSqlDataType(tdsType, userType, tdsLen);
- rec.Type = rec.MetaType.SqlDbType;
+ rec.metaType = MetaType.GetSqlDataType(tdsType, userType, tdsLen);
+ rec.type = rec.metaType.SqlDbType;
// always use the nullable type for parameters if 2000 or later
// 7.0 sometimes sends fixed length return values
- rec.TdsType = rec.MetaType.NullableType;
+ rec.tdsType = rec.metaType.NullableType;
rec.IsNullable = true;
if (tdsLen == TdsEnums.SQL_USHORTVARMAXLEN)
{
- rec.MetaType = MetaType.GetMaxMetaTypeFromMetaType(rec.MetaType);
+ rec.metaType = MetaType.GetMaxMetaTypeFromMetaType(rec.metaType);
}
- if (rec.Type == SqlDbType.Decimal)
+ if (rec.type == SqlDbType.Decimal)
{
- result = stateObj.TryReadByte(out rec.Precision);
+ result = stateObj.TryReadByte(out rec.precision);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out rec.Scale);
+ result = stateObj.TryReadByte(out rec.scale);
if (result != TdsOperationStatus.Done)
{
return result;
}
}
- if (rec.MetaType.IsVarTime)
+ if (rec.metaType.IsVarTime)
{
- result = stateObj.TryReadByte(out rec.Scale);
+ result = stateObj.TryReadByte(out rec.scale);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4275,7 +4275,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
}
}
- if (rec.Type == SqlDbType.Xml)
+ if (rec.type == SqlDbType.Xml)
{
// Read schema info
byte schemapresent;
@@ -4292,13 +4292,13 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
{
return result;
}
- if (rec.XmlSchemaCollection is null)
+ if (rec.xmlSchemaCollection is null)
{
- rec.XmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
+ rec.xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
}
if (len != 0)
{
- result = stateObj.TryReadString(len, out rec.XmlSchemaCollection.Database);
+ result = stateObj.TryReadString(len, out rec.xmlSchemaCollection.Database);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4312,7 +4312,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
}
if (len != 0)
{
- result = stateObj.TryReadString(len, out rec.XmlSchemaCollection.OwningSchema);
+ result = stateObj.TryReadString(len, out rec.xmlSchemaCollection.OwningSchema);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4328,7 +4328,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
if (slen != 0)
{
- result = stateObj.TryReadString(slen, out rec.XmlSchemaCollection.Name);
+ result = stateObj.TryReadString(slen, out rec.xmlSchemaCollection.Name);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4336,40 +4336,40 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
}
}
}
- else if (rec.MetaType.IsCharType)
+ else if (rec.metaType.IsCharType)
{
// read the collation for 8.x servers
- result = TryProcessCollation(stateObj, out rec.Collation);
+ result = TryProcessCollation(stateObj, out rec.collation);
if (result != TdsOperationStatus.Done)
{
return result;
}
// UTF8 collation
- if (rec.Collation.IsUTF8)
+ if (rec.collation.IsUTF8)
{
- rec.Encoding = Encoding.UTF8;
+ rec.encoding = Encoding.UTF8;
}
else
{
- int codePage = GetCodePage(rec.Collation, stateObj);
+ int codePage = GetCodePage(rec.collation, stateObj);
// If the column lcid is the same as the default, use the default encoder
if (codePage == _defaultCodePage)
{
- rec.CodePage = _defaultCodePage;
- rec.Encoding = _defaultEncoding;
+ rec.codePage = _defaultCodePage;
+ rec.encoding = _defaultEncoding;
}
else
{
- rec.CodePage = codePage;
- rec.Encoding = System.Text.Encoding.GetEncoding(rec.CodePage);
+ rec.codePage = codePage;
+ rec.encoding = System.Text.Encoding.GetEncoding(rec.codePage);
}
}
}
// For encrypted parameters, read the unencrypted type and encryption information.
- if (IsColumnEncryptionSupported && rec.IsEncrypted)
+ if (IsColumnEncryptionSupported && rec.isEncrypted)
{
result = TryProcessTceCryptoMetadata(stateObj, rec, cipherTable: null, columnEncryptionSetting: columnEncryptionSetting, isReturnValue: true);
if (result != TdsOperationStatus.Done)
@@ -4392,20 +4392,20 @@ internal TdsOperationStatus TryProcessReturnValue(int length, TdsParserStateObje
int intlen = valLen > (ulong)(int.MaxValue) ? int.MaxValue : (int)valLen;
- if (rec.MetaType.IsPlp)
+ if (rec.metaType.IsPlp)
{
intlen = int.MaxValue; // If plp data, read it all
}
if (isNull)
{
- GetNullSqlValue(rec.Value, rec, SqlCommandColumnEncryptionSetting.Disabled, _connHandler);
+ GetNullSqlValue(rec.value, rec, SqlCommandColumnEncryptionSetting.Disabled, _connHandler);
}
else
{
// We should never do any decryption here, so pass disabled as the command encryption override.
// We only read the binary value and decryption will be performed by OnReturnValue().
- result = TryReadSqlValue(rec.Value, rec, intlen, stateObj, SqlCommandColumnEncryptionSetting.Disabled, columnName: null /*Not used*/);
+ result = TryReadSqlValue(rec.value, rec, intlen, stateObj, SqlCommandColumnEncryptionSetting.Disabled, columnName: null /*Not used*/);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4454,8 +4454,8 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
}
// Read the base TypeInfo
- col.BaseTI = new SqlMetaDataPriv();
- result = TryProcessTypeInfo(stateObj, col.BaseTI, userType);
+ col.baseTI = new SqlMetaDataPriv();
+ result = TryProcessTypeInfo(stateObj, col.baseTI, userType);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4503,7 +4503,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
return result;
}
- Debug.Assert(col.CipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
+ Debug.Assert(col.cipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
// Check if TCE is enable and if it is set the crypto MD for the column.
// TCE is enabled if the command is set to enabled or to resultset only and this is not a return value
@@ -4514,7 +4514,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
_connHandler != null && _connHandler.ConnectionOptions != null &&
_connHandler.ConnectionOptions.ColumnEncryptionSetting == SqlConnectionColumnEncryptionSetting.Enabled))
{
- col.CipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
+ col.cipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
index,
cipherAlgorithmId: cipherAlgorithmId,
cipherAlgorithmName: cipherAlgorithmName,
@@ -4524,7 +4524,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
else
{
// If TCE is disabled mark the MD as not encrypted.
- col.IsEncrypted = false;
+ col.isEncrypted = false;
}
return TdsOperationStatus.Done;
@@ -4691,7 +4691,7 @@ internal void DrainData(TdsParserStateObject stateObj)
// iia. if we still have bytes left from a partially read column, skip
if (sharedState._nextColumnDataToRead < sharedState._nextColumnHeaderToRead)
{
- if ((sharedState._nextColumnHeaderToRead > 0) && (metadata[sharedState._nextColumnHeaderToRead - 1].MetaType.IsPlp))
+ if ((sharedState._nextColumnHeaderToRead > 0) && (metadata[sharedState._nextColumnHeaderToRead - 1].metaType.IsPlp))
{
if (stateObj._longlen != 0)
{
@@ -4751,7 +4751,7 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
_SqlMetaDataSet altMetaDataSet = new _SqlMetaDataSet(cColumns, null);
- TdsOperationStatus result = stateObj.TryReadUInt16(out altMetaDataSet.Id);
+ TdsOperationStatus result = stateObj.TryReadUInt16(out altMetaDataSet.id);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5026,25 +5026,25 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
if (tdsType == TdsEnums.SQLXMLTYPE)
- col.Length = TdsEnums.SQL_USHORTVARMAXLEN; //Use the same length as other plp datatypes
+ col.length = TdsEnums.SQL_USHORTVARMAXLEN; //Use the same length as other plp datatypes
else if (IsVarTimeTds(tdsType))
- col.Length = 0; // placeholder until we read the scale, just make sure it's not SQL_USHORTVARMAXLEN
+ col.length = 0; // placeholder until we read the scale, just make sure it's not SQL_USHORTVARMAXLEN
else if (tdsType == TdsEnums.SQLDATE)
{
- col.Length = 3;
+ col.length = 3;
}
else
{
- result = TryGetTokenLength(tdsType, stateObj, out col.Length);
+ result = TryGetTokenLength(tdsType, stateObj, out col.length);
if (result != TdsOperationStatus.Done)
{
return result;
}
}
- col.MetaType = MetaType.GetSqlDataType(tdsType, userType, col.Length);
- col.Type = col.MetaType.SqlDbType;
- col.TdsType = (col.IsNullable ? col.MetaType.NullableType : col.MetaType.TDSType);
+ col.metaType = MetaType.GetSqlDataType(tdsType, userType, col.length);
+ col.type = col.metaType.SqlDbType;
+ col.tdsType = (col.IsNullable ? col.metaType.NullableType : col.metaType.TDSType);
if (TdsEnums.SQLUDT == tdsType)
{
@@ -5055,7 +5055,7 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
}
- if (col.Length == TdsEnums.SQL_USHORTVARMAXLEN)
+ if (col.length == TdsEnums.SQL_USHORTVARMAXLEN)
{
Debug.Assert(tdsType == TdsEnums.SQLXMLTYPE ||
tdsType == TdsEnums.SQLBIGVARCHAR ||
@@ -5063,9 +5063,9 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
tdsType == TdsEnums.SQLNVARCHAR ||
tdsType == TdsEnums.SQLUDT,
"Invalid streaming datatype");
- col.MetaType = MetaType.GetMaxMetaTypeFromMetaType(col.MetaType);
- Debug.Assert(col.MetaType.IsLong, "Max datatype not IsLong");
- col.Length = int.MaxValue;
+ col.metaType = MetaType.GetMaxMetaTypeFromMetaType(col.metaType);
+ Debug.Assert(col.metaType.IsLong, "Max datatype not IsLong");
+ col.length = int.MaxValue;
if (tdsType == TdsEnums.SQLXMLTYPE)
{
byte schemapresent;
@@ -5082,13 +5082,13 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
{
return result;
}
- if (col.XmlSchemaCollection is null)
+ if (col.xmlSchemaCollection is null)
{
- col.XmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
+ col.xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
}
if (byteLen != 0)
{
- result = stateObj.TryReadString(byteLen, out col.XmlSchemaCollection.Database);
+ result = stateObj.TryReadString(byteLen, out col.xmlSchemaCollection.Database);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5102,7 +5102,7 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
if (byteLen != 0)
{
- result = stateObj.TryReadString(byteLen, out col.XmlSchemaCollection.OwningSchema);
+ result = stateObj.TryReadString(byteLen, out col.xmlSchemaCollection.OwningSchema);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5117,7 +5117,7 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
if (byteLen != 0)
{
- result = stateObj.TryReadString(shortLen, out col.XmlSchemaCollection.Name);
+ result = stateObj.TryReadString(shortLen, out col.xmlSchemaCollection.Name);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5127,44 +5127,44 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
}
- if (col.Type == SqlDbType.Decimal)
+ if (col.type == SqlDbType.Decimal)
{
- result = stateObj.TryReadByte(out col.Precision);
+ result = stateObj.TryReadByte(out col.precision);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out col.Scale);
+ result = stateObj.TryReadByte(out col.scale);
if (result != TdsOperationStatus.Done)
{
return result;
}
}
- if (col.MetaType.IsVarTime)
+ if (col.metaType.IsVarTime)
{
- result = stateObj.TryReadByte(out col.Scale);
+ result = stateObj.TryReadByte(out col.scale);
if (result != TdsOperationStatus.Done)
{
return result;
}
- Debug.Assert(0 <= col.Scale && col.Scale <= 7);
+ Debug.Assert(0 <= col.scale && col.scale <= 7);
// calculate actual column length here
// TODO: variable-length calculation needs to be encapsulated better
- switch (col.MetaType.SqlDbType)
+ switch (col.metaType.SqlDbType)
{
case SqlDbType.Time:
- col.Length = MetaType.GetTimeSizeFromScale(col.Scale);
+ col.length = MetaType.GetTimeSizeFromScale(col.scale);
break;
case SqlDbType.DateTime2:
// Date in number of days (3 bytes) + time
- col.Length = 3 + MetaType.GetTimeSizeFromScale(col.Scale);
+ col.length = 3 + MetaType.GetTimeSizeFromScale(col.scale);
break;
case SqlDbType.DateTimeOffset:
// Date in days (3 bytes) + offset in minutes (2 bytes) + time
- col.Length = 5 + MetaType.GetTimeSizeFromScale(col.Scale);
+ col.length = 5 + MetaType.GetTimeSizeFromScale(col.scale);
break;
default:
@@ -5174,32 +5174,32 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
// read the collation for 7.x servers
- if (col.MetaType.IsCharType && (tdsType != TdsEnums.SQLXMLTYPE))
+ if (col.metaType.IsCharType && (tdsType != TdsEnums.SQLXMLTYPE))
{
- result = TryProcessCollation(stateObj, out col.Collation);
+ result = TryProcessCollation(stateObj, out col.collation);
if (result != TdsOperationStatus.Done)
{
return result;
}
// UTF8 collation
- if (col.Collation.IsUTF8)
+ if (col.collation.IsUTF8)
{
- col.Encoding = Encoding.UTF8;
+ col.encoding = Encoding.UTF8;
}
else
{
- int codePage = GetCodePage(col.Collation, stateObj);
+ int codePage = GetCodePage(col.collation, stateObj);
if (codePage == _defaultCodePage)
{
- col.CodePage = _defaultCodePage;
- col.Encoding = _defaultEncoding;
+ col.codePage = _defaultCodePage;
+ col.encoding = _defaultEncoding;
}
else
{
- col.CodePage = codePage;
- col.Encoding = System.Text.Encoding.GetEncoding(col.CodePage);
+ col.codePage = codePage;
+ col.encoding = System.Text.Encoding.GetEncoding(col.codePage);
}
}
}
@@ -5242,7 +5242,7 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
if (fColMD && IsColumnEncryptionSupported)
{
- col.IsEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ col.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// Read TypeInfo
@@ -5253,10 +5253,10 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
}
// Read tablename if present
- if (col.MetaType.IsLong && !col.MetaType.IsPlp)
+ if (col.metaType.IsLong && !col.metaType.IsPlp)
{
int unusedLen = 0xFFFF; //We ignore this value
- result = TryProcessOneTable(stateObj, ref unusedLen, out col.MultiPartTableName);
+ result = TryProcessOneTable(stateObj, ref unusedLen, out col.multiPartTableName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5264,7 +5264,7 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
}
// Read the TCE column cryptoinfo
- if (fColMD && IsColumnEncryptionSupported && col.IsEncrypted)
+ if (fColMD && IsColumnEncryptionSupported && col.isEncrypted)
{
// If the column is encrypted, we should have a valid cipherTable
if (cipherTable != null)
@@ -5283,7 +5283,7 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
{
return result;
}
- result = stateObj.TryReadString(byteLen, out col.Column);
+ result = stateObj.TryReadString(byteLen, out col.column);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5473,7 +5473,7 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
return result;
}
- result = stateObj.TryReadByte(out col.TableNum);
+ result = stateObj.TryReadByte(out col.tableNum);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5501,7 +5501,7 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
{
return result;
}
- result = stateObj.TryReadString(len, out col.BaseColumn);
+ result = stateObj.TryReadString(len, out col.baseColumn);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5510,10 +5510,10 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
// Fixup column name - only if result of a table - that is if it was not the result of
// an expression.
- if ((reader.TableNames != null) && (col.TableNum > 0))
+ if ((reader.TableNames != null) && (col.tableNum > 0))
{
- Debug.Assert(reader.TableNames.Length >= col.TableNum, "invalid tableNames array!");
- col.MultiPartTableName = reader.TableNames[col.TableNum - 1];
+ Debug.Assert(reader.TableNames.Length >= col.tableNum, "invalid tableNames array!");
+ col.multiPartTableName = reader.TableNames[col.tableNum - 1];
}
// Expressions are readonly
@@ -5548,7 +5548,7 @@ internal TdsOperationStatus TryProcessColumnHeader(SqlMetaDataPriv col, TdsParse
private TdsOperationStatus TryProcessColumnHeaderNoNBC(SqlMetaDataPriv col, TdsParserStateObject stateObj, out bool isNull, out ulong length)
{
- if (col.MetaType.IsLong && !col.MetaType.IsPlp)
+ if (col.metaType.IsLong && !col.metaType.IsPlp)
{
//
// we don't care about TextPtrs, simply go after the data after it
@@ -5604,7 +5604,7 @@ private TdsOperationStatus TryProcessColumnHeaderNoNBC(SqlMetaDataPriv col, TdsP
return result;
}
- isNull = IsNull(col.MetaType, longlen);
+ isNull = IsNull(col.metaType, longlen);
length = (isNull ? 0 : longlen);
return TdsOperationStatus.Done;
}
@@ -5673,7 +5673,7 @@ private TdsOperationStatus TryProcessRow(_SqlMetaDataSet columns, object[] buffe
// We only read up to 2Gb. Throw if data is larger. Very large data
// should be read in chunks in sequential read mode
// For Plp columns, we may have gotten only the length of the first chunk
- result = TryReadSqlValue(data, md, md.MetaType.IsPlp ? (Int32.MaxValue) : (int)len, stateObj, SqlCommandColumnEncryptionSetting.Disabled /*Column Encryption Disabled for Bulk Copy*/, md.Column);
+ result = TryReadSqlValue(data, md, md.metaType.IsPlp ? (Int32.MaxValue) : (int)len, stateObj, SqlCommandColumnEncryptionSetting.Disabled /*Column Encryption Disabled for Bulk Copy*/, md.column);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5715,13 +5715,13 @@ internal static bool ShouldHonorTceForRead(SqlCommandColumnEncryptionSetting col
internal static object GetNullSqlValue(SqlBuffer nullVal, SqlMetaDataPriv md, SqlCommandColumnEncryptionSetting columnEncryptionSetting, SqlInternalConnectionTds connection)
{
- SqlDbType type = md.Type;
+ SqlDbType type = md.type;
if (type == SqlDbType.VarBinary && // if its a varbinary
- md.IsEncrypted &&// and encrypted
+ md.isEncrypted &&// and encrypted
ShouldHonorTceForRead(columnEncryptionSetting, connection))
{
- type = md.BaseTI.Type; // the use the actual (plaintext) type
+ type = md.baseTI.type; // the use the actual (plaintext) type
}
switch (type)
@@ -5821,7 +5821,7 @@ internal static object GetNullSqlValue(SqlBuffer nullVal, SqlMetaDataPriv md, Sq
break;
default:
- Debug.Fail("unknown null sqlType!" + md.Type.ToString());
+ Debug.Fail("unknown null sqlType!" + md.type.ToString());
break;
}
@@ -5859,7 +5859,7 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
}
TdsOperationStatus result;
- if (md.MetaType.IsPlp)
+ if (md.metaType.IsPlp)
{
result = TrySkipPlpValue(ulong.MaxValue, stateObj, out _);
if (result != TdsOperationStatus.Done)
@@ -5867,9 +5867,9 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
return result;
}
}
- else if (md.MetaType.IsLong)
+ else if (md.metaType.IsLong)
{
- Debug.Assert(!md.MetaType.IsPlp, "Plp types must be handled using SkipPlpValue");
+ Debug.Assert(!md.metaType.IsPlp, "Plp types must be handled using SkipPlpValue");
byte textPtrLen;
result = stateObj.TryReadByte(out textPtrLen);
@@ -5887,7 +5887,7 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
}
int length;
- result = TryGetTokenLength(md.TdsType, stateObj, out length);
+ result = TryGetTokenLength(md.tdsType, stateObj, out length);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5902,14 +5902,14 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
else
{
int length;
- result = TryGetTokenLength(md.TdsType, stateObj, out length);
+ result = TryGetTokenLength(md.tdsType, stateObj, out length);
if (result != TdsOperationStatus.Done)
{
return result;
}
// if false, no value to skip - it's null
- if (!IsNull(md.MetaType, (ulong)length))
+ if (!IsNull(md.metaType, (ulong)length))
{
result = stateObj.TrySkipBytes(length);
if (result != TdsOperationStatus.Done)
@@ -6040,14 +6040,14 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
throw SQL.UnsupportedNormalizationVersion(normalizationVersion);
}
- byte tdsType = md.BaseTI.TdsType;
+ byte tdsType = md.baseTI.tdsType;
int length = unencryptedBytes.Length;
// For normalized types, the length and scale of the actual type might be different than the value's.
- int denormalizedLength = md.BaseTI.Length;
- byte denormalizedScale = md.BaseTI.Scale;
+ int denormalizedLength = md.baseTI.length;
+ byte denormalizedScale = md.baseTI.scale;
- Debug.Assert(false == md.BaseTI.IsEncrypted, "Double encryption detected");
+ Debug.Assert(false == md.baseTI.isEncrypted, "Double encryption detected");
//DEVNOTE: When modifying the following routines (for deserialization) please pay attention to
// deserialization code in DecryptWithKey () method and modify it accordingly.
switch (tdsType)
@@ -6197,7 +6197,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with zeros to get to the fixed length size.
if (tdsType == TdsEnums.SQLBINARY || tdsType == TdsEnums.SQLBIGBINARY)
{
- byte[] bytes = new byte[md.BaseTI.Length];
+ byte[] bytes = new byte[md.baseTI.length];
Buffer.BlockCopy(unencryptedBytes, 0, bytes, 0, unencryptedBytes.Length);
unencryptedBytes = bytes;
}
@@ -6224,7 +6224,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
bits[i] = BinaryPrimitives.ReadInt32LittleEndian(span.Slice(index));
index += 4;
}
- value.SetToDecimal(md.BaseTI.Precision, md.BaseTI.Scale, fPositive, bits);
+ value.SetToDecimal(md.baseTI.precision, md.baseTI.scale, fPositive, bits);
break;
case TdsEnums.SQLCHAR:
@@ -6233,7 +6233,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
case TdsEnums.SQLBIGVARCHAR:
case TdsEnums.SQLTEXT:
{
- System.Text.Encoding encoding = md.BaseTI.Encoding;
+ System.Text.Encoding encoding = md.baseTI.encoding;
if (encoding == null)
{
@@ -6250,7 +6250,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLCHAR || tdsType == TdsEnums.SQLBIGCHAR)
{
- strValue = strValue.PadRight(md.BaseTI.Length);
+ strValue = strValue.PadRight(md.baseTI.length);
}
value.SetToString(strValue);
@@ -6266,7 +6266,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLNCHAR)
{
- strValue = strValue.PadRight(md.BaseTI.Length / ADP.CharSize);
+ strValue = strValue.PadRight(md.baseTI.length / ADP.CharSize);
}
value.SetToString(strValue);
@@ -6297,7 +6297,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
break;
default:
- MetaType metaType = md.BaseTI.MetaType;
+ MetaType metaType = md.baseTI.metaType;
// If we don't have a metatype already, construct one to get the proper type name.
if (metaType == null)
@@ -6313,11 +6313,11 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, TdsParserStateObject stateObj, SqlCommandColumnEncryptionSetting columnEncryptionOverride, string columnName, SqlCommand command = null)
{
- bool isPlp = md.MetaType.IsPlp;
- byte tdsType = md.TdsType;
+ bool isPlp = md.metaType.IsPlp;
+ byte tdsType = md.tdsType;
TdsOperationStatus result;
- Debug.Assert(isPlp || !IsNull(md.MetaType, (ulong)length), "null value should not get here!");
+ Debug.Assert(isPlp || !IsNull(md.metaType, (ulong)length), "null value should not get here!");
if (isPlp)
{
// We must read the column value completely, no matter what length is passed in
@@ -6330,7 +6330,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md,
{
case TdsEnums.SQLDECIMALN:
case TdsEnums.SQLNUMERICN:
- result = TryReadSqlDecimal(value, length, md.Precision, md.Scale, stateObj);
+ result = TryReadSqlDecimal(value, length, md.precision, md.scale, stateObj);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6367,7 +6367,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md,
}
}
- if (md.IsEncrypted
+ if (md.isEncrypted
&& (columnEncryptionOverride == SqlCommandColumnEncryptionSetting.Enabled
|| columnEncryptionOverride == SqlCommandColumnEncryptionSetting.ResultSetOnly
|| (columnEncryptionOverride == SqlCommandColumnEncryptionSetting.UseConnectionSetting
@@ -6377,7 +6377,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md,
try
{
// CipherInfo is present, decrypt and read
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md.CipherMD, _connHandler.Connection, command);
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md.cipherMD, _connHandler.Connection, command);
if (unencryptedBytes != null)
{
@@ -6420,7 +6420,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md,
case TdsEnums.SQLNCHAR:
case TdsEnums.SQLNVARCHAR:
case TdsEnums.SQLNTEXT:
- result = TryReadSqlStringValue(value, tdsType, length, md.Encoding, isPlp, stateObj);
+ result = TryReadSqlStringValue(value, tdsType, length, md.encoding, isPlp, stateObj);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6443,7 +6443,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md,
case TdsEnums.SQLTIME:
case TdsEnums.SQLDATETIME2:
case TdsEnums.SQLDATETIMEOFFSET:
- result = TryReadSqlDateTime(value, tdsType, length, md.Scale, stateObj);
+ result = TryReadSqlDateTime(value, tdsType, length, md.scale, stateObj);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -7951,21 +7951,21 @@ internal int GetEncodingCharLength(string value, int numChars, int charOffset, E
internal TdsOperationStatus TryGetDataLength(SqlMetaDataPriv colmeta, TdsParserStateObject stateObj, out ulong length)
{
// Handle 2005 specific tokens
- if (colmeta.MetaType.IsPlp)
+ if (colmeta.metaType.IsPlp)
{
- Debug.Assert(colmeta.TdsType == TdsEnums.SQLXMLTYPE ||
- colmeta.TdsType == TdsEnums.SQLBIGVARCHAR ||
- colmeta.TdsType == TdsEnums.SQLBIGVARBINARY ||
- colmeta.TdsType == TdsEnums.SQLNVARCHAR ||
+ Debug.Assert(colmeta.tdsType == TdsEnums.SQLXMLTYPE ||
+ colmeta.tdsType == TdsEnums.SQLBIGVARCHAR ||
+ colmeta.tdsType == TdsEnums.SQLBIGVARBINARY ||
+ colmeta.tdsType == TdsEnums.SQLNVARCHAR ||
// Large UDTs is WinFS-only
- colmeta.TdsType == TdsEnums.SQLUDT,
+ colmeta.tdsType == TdsEnums.SQLUDT,
"GetDataLength:Invalid streaming datatype");
return stateObj.TryReadPlpLength(true, out length);
}
else
{
int intLength;
- TdsOperationStatus result = TryGetTokenLength(colmeta.TdsType, stateObj, out intLength);
+ TdsOperationStatus result = TryGetTokenLength(colmeta.tdsType, stateObj, out intLength);
if (result != TdsOperationStatus.Done)
{
length = 0;
@@ -8229,21 +8229,21 @@ private static int StateValueLength(int dataLen)
internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionData fedAuthFeatureData,
bool write /* if false just calculates the length */)
{
- Debug.Assert(fedAuthFeatureData.LibraryType == TdsEnums.FedAuthLibrary.MSAL || fedAuthFeatureData.LibraryType == TdsEnums.FedAuthLibrary.SecurityToken,
+ Debug.Assert(fedAuthFeatureData.libraryType == TdsEnums.FedAuthLibrary.MSAL || fedAuthFeatureData.libraryType == TdsEnums.FedAuthLibrary.SecurityToken,
"only fed auth library type MSAL and Security Token are supported in writing feature request");
int dataLen = 0;
int totalLen = 0;
// set dataLen and totalLen
- switch (fedAuthFeatureData.LibraryType)
+ switch (fedAuthFeatureData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
dataLen = 2; // length of feature data = 1 byte for library and echo + 1 byte for workflow
break;
case TdsEnums.FedAuthLibrary.SecurityToken:
- Debug.Assert(fedAuthFeatureData.AccessToken != null, "AccessToken should not be null.");
- dataLen = 1 + sizeof(int) + fedAuthFeatureData.AccessToken.Length; // length of feature data = 1 byte for library and echo, security token length and sizeof(int) for token length itself
+ Debug.Assert(fedAuthFeatureData.accessToken != null, "AccessToken should not be null.");
+ dataLen = 1 + sizeof(int) + fedAuthFeatureData.accessToken.Length; // length of feature data = 1 byte for library and echo, security token length and sizeof(int) for token length itself
break;
default:
Debug.Fail("Unrecognized library type for fedauth feature extension request");
@@ -8261,7 +8261,7 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
byte options = 0x00;
// set upper 7 bits of options to indicate fed auth library type
- switch (fedAuthFeatureData.LibraryType)
+ switch (fedAuthFeatureData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
Debug.Assert(_connHandler._federatedAuthenticationInfoRequested == true, "_federatedAuthenticationInfoRequested field should be true");
@@ -8276,18 +8276,18 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
break;
}
- options |= (byte)(fedAuthFeatureData.FedAuthRequiredPreLoginResponse == true ? 0x01 : 0x00);
+ options |= (byte)(fedAuthFeatureData.fedAuthRequiredPreLoginResponse == true ? 0x01 : 0x00);
// write dataLen and options
WriteInt(dataLen, _physicalStateObj);
_physicalStateObj.WriteByte(options);
// write accessToken for FedAuthLibrary.SecurityToken
- switch (fedAuthFeatureData.LibraryType)
+ switch (fedAuthFeatureData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
byte workflow = 0x00;
- switch (fedAuthFeatureData.Authentication)
+ switch (fedAuthFeatureData.authentication)
{
case SqlAuthenticationMethod.ActiveDirectoryPassword:
workflow = TdsEnums.MSALWORKFLOW_ACTIVEDIRECTORYPASSWORD;
@@ -8329,8 +8329,8 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
_physicalStateObj.WriteByte(workflow);
break;
case TdsEnums.FedAuthLibrary.SecurityToken:
- WriteInt(fedAuthFeatureData.AccessToken.Length, _physicalStateObj);
- _physicalStateObj.WriteByteArray(fedAuthFeatureData.AccessToken, fedAuthFeatureData.AccessToken.Length, 0);
+ WriteInt(fedAuthFeatureData.accessToken.Length, _physicalStateObj);
+ _physicalStateObj.WriteByteArray(fedAuthFeatureData.accessToken, fedAuthFeatureData.accessToken.Length, 0);
break;
default:
Debug.Fail("Unrecognized FedAuthLibrary type for feature extension request");
@@ -8445,7 +8445,7 @@ private void WriteLoginData(SqlLogin rec,
{
WriteUnsignedInt(recoverySessionData._tdsVersion, _physicalStateObj);
}
- WriteInt(rec.PacketSize, _physicalStateObj);
+ WriteInt(rec.packetSize, _physicalStateObj);
WriteInt(TdsEnums.CLIENT_PROG_VER, _physicalStateObj);
WriteInt(TdsParserStaticMethods.GetCurrentProcessIdForTdsLoginOnly(), _physicalStateObj);
WriteInt(0, _physicalStateObj); // connectionID is unused
@@ -8487,27 +8487,27 @@ private void WriteLoginData(SqlLogin rec,
// second byte
log7Flags |= TdsEnums.INIT_LANG_FATAL << 8;
log7Flags |= TdsEnums.ODBC_ON << 9;
- if (rec.UseReplication)
+ if (rec.useReplication)
{
log7Flags |= TdsEnums.REPL_ON << 12;
}
- if (rec.UseSspi)
+ if (rec.useSSPI)
{
log7Flags |= TdsEnums.SSPI_ON << 15;
}
// third byte
- if (rec.ReadOnlyIntent)
+ if (rec.readOnlyIntent)
{
log7Flags |= TdsEnums.READONLY_INTENT_ON << 21; // read-only intent flag is a first bit of fSpare1
}
// 4th one
- if (!string.IsNullOrEmpty(rec.NewPassword) || (rec.NewSecurePassword != null && rec.NewSecurePassword.Length != 0))
+ if (!string.IsNullOrEmpty(rec.newPassword) || (rec.newSecurePassword != null && rec.newSecurePassword.Length != 0))
{
log7Flags |= 1 << 24;
}
- if (rec.UserInstance)
+ if (rec.userInstance)
{
log7Flags |= 1 << 26;
}
@@ -8529,12 +8529,12 @@ private void WriteLoginData(SqlLogin rec,
// note that you must always set ibHostName since it indicates the beginning of the variable length section of the login record
WriteShort(offset, _physicalStateObj); // host name offset
- WriteShort(rec.HostName.Length, _physicalStateObj);
- offset += rec.HostName.Length * 2;
+ WriteShort(rec.hostName.Length, _physicalStateObj);
+ offset += rec.hostName.Length * 2;
// Only send user/password over if not fSSPI... If both user/password and SSPI are in login
// rec, only SSPI is used. Confirmed same behavior as in luxor.
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
WriteShort(offset, _physicalStateObj); // userName offset
WriteShort(userName.Length, _physicalStateObj);
@@ -8555,12 +8555,12 @@ private void WriteLoginData(SqlLogin rec,
}
WriteShort(offset, _physicalStateObj); // app name offset
- WriteShort(rec.ApplicationName.Length, _physicalStateObj);
- offset += rec.ApplicationName.Length * 2;
+ WriteShort(rec.applicationName.Length, _physicalStateObj);
+ offset += rec.applicationName.Length * 2;
WriteShort(offset, _physicalStateObj); // server name offset
- WriteShort(rec.ServerName.Length, _physicalStateObj);
- offset += rec.ServerName.Length * 2;
+ WriteShort(rec.serverName.Length, _physicalStateObj);
+ offset += rec.serverName.Length * 2;
WriteShort(offset, _physicalStateObj);
if (useFeatureExt)
@@ -8578,12 +8578,12 @@ private void WriteLoginData(SqlLogin rec,
offset += clientInterfaceName.Length * 2;
WriteShort(offset, _physicalStateObj); // language name offset
- WriteShort(rec.Language.Length, _physicalStateObj);
- offset += rec.Language.Length * 2;
+ WriteShort(rec.language.Length, _physicalStateObj);
+ offset += rec.language.Length * 2;
WriteShort(offset, _physicalStateObj); // database name offset
- WriteShort(rec.Database.Length, _physicalStateObj);
- offset += rec.Database.Length * 2;
+ WriteShort(rec.database.Length, _physicalStateObj);
+ offset += rec.database.Length * 2;
if (s_nicAddress == null)
{
@@ -8593,7 +8593,7 @@ private void WriteLoginData(SqlLogin rec,
_physicalStateObj.WriteByteArray(s_nicAddress, s_nicAddress.Length, 0);
WriteShort(offset, _physicalStateObj); // ibSSPI offset
- if (rec.UseSspi)
+ if (rec.useSSPI)
{
WriteShort((int)outSSPILength, _physicalStateObj);
offset += (int)outSSPILength;
@@ -8604,8 +8604,8 @@ private void WriteLoginData(SqlLogin rec,
}
WriteShort(offset, _physicalStateObj); // DB filename offset
- WriteShort(rec.AttachDbFilename.Length, _physicalStateObj);
- offset += rec.AttachDbFilename.Length * 2;
+ WriteShort(rec.attachDBFilename.Length, _physicalStateObj);
+ offset += rec.attachDBFilename.Length * 2;
WriteShort(offset, _physicalStateObj); // reset password offset
WriteShort(encryptedChangePasswordLengthInBytes / 2, _physicalStateObj);
@@ -8613,17 +8613,17 @@ private void WriteLoginData(SqlLogin rec,
WriteInt(0, _physicalStateObj); // reserved for chSSPI
// write variable length portion
- WriteString(rec.HostName, _physicalStateObj);
+ WriteString(rec.hostName, _physicalStateObj);
// if we are using SSPI, do not send over username/password, since we will use SSPI instead
// same behavior as Luxor
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
WriteString(userName, _physicalStateObj);
- if (rec.Credential != null)
+ if (rec.credential != null)
{
- _physicalStateObj.WriteSecureString(rec.Credential.Password);
+ _physicalStateObj.WriteSecureString(rec.credential.Password);
}
else
{
@@ -8631,8 +8631,8 @@ private void WriteLoginData(SqlLogin rec,
}
}
- WriteString(rec.ApplicationName, _physicalStateObj);
- WriteString(rec.ServerName, _physicalStateObj);
+ WriteString(rec.applicationName, _physicalStateObj);
+ WriteString(rec.serverName, _physicalStateObj);
// write ibFeatureExtLong
if (useFeatureExt)
@@ -8646,19 +8646,19 @@ private void WriteLoginData(SqlLogin rec,
}
WriteString(clientInterfaceName, _physicalStateObj);
- WriteString(rec.Language, _physicalStateObj);
- WriteString(rec.Database, _physicalStateObj);
+ WriteString(rec.language, _physicalStateObj);
+ WriteString(rec.database, _physicalStateObj);
// send over SSPI data if we are using SSPI
- if (rec.UseSspi)
+ if (rec.useSSPI)
_physicalStateObj.WriteByteArray(outSSPIBuff, (int)outSSPILength, 0);
- WriteString(rec.AttachDbFilename, _physicalStateObj);
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ WriteString(rec.attachDBFilename, _physicalStateObj);
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
- if (rec.NewSecurePassword != null)
+ if (rec.newSecurePassword != null)
{
- _physicalStateObj.WriteSecureString(rec.NewSecurePassword);
+ _physicalStateObj.WriteSecureString(rec.newSecurePassword);
}
else
{
@@ -8739,11 +8739,11 @@ private int ApplyFeatureExData(TdsEnums.FeatureExtension requestedFeatures,
internal void SendFedAuthToken(SqlFedAuthToken fedAuthToken)
{
Debug.Assert(fedAuthToken != null, "fedAuthToken cannot be null");
- Debug.Assert(fedAuthToken.AccessToken != null, "fedAuthToken.accessToken cannot be null");
+ Debug.Assert(fedAuthToken.accessToken != null, "fedAuthToken.accessToken cannot be null");
SqlClientEventSource.Log.TryTraceEvent(" Sending federated authentication token");
_physicalStateObj._outputMessageType = TdsEnums.MT_FEDAUTH;
- byte[] accessToken = fedAuthToken.AccessToken;
+ byte[] accessToken = fedAuthToken.accessToken;
// Send total length (length of token plus 4 bytes for the token length field)
// If we were sending a nonce, this would include that length as well
@@ -9266,30 +9266,30 @@ internal Task TdsExecuteRPC(SqlCommand cmd, IList<_SqlRPC> rpcArray, int timeout
if (startParam == 0 || ii > startRpc)
{
- if (rpcext.ProcId != 0)
+ if (rpcext.ProcID != 0)
{
// Perf optimization for 2000 and later,
- Debug.Assert(rpcext.ProcId < 255, "rpcExec:ProcID can't be larger than 255");
+ Debug.Assert(rpcext.ProcID < 255, "rpcExec:ProcID can't be larger than 255");
WriteShort(0xffff, stateObj);
- WriteShort((short)(rpcext.ProcId), stateObj);
+ WriteShort((short)(rpcext.ProcID), stateObj);
}
else
{
- Debug.Assert(!string.IsNullOrEmpty(rpcext.RpcName), "must have an RPC name");
- tempLen = rpcext.RpcName.Length;
+ Debug.Assert(!string.IsNullOrEmpty(rpcext.rpcName), "must have an RPC name");
+ tempLen = rpcext.rpcName.Length;
WriteShort(tempLen, stateObj);
- WriteString(rpcext.RpcName, tempLen, 0, stateObj);
+ WriteString(rpcext.rpcName, tempLen, 0, stateObj);
}
// Options
- WriteShort((short)rpcext.Options, stateObj);
+ WriteShort((short)rpcext.options, stateObj);
byte[] enclavePackage = cmd.enclavePackage != null ? cmd.enclavePackage.EnclavePackageBytes : null;
WriteEnclaveInfo(stateObj, enclavePackage);
}
// Stream out parameters
- int parametersLength = rpcext.UserParamCount + rpcext.SystemParamCount;
+ int parametersLength = rpcext.userParamCount + rpcext.systemParamCount;
bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn();
bool enableOptimizedParameterBinding = cmd.EnableOptimizedParameterBinding && cmd.CommandType == CommandType.Text;
@@ -10482,9 +10482,9 @@ internal void LoadColumnEncryptionKeys(_SqlMetaDataSet metadataCollection, SqlCo
if (metadataCollection[col] != null)
{
_SqlMetaData md = metadataCollection[col];
- if (md.IsEncrypted)
+ if (md.isEncrypted)
{
- SqlSecurityUtility.DecryptSymmetricKey(md.CipherMD, connection, command);
+ SqlSecurityUtility.DecryptSymmetricKey(md.cipherMD, connection, command);
}
}
}
@@ -10532,14 +10532,14 @@ internal void WriteCekTable(_SqlMetaDataSet metadataCollection, TdsParserStateOb
// Note- Cek table (with 0 entries) will be present if TCE
// was enabled and server supports it!
// OR if encryption was disabled in connection options
- if (metadataCollection.CekTable == null ||
+ if (metadataCollection.cekTable == null ||
!ShouldEncryptValuesForBulkCopy())
{
WriteShort(0x00, stateObj);
return;
}
- SqlTceCipherInfoTable cekTable = metadataCollection.CekTable;
+ SqlTceCipherInfoTable cekTable = metadataCollection.cekTable;
ushort count = (ushort)cekTable.Size;
WriteShort(count, stateObj);
@@ -10556,17 +10556,17 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
// Write the UserType (4 byte value)
WriteInt(0x0, stateObj); // TODO: fix this- timestamp columns have 0x50 value here
- Debug.Assert(SqlDbType.Xml != mdPriv.Type);
- Debug.Assert(SqlDbType.Udt != mdPriv.Type);
+ Debug.Assert(SqlDbType.Xml != mdPriv.type);
+ Debug.Assert(SqlDbType.Udt != mdPriv.type);
- stateObj.WriteByte(mdPriv.TdsType);
+ stateObj.WriteByte(mdPriv.tdsType);
- switch (mdPriv.Type)
+ switch (mdPriv.type)
{
case SqlDbType.Decimal:
- WriteTokenLength(mdPriv.TdsType, mdPriv.Length, stateObj);
- stateObj.WriteByte(mdPriv.Precision);
- stateObj.WriteByte(mdPriv.Scale);
+ WriteTokenLength(mdPriv.tdsType, mdPriv.length, stateObj);
+ stateObj.WriteByte(mdPriv.precision);
+ stateObj.WriteByte(mdPriv.scale);
break;
case SqlDbType.Date:
// Nothing more to write!
@@ -10574,14 +10574,14 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
case SqlDbType.Time:
case SqlDbType.DateTime2:
case SqlDbType.DateTimeOffset:
- stateObj.WriteByte(mdPriv.Scale);
+ stateObj.WriteByte(mdPriv.scale);
break;
default:
- WriteTokenLength(mdPriv.TdsType, mdPriv.Length, stateObj);
- if (mdPriv.MetaType.IsCharType)
+ WriteTokenLength(mdPriv.tdsType, mdPriv.length, stateObj);
+ if (mdPriv.metaType.IsCharType)
{
- WriteUnsignedInt(mdPriv.Collation._info, stateObj);
- stateObj.WriteByte(mdPriv.Collation._sortId);
+ WriteUnsignedInt(mdPriv.collation._info, stateObj);
+ stateObj.WriteByte(mdPriv.collation._sortId);
}
break;
}
@@ -10594,34 +10594,34 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
internal void WriteCryptoMetadata(_SqlMetaData md, TdsParserStateObject stateObj)
{
if (!IsColumnEncryptionSupported || // TCE Feature supported
- !md.IsEncrypted || // Column is not encrypted
+ !md.isEncrypted || // Column is not encrypted
!ShouldEncryptValuesForBulkCopy())
{ // TCE disabled on connection string
return;
}
// Write the ordinal
- WriteShort(md.CipherMD.CekTableOrdinal, stateObj);
+ WriteShort(md.cipherMD.CekTableOrdinal, stateObj);
// Write UserType and TYPEINFO
- WriteTceUserTypeAndTypeInfo(md.BaseTI, stateObj);
+ WriteTceUserTypeAndTypeInfo(md.baseTI, stateObj);
// Write Encryption Algo
- stateObj.WriteByte(md.CipherMD.CipherAlgorithmId);
+ stateObj.WriteByte(md.cipherMD.CipherAlgorithmId);
- if (TdsEnums.CustomCipherAlgorithmId == md.CipherMD.CipherAlgorithmId)
+ if (TdsEnums.CustomCipherAlgorithmId == md.cipherMD.CipherAlgorithmId)
{
// Write the algorithm name
- Debug.Assert(md.CipherMD.CipherAlgorithmName.Length < 256);
- stateObj.WriteByte((byte)md.CipherMD.CipherAlgorithmName.Length);
- WriteString(md.CipherMD.CipherAlgorithmName, stateObj);
+ Debug.Assert(md.cipherMD.CipherAlgorithmName.Length < 256);
+ stateObj.WriteByte((byte)md.cipherMD.CipherAlgorithmName.Length);
+ WriteString(md.cipherMD.CipherAlgorithmName, stateObj);
}
// Write Encryption Algo Type
- stateObj.WriteByte(md.CipherMD.EncryptionType);
+ stateObj.WriteByte(md.cipherMD.EncryptionType);
// Write Normalization Version
- stateObj.WriteByte(md.CipherMD.NormalizationRuleVersion);
+ stateObj.WriteByte(md.cipherMD.NormalizationRuleVersion);
}
internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int count, TdsParserStateObject stateObj)
@@ -10657,58 +10657,58 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
{ // TCE Supported
if (ShouldEncryptValuesForBulkCopy())
{ // TCE enabled on connection options
- flags |= (UInt16)(md.IsEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
+ flags |= (UInt16)(md.isEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
}
}
WriteShort(flags, stateObj); // write the flags
- switch (md.Type)
+ switch (md.type)
{
case SqlDbType.Decimal:
- stateObj.WriteByte(md.TdsType);
- WriteTokenLength(md.TdsType, md.Length, stateObj);
- stateObj.WriteByte(md.Precision);
- stateObj.WriteByte(md.Scale);
+ stateObj.WriteByte(md.tdsType);
+ WriteTokenLength(md.tdsType, md.length, stateObj);
+ stateObj.WriteByte(md.precision);
+ stateObj.WriteByte(md.scale);
break;
case SqlDbType.Xml:
stateObj.WriteByteArray(s_xmlMetadataSubstituteSequence, s_xmlMetadataSubstituteSequence.Length, 0);
break;
case SqlDbType.Udt:
stateObj.WriteByte(TdsEnums.SQLBIGVARBINARY);
- WriteTokenLength(TdsEnums.SQLBIGVARBINARY, md.Length, stateObj);
+ WriteTokenLength(TdsEnums.SQLBIGVARBINARY, md.length, stateObj);
break;
case SqlDbType.Date:
- stateObj.WriteByte(md.TdsType);
+ stateObj.WriteByte(md.tdsType);
break;
case SqlDbType.Time:
case SqlDbType.DateTime2:
case SqlDbType.DateTimeOffset:
- stateObj.WriteByte(md.TdsType);
- stateObj.WriteByte(md.Scale);
+ stateObj.WriteByte(md.tdsType);
+ stateObj.WriteByte(md.scale);
break;
default:
- stateObj.WriteByte(md.TdsType);
- WriteTokenLength(md.TdsType, md.Length, stateObj);
- if (md.MetaType.IsCharType)
+ stateObj.WriteByte(md.tdsType);
+ WriteTokenLength(md.tdsType, md.length, stateObj);
+ if (md.metaType.IsCharType)
{
- WriteUnsignedInt(md.Collation._info, stateObj);
- stateObj.WriteByte(md.Collation._sortId);
+ WriteUnsignedInt(md.collation._info, stateObj);
+ stateObj.WriteByte(md.collation._sortId);
}
break;
}
- if (md.MetaType.IsLong && !md.MetaType.IsPlp)
+ if (md.metaType.IsLong && !md.metaType.IsPlp)
{
- WriteShort(md.TableName.Length, stateObj);
- WriteString(md.TableName, stateObj);
+ WriteShort(md.tableName.Length, stateObj);
+ WriteString(md.tableName, stateObj);
}
WriteCryptoMetadata(md, stateObj);
- stateObj.WriteByte((byte)md.Column.Length);
- WriteString(md.Column, stateObj);
+ stateObj.WriteByte((byte)md.column.Length);
+ WriteString(md.column, stateObj);
}
} // end for loop
}
@@ -10744,7 +10744,7 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
}
int actualLengthInBytes;
- switch (metadata.BaseTI.MetaType.NullableType)
+ switch (metadata.baseTI.metaType.NullableType)
{
case TdsEnums.SQLBIGBINARY:
case TdsEnums.SQLBIGVARBINARY:
@@ -10759,11 +10759,11 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
// to report the size of data to be copied out (for serialization). If we underreport the
// size, truncation will happen for us!
actualLengthInBytes = (isSqlType) ? ((SqlBinary)value).Length : ((byte[])value).Length;
- if (metadata.BaseTI.Length > 0 &&
- actualLengthInBytes > metadata.BaseTI.Length)
+ if (metadata.baseTI.length > 0 &&
+ actualLengthInBytes > metadata.baseTI.length)
{
// see comments above
- actualLengthInBytes = metadata.BaseTI.Length;
+ actualLengthInBytes = metadata.baseTI.length;
}
break;
@@ -10782,10 +10782,10 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
actualLengthInBytes = _defaultEncoding.GetByteCount(stringValue);
// If the string length is > max length, then use the max length (see comments above)
- if (metadata.BaseTI.Length > 0 &&
- actualLengthInBytes > metadata.BaseTI.Length)
+ if (metadata.baseTI.length > 0 &&
+ actualLengthInBytes > metadata.baseTI.length)
{
- actualLengthInBytes = metadata.BaseTI.Length; // this ensure truncation!
+ actualLengthInBytes = metadata.baseTI.length; // this ensure truncation!
}
break;
@@ -10794,16 +10794,16 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
case TdsEnums.SQLNTEXT:
actualLengthInBytes = ((isSqlType) ? ((SqlString)value).Value.Length : ((string)value).Length) * 2;
- if (metadata.BaseTI.Length > 0 &&
- actualLengthInBytes > metadata.BaseTI.Length)
+ if (metadata.baseTI.length > 0 &&
+ actualLengthInBytes > metadata.baseTI.length)
{ // see comments above
- actualLengthInBytes = metadata.BaseTI.Length;
+ actualLengthInBytes = metadata.baseTI.length;
}
break;
default:
- actualLengthInBytes = metadata.BaseTI.Length;
+ actualLengthInBytes = metadata.baseTI.length;
break;
}
@@ -10812,28 +10812,28 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
{
// SqlType
serializedValue = SerializeUnencryptedSqlValue(value,
- metadata.BaseTI.MetaType,
+ metadata.baseTI.metaType,
actualLengthInBytes,
offset: 0,
- normalizationVersion: metadata.CipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
else
{
serializedValue = SerializeUnencryptedValue(value,
- metadata.BaseTI.MetaType,
- metadata.BaseTI.Scale,
+ metadata.baseTI.metaType,
+ metadata.baseTI.scale,
actualLengthInBytes,
offset: 0,
isDataFeed: isDataFeed,
- normalizationVersion: metadata.CipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
Debug.Assert(serializedValue != null, "serializedValue should not be null in TdsExecuteRPC.");
return SqlSecurityUtility.EncryptWithKey(
serializedValue,
- metadata.CipherMD,
+ metadata.cipherMD,
_connHandler.Connection,
null);
}
@@ -10856,24 +10856,24 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
}
try
{
- if (metadata.Encoding != null)
+ if (metadata.encoding != null)
{
- _defaultEncoding = metadata.Encoding;
+ _defaultEncoding = metadata.encoding;
}
- if (metadata.Collation != null)
+ if (metadata.collation != null)
{
// Replace encoding if it is UTF8
- if (metadata.Collation.IsUTF8)
+ if (metadata.collation.IsUTF8)
{
_defaultEncoding = Encoding.UTF8;
}
- _defaultCollation = metadata.Collation;
+ _defaultCollation = metadata.collation;
_defaultLCID = _defaultCollation.LCID;
}
- _defaultCodePage = metadata.CodePage;
+ _defaultCodePage = metadata.codePage;
- MetaType metatype = metadata.MetaType;
+ MetaType metatype = metadata.metaType;
int ccb = 0;
int ccbStringBytes = 0;
@@ -10944,7 +10944,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
break;
default:
- ccb = metadata.Length;
+ ccb = metadata.length;
break;
}
}
@@ -10968,7 +10968,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
case SqlDbType.NText:
case SqlDbType.Image:
stateObj.WriteByteArray(s_longDataHeader, s_longDataHeader.Length, 0);
- WriteTokenLength(metadata.TdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
+ WriteTokenLength(metadata.tdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
break;
case SqlDbType.VarChar:
@@ -10983,7 +10983,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
}
else
{
- WriteTokenLength(metadata.TdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
+ WriteTokenLength(metadata.tdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
}
if (isSqlType)
@@ -10992,7 +10992,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
}
else if (metatype.SqlDbType != SqlDbType.Udt || metatype.IsLong)
{
- internalWriteTask = WriteValue(value, metatype, metadata.Scale, ccb, ccbStringBytes, 0, stateObj, metadata.Length, isDataFeed);
+ internalWriteTask = WriteValue(value, metatype, metadata.scale, ccb, ccbStringBytes, 0, stateObj, metadata.length, isDataFeed);
if ((internalWriteTask == null) && (_asyncWrite))
{
internalWriteTask = stateObj.WaitForAccumulatedWrites();
@@ -12901,7 +12901,7 @@ internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPr
if (stateObj._plpdecoder == null)
{
- Encoding enc = metadata.Encoding;
+ Encoding enc = metadata.encoding;
if (enc == null)
{
@@ -13048,7 +13048,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
{
return result;
}
- metaData.Length = shortLength;
+ metaData.length = shortLength;
// database name
result = stateObj.TryReadByte(out byteLength);
@@ -13056,13 +13056,13 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
{
return result;
}
- if (metaData.Udt is null)
+ if (metaData.udt is null)
{
- metaData.Udt = new SqlMetaDataUdt();
+ metaData.udt = new SqlMetaDataUdt();
}
if (byteLength != 0)
{
- result = stateObj.TryReadString(byteLength, out metaData.Udt.DatabaseName);
+ result = stateObj.TryReadString(byteLength, out metaData.udt.DatabaseName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -13077,7 +13077,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
}
if (byteLength != 0)
{
- result = stateObj.TryReadString(byteLength, out metaData.Udt.SchemaName);
+ result = stateObj.TryReadString(byteLength, out metaData.udt.SchemaName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -13092,7 +13092,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
}
if (byteLength != 0)
{
- result = stateObj.TryReadString(byteLength, out metaData.Udt.TypeName);
+ result = stateObj.TryReadString(byteLength, out metaData.udt.TypeName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -13106,7 +13106,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
}
if (shortLength != 0)
{
- result = stateObj.TryReadString(shortLength, out metaData.Udt.AssemblyQualifiedName);
+ result = stateObj.TryReadString(shortLength, out metaData.udt.AssemblyQualifiedName);
if (result != TdsOperationStatus.Done)
{
return result;
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
index 6141a5dc8d..0f43f46da1 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs
@@ -591,7 +591,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
rejectColumn = false;
// Check for excluded types
- if ((metadata.Type == SqlDbType.Timestamp)
+ if ((metadata.type == SqlDbType.Timestamp)
|| ((metadata.IsIdentity) && !IsCopyOption(SqlBulkCopyOptions.KeepIdentity)))
{
// Remove metadata for excluded columns
@@ -604,8 +604,8 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
int assocId;
for (assocId = 0; assocId < _localColumnMappings.Count; assocId++)
{
- if ((_localColumnMappings[assocId]._destinationColumnOrdinal == metadata.Ordinal) ||
- (UnquotedName(_localColumnMappings[assocId]._destinationColumnName) == metadata.Column))
+ if ((_localColumnMappings[assocId]._destinationColumnOrdinal == metadata.ordinal) ||
+ (UnquotedName(_localColumnMappings[assocId]._destinationColumnName) == metadata.column))
{
if (rejectColumn)
{
@@ -614,7 +614,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
_sortedColumnMappings.Add(new _ColumnMapping(_localColumnMappings[assocId]._internalSourceColumnOrdinal, metadata));
- destColumnNames.Add(metadata.Column);
+ destColumnNames.Add(metadata.column);
nmatched++;
if (nmatched > 1)
@@ -623,25 +623,25 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
// Some datatypes need special handling ...
- if (metadata.Type == SqlDbType.Variant)
+ if (metadata.type == SqlDbType.Variant)
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.Column, "sql_variant");
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, "sql_variant");
}
- else if (metadata.Type == SqlDbType.Udt)
+ else if (metadata.type == SqlDbType.Udt)
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.Column, "varbinary");
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, "varbinary");
}
else
{
- AppendColumnNameAndTypeName(updateBulkCommandText, metadata.Column, typeof(SqlDbType).GetEnumName(metadata.Type));
+ AppendColumnNameAndTypeName(updateBulkCommandText, metadata.column, typeof(SqlDbType).GetEnumName(metadata.type));
}
- switch (metadata.MetaType.NullableType)
+ switch (metadata.metaType.NullableType)
{
case TdsEnums.SQLNUMERICN:
case TdsEnums.SQLDECIMALN:
// Decimal and numeric need to include precision and scale
- updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0},{1})", metadata.Precision, metadata.Scale);
+ updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0},{1})", metadata.precision, metadata.scale);
break;
case TdsEnums.SQLUDT:
{
@@ -651,7 +651,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
else
{
- int size = metadata.Length;
+ int size = metadata.length;
updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", size);
}
break;
@@ -660,15 +660,15 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
case TdsEnums.SQLDATETIME2:
case TdsEnums.SQLDATETIMEOFFSET:
// date, dateime2, and datetimeoffset need to include scale
- updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", metadata.Scale);
+ updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", metadata.scale);
break;
default:
{
// For non-long non-fixed types we need to add the Size
- if (!metadata.MetaType.IsFixed && !metadata.MetaType.IsLong)
+ if (!metadata.metaType.IsFixed && !metadata.metaType.IsLong)
{
- int size = metadata.Length;
- switch (metadata.MetaType.NullableType)
+ int size = metadata.length;
+ switch (metadata.metaType.NullableType)
{
case TdsEnums.SQLNCHAR:
case TdsEnums.SQLNVARCHAR:
@@ -680,7 +680,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
}
updateBulkCommandText.AppendFormat((IFormatProvider)null, "({0})", size);
}
- else if (metadata.MetaType.IsPlp && metadata.MetaType.SqlDbType != SqlDbType.Xml)
+ else if (metadata.metaType.IsPlp && metadata.metaType.SqlDbType != SqlDbType.Xml)
{
// Partial length column prefix (max)
updateBulkCommandText.Append("(max)");
@@ -698,7 +698,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
object rowvalue = rowset[i][CollationId];
bool shouldSendCollation;
- switch (metadata.Type)
+ switch (metadata.type)
{
case SqlDbType.Char:
case SqlDbType.NChar:
@@ -723,15 +723,15 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
{
updateBulkCommandText.Append(" COLLATE " + collation_name.Value);
// VSTFDEVDIV 461426: compare collations only if the collation value was set on the metadata
- if (_sqlDataReaderRowSource != null && metadata.Collation != null)
+ if (_sqlDataReaderRowSource != null && metadata.collation != null)
{
// On SqlDataReader we can verify the sourcecolumn collation!
int sourceColumnId = _localColumnMappings[assocId]._internalSourceColumnOrdinal;
- int destinationLcid = metadata.Collation.LCID;
+ int destinationLcid = metadata.collation.LCID;
int sourceLcid = _sqlDataReaderRowSource.GetLocaleId(sourceColumnId);
if (sourceLcid != destinationLcid)
{
- throw SQL.BulkLoadLcidMismatch(sourceLcid, _sqlDataReaderRowSource.GetName(sourceColumnId), destinationLcid, metadata.Column);
+ throw SQL.BulkLoadLcidMismatch(sourceLcid, _sqlDataReaderRowSource.GetName(sourceColumnId), destinationLcid, metadata.column);
}
}
}
@@ -1000,7 +1000,7 @@ private object GetValueFromSourceRow(int destRowIndex, out bool isSqlType, out b
object value = _sqlDataReaderRowSource.GetValue(sourceOrdinal);
isNull = ((value == null) || (value == DBNull.Value));
- if ((!isNull) && (metadata.Type == SqlDbType.Udt))
+ if ((!isNull) && (metadata.type == SqlDbType.Udt))
{
var columnAsINullable = value as INullable;
isNull = (columnAsINullable != null) && columnAsINullable.IsNull;
@@ -1211,7 +1211,7 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
bool isSqlType;
bool isDataFeed;
- if (((_sqlDataReaderRowSource != null) || (_dataTableSource != null)) && ((metadata.MetaType.NullableType == TdsEnums.SQLDECIMALN) || (metadata.MetaType.NullableType == TdsEnums.SQLNUMERICN)))
+ if (((_sqlDataReaderRowSource != null) || (_dataTableSource != null)) && ((metadata.metaType.NullableType == TdsEnums.SQLDECIMALN) || (metadata.metaType.NullableType == TdsEnums.SQLNUMERICN)))
{
isDataFeed = false;
@@ -1254,28 +1254,28 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
}
// Check for data streams
- else if ((_enableStreaming) && (metadata.Length == MAX_LENGTH) && (!_rowSourceIsSqlDataReaderSmi))
+ else if ((_enableStreaming) && (metadata.length == MAX_LENGTH) && (!_rowSourceIsSqlDataReaderSmi))
{
isSqlType = false;
if (_sqlDataReaderRowSource != null)
{
// MetaData property is not set for SMI, but since streaming is disabled we do not need it
- MetaType mtSource = _sqlDataReaderRowSource.MetaData[sourceOrdinal].MetaType;
+ MetaType mtSource = _sqlDataReaderRowSource.MetaData[sourceOrdinal].metaType;
// There is no memory gain for non-sequential access for binary
- if ((metadata.Type == SqlDbType.VarBinary) && (mtSource.IsBinType) && (mtSource.SqlDbType != SqlDbType.Timestamp) && _sqlDataReaderRowSource.IsCommandBehavior(CommandBehavior.SequentialAccess))
+ if ((metadata.type == SqlDbType.VarBinary) && (mtSource.IsBinType) && (mtSource.SqlDbType != SqlDbType.Timestamp) && _sqlDataReaderRowSource.IsCommandBehavior(CommandBehavior.SequentialAccess))
{
isDataFeed = true;
method = ValueMethod.DataFeedStream;
}
// For text and XML there is memory gain from streaming on destination side even if reader is non-sequential
- else if (((metadata.Type == SqlDbType.VarChar) || (metadata.Type == SqlDbType.NVarChar)) && (mtSource.IsCharType) && (mtSource.SqlDbType != SqlDbType.Xml))
+ else if (((metadata.type == SqlDbType.VarChar) || (metadata.type == SqlDbType.NVarChar)) && (mtSource.IsCharType) && (mtSource.SqlDbType != SqlDbType.Xml))
{
isDataFeed = true;
method = ValueMethod.DataFeedText;
}
- else if ((metadata.Type == SqlDbType.Xml) && (mtSource.SqlDbType == SqlDbType.Xml))
+ else if ((metadata.type == SqlDbType.Xml) && (mtSource.SqlDbType == SqlDbType.Xml))
{
isDataFeed = true;
method = ValueMethod.DataFeedXml;
@@ -1288,12 +1288,12 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal)
}
else if (_dbDataReaderRowSource != null)
{
- if (metadata.Type == SqlDbType.VarBinary)
+ if (metadata.type == SqlDbType.VarBinary)
{
isDataFeed = true;
method = ValueMethod.DataFeedStream;
}
- else if ((metadata.Type == SqlDbType.VarChar) || (metadata.Type == SqlDbType.NVarChar))
+ else if ((metadata.type == SqlDbType.VarChar) || (metadata.type == SqlDbType.NVarChar))
{
isDataFeed = true;
method = ValueMethod.DataFeedText;
@@ -1497,28 +1497,28 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
if (!metadata.IsNullable)
{
- throw SQL.BulkLoadBulkLoadNotAllowDBNull(metadata.Column);
+ throw SQL.BulkLoadBulkLoadNotAllowDBNull(metadata.column);
}
return value;
}
- MetaType type = metadata.MetaType;
+ MetaType type = metadata.metaType;
bool typeChanged = false;
// If the column is encrypted then we are going to transparently encrypt this column
// (based on connection string setting)- Use the metaType for the underlying
// value (unencrypted value) for conversion/casting purposes (below).
// Note - this flag is set if connection string options has TCE turned on
- byte scale = metadata.Scale;
- byte precision = metadata.Precision;
- int length = metadata.Length;
- if (metadata.IsEncrypted)
+ byte scale = metadata.scale;
+ byte precision = metadata.precision;
+ int length = metadata.length;
+ if (metadata.isEncrypted)
{
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- type = metadata.BaseTI.MetaType;
- scale = metadata.BaseTI.Scale;
- precision = metadata.BaseTI.Precision;
- length = metadata.BaseTI.Length;
+ type = metadata.baseTI.metaType;
+ scale = metadata.baseTI.scale;
+ precision = metadata.baseTI.precision;
+ length = metadata.baseTI.length;
}
try
@@ -1559,11 +1559,11 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
}
catch (SqlTruncateException)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), ADP.ParameterValueOutOfRange(sqlValue));
}
catch (Exception e)
{
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), mt, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), e);
}
}
@@ -1608,7 +1608,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
int maxStringLength = length / 2;
if (str.Length > maxStringLength)
{
- if (metadata.IsEncrypted)
+ if (metadata.isEncrypted)
{
str = "";
}
@@ -1618,7 +1618,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
// https://blogs.msdn.microsoft.com/sql_server_team/string-or-binary-data-would-be-truncated-replacing-the-infamous-error-8152/
str = str.Remove(Math.Min(maxStringLength, 100));
}
- throw SQL.BulkLoadStringTooLong(_destinationTableName, metadata.Column, str);
+ throw SQL.BulkLoadStringTooLong(_destinationTableName, metadata.column, str);
}
}
break;
@@ -1652,7 +1652,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
default:
Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), null);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), null);
}
if (typeChanged)
@@ -1669,7 +1669,7 @@ private object ConvertValue(object value, _SqlMetaData metadata, bool isNull, re
{
throw;
}
- throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.Ordinal, RowNumber, metadata.IsEncrypted, metadata.Column, value.ToString(), e);
+ throw SQL.BulkLoadCannotConvertValue(value.GetType(), type, metadata.ordinal, RowNumber, metadata.isEncrypted, metadata.column, value.ToString(), e);
}
}
@@ -2268,17 +2268,17 @@ private Task ReadWriteColumnValueAsync(int col)
// If column encryption is requested via connection string option, perform encryption here
if (!isNull && // if value is not NULL
- metadata.IsEncrypted)
+ metadata.isEncrypted)
{ // If we are transparently encrypting
Debug.Assert(_parser.ShouldEncryptValuesForBulkCopy());
- value = _parser.EncryptColumnValue(value, metadata, metadata.Column, _stateObj, isDataFeed, isSqlType);
+ value = _parser.EncryptColumnValue(value, metadata, metadata.column, _stateObj, isDataFeed, isSqlType);
isSqlType = false; // Its not a sql type anymore
}
}
//write part
Task writeTask = null;
- if (metadata.Type != SqlDbType.Variant)
+ if (metadata.type != SqlDbType.Variant)
{
//this is the most common path
writeTask = _parser.WriteBulkCopyValue(value, metadata, _stateObj, isSqlType, isDataFeed, isNull); //returns Task/Null
@@ -2286,7 +2286,7 @@ private Task ReadWriteColumnValueAsync(int col)
else
{
// Target type shouldn't be encrypted
- Debug.Assert(!metadata.IsEncrypted, "Can't encrypt SQL Variant type");
+ Debug.Assert(!metadata.isEncrypted, "Can't encrypt SQL Variant type");
SqlBuffer.StorageType variantInternalType = SqlBuffer.StorageType.Empty;
if ((_sqlDataReaderRowSource != null) && (_connection.Is2008OrNewer))
{
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs
index 91cab3ceb3..ba860f106f 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs
@@ -4562,9 +4562,9 @@ private SqlDataReader TryFetchInputParameterEncryptionInfo(int timeout,
{
// In _batchRPCMode, the actual T-SQL query is in the first parameter and not present as the rpcName, as is the case with non-_batchRPCMode.
// So input parameters start at parameters[1]. parameters[0] is the actual T-SQL Statement. rpcName is sp_executesql.
- if (_RPCList[i].SystemParams.Length > 1)
+ if (_RPCList[i].systemParams.Length > 1)
{
- _RPCList[i].NeedsFetchParameterEncryptionMetadata = true;
+ _RPCList[i].needsFetchParameterEncryptionMetadata = true;
// Since we are going to need multiple RPC objects, allocate a new one here for each command in the batch.
_SqlRPC rpcDescribeParameterEncryptionRequest = new _SqlRPC();
@@ -4611,8 +4611,8 @@ private SqlDataReader TryFetchInputParameterEncryptionInfo(int timeout,
GetRPCObject(0, GetParameterCount(_parameters), ref rpc);
Debug.Assert(rpc != null, "GetRPCObject should not return rpc as null.");
- rpc.RpcName = CommandText;
- rpc.UserParams = _parameters;
+ rpc.rpcName = CommandText;
+ rpc.userParams = _parameters;
// Prepare the RPC request for describe parameter encryption procedure.
PrepareDescribeParameterEncryptionRequest(rpc, ref _sqlRPCParameterEncryptionReqArray[0], serializedAttestationParameters);
@@ -4679,7 +4679,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// sp_describe_parameter_encryption always has 2 parameters (stmt, paramlist).
//sp_describe_parameter_encryption can have an optional 3rd parameter (attestationParametes), used to identify and execute attestation protocol
GetRPCObject(attestationParameters == null ? 2 : 3, 0, ref describeParameterEncryptionRequest, forSpDescribeParameterEncryption: true);
- describeParameterEncryptionRequest.RpcName = "sp_describe_parameter_encryption";
+ describeParameterEncryptionRequest.rpcName = "sp_describe_parameter_encryption";
// Prepare @tsql parameter
string text;
@@ -4687,11 +4687,11 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// In _batchRPCMode, The actual T-SQL query is in the first parameter and not present as the rpcName, as is the case with non-_batchRPCMode.
if (_batchRPCMode)
{
- Debug.Assert(originalRpcRequest.SystemParamCount > 0,
+ Debug.Assert(originalRpcRequest.systemParamCount > 0,
"originalRpcRequest didn't have at-least 1 parameter in BatchRPCMode, in PrepareDescribeParameterEncryptionRequest.");
- text = (string)originalRpcRequest.SystemParams[0].Value;
+ text = (string)originalRpcRequest.systemParams[0].Value;
//@tsql
- SqlParameter tsqlParam = describeParameterEncryptionRequest.SystemParams[0];
+ SqlParameter tsqlParam = describeParameterEncryptionRequest.systemParams[0];
tsqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
tsqlParam.Value = text;
tsqlParam.Size = text.Length;
@@ -4699,17 +4699,17 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
}
else
{
- text = originalRpcRequest.RpcName;
+ text = originalRpcRequest.rpcName;
if (CommandType == CommandType.StoredProcedure)
{
// For stored procedures, we need to prepare @tsql in the following format
// N'EXEC sp_name @param1=@param1, @param1=@param2, ..., @paramN=@paramN'
- describeParameterEncryptionRequest.SystemParams[0] = BuildStoredProcedureStatementForColumnEncryption(text, originalRpcRequest.UserParams);
+ describeParameterEncryptionRequest.systemParams[0] = BuildStoredProcedureStatementForColumnEncryption(text, originalRpcRequest.userParams);
}
else
{
//@tsql
- SqlParameter tsqlParam = describeParameterEncryptionRequest.SystemParams[0];
+ SqlParameter tsqlParam = describeParameterEncryptionRequest.systemParams[0];
tsqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
tsqlParam.Value = text;
tsqlParam.Size = text.Length;
@@ -4725,9 +4725,9 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// And it is already in the format expected out of BuildParamList, which is not the case with Non-_batchRPCMode.
if (_batchRPCMode)
{
- if (originalRpcRequest.SystemParamCount > 1)
+ if (originalRpcRequest.systemParamCount > 1)
{
- parameterList = (string)originalRpcRequest.SystemParams[1].Value;
+ parameterList = (string)originalRpcRequest.systemParams[1].Value;
}
}
else
@@ -4736,11 +4736,11 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
// Need to create new parameters as we cannot have the same parameter being part of two SqlCommand objects
SqlParameterCollection tempCollection = new SqlParameterCollection();
- if (originalRpcRequest.UserParams != null)
+ if (originalRpcRequest.userParams != null)
{
- for (int i = 0; i < originalRpcRequest.UserParams.Count; i++)
+ for (int i = 0; i < originalRpcRequest.userParams.Count; i++)
{
- SqlParameter param = originalRpcRequest.UserParams[i];
+ SqlParameter param = originalRpcRequest.userParams[i];
SqlParameter paramCopy = new SqlParameter(
param.ParameterName,
param.SqlDbType,
@@ -4784,7 +4784,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
parameterList = BuildParamList(tdsParser, tempCollection, includeReturnValue: true);
}
- SqlParameter paramsParam = describeParameterEncryptionRequest.SystemParams[1];
+ SqlParameter paramsParam = describeParameterEncryptionRequest.systemParams[1];
paramsParam.SqlDbType = ((parameterList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
paramsParam.Size = parameterList.Length;
paramsParam.Value = parameterList;
@@ -4792,7 +4792,7 @@ private void PrepareDescribeParameterEncryptionRequest(_SqlRPC originalRpcReques
if (attestationParameters != null)
{
- SqlParameter attestationParametersParam = describeParameterEncryptionRequest.SystemParams[2];
+ SqlParameter attestationParametersParam = describeParameterEncryptionRequest.systemParams[2];
attestationParametersParam.SqlDbType = SqlDbType.VarBinary;
attestationParametersParam.Size = attestationParameters.Length;
attestationParametersParam.Value = attestationParameters;
@@ -4971,7 +4971,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
Debug.Assert(rpc != null, "rpc should not be null here.");
- int userParamCount = rpc.UserParams?.Count ?? 0;
+ int userParamCount = rpc.userParams?.Count ?? 0;
int recievedMetadataCount = 0;
if (!enclaveMetadataExists || ds.NextResult())
@@ -4989,7 +4989,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
// Null is used to indicate the end of the valid part of the array. Refer to GetRPCObject().
for (int index = 0; index < userParamCount; index++)
{
- SqlParameter sqlParameter = rpc.UserParams[index];
+ SqlParameter sqlParameter = rpc.userParams[index];
Debug.Assert(sqlParameter != null, "sqlParameter should not be null.");
if (SqlParameter.ParameterNamesEqual(sqlParameter.ParameterName, parameterName, StringComparison.Ordinal))
@@ -5024,9 +5024,9 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
// This is effective only for BatchRPCMode even though we set it for non-BatchRPCMode also,
// since for non-BatchRPCMode mode, paramoptions gets thrown away and reconstructed in BuildExecuteSql.
- int options = (int)(rpc.UserParamMap[index] >> 32);
+ int options = (int)(rpc.userParamMap[index] >> 32);
options |= TdsEnums.RPC_PARAM_ENCRYPTED;
- rpc.UserParamMap[index] = ((((long)options) << 32) | (long)index);
+ rpc.userParamMap[index] = ((((long)options) << 32) | (long)index);
}
break;
@@ -5041,7 +5041,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
for (int index = 0; index < userParamCount; index++)
{
- SqlParameter sqlParameter = rpc.UserParams[index];
+ SqlParameter sqlParameter = rpc.userParams[index];
if (!sqlParameter.HasReceivedMetadata && sqlParameter.Direction != ParameterDirection.ReturnValue)
{
// Encryption MD wasn't sent by the server - we expect the metadata to be sent for all the parameters
@@ -5102,7 +5102,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
}
// The server has responded with encryption related information for this rpc request. So clear the needsFetchParameterEncryptionMetadata flag.
- rpc.NeedsFetchParameterEncryptionMetadata = false;
+ rpc.needsFetchParameterEncryptionMetadata = false;
} while (ds.NextResult());
// Verify that we received response for each rpc call needs tce
@@ -5110,9 +5110,9 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
for (int i = 0; i < _RPCList.Count; i++)
{
- if (_RPCList[i].NeedsFetchParameterEncryptionMetadata)
+ if (_RPCList[i].needsFetchParameterEncryptionMetadata)
{
- throw SQL.ProcEncryptionMetadataMissing(_RPCList[i].RpcName);
+ throw SQL.ProcEncryptionMetadataMissing(_RPCList[i].rpcName);
}
}
}
@@ -5576,7 +5576,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi
// if 2000, then set NOMETADATA_UNLESSCHANGED flag
if (_activeConnection.Is2000)
- rpc.Options = TdsEnums.RPC_NOMETADATA;
+ rpc.options = TdsEnums.RPC_NOMETADATA;
if (returnStream)
{
SqlClientEventSource.Log.TryTraceEvent(" {0}, Command executed as RPC.", ObjectID);
@@ -6211,29 +6211,29 @@ private static void OnDone(TdsParserStateObject stateObj, int index, IList<_SqlR
// track the records affected for the just completed rpc batch
// _rowsAffected is cumulative for ExecuteNonQuery across all rpc batches
- current.CumulativeRecordsAffected = rowsAffected;
+ current.cumulativeRecordsAffected = rowsAffected;
- current.RecordsAffected =
+ current.recordsAffected =
(((previous != null) && (0 <= rowsAffected))
- ? (rowsAffected - Math.Max(previous.CumulativeRecordsAffected, 0))
+ ? (rowsAffected - Math.Max(previous.cumulativeRecordsAffected, 0))
: rowsAffected);
- if (current.BatchCommand != null)
+ if (current.batchCommand != null)
{
- current.BatchCommand.SetRecordAffected(current.RecordsAffected.GetValueOrDefault());
+ current.batchCommand.SetRecordAffected(current.recordsAffected.GetValueOrDefault());
}
// track the error collection (not available from TdsParser after ExecuteNonQuery)
// and the which errors are associated with the just completed rpc batch
- current.ErrorsIndexStart = previous?.ErrorsIndexEnd ?? 0;
- current.ErrorsIndexEnd = stateObj.ErrorCount;
- current.Errors = stateObj._errors;
+ current.errorsIndexStart = previous?.errorsIndexEnd ?? 0;
+ current.errorsIndexEnd = stateObj.ErrorCount;
+ current.errors = stateObj._errors;
// track the warning collection (not available from TdsParser after ExecuteNonQuery)
// and the which warnings are associated with the just completed rpc batch
- current.WarningsIndexStart = previous?.WarningsIndexEnd ?? 0;
- current.WarningsIndexEnd = stateObj.WarningCount;
- current.Warnings = stateObj._warnings;
+ current.warningsIndexStart = previous?.warningsIndexEnd ?? 0;
+ current.warningsIndexEnd = stateObj.WarningCount;
+ current.warnings = stateObj._warnings;
}
//
@@ -6254,7 +6254,7 @@ internal void OnReturnStatus(int status)
{
if (_RPCList.Count > _currentlyExecutingBatch)
{
- parameters = _RPCList[_currentlyExecutingBatch].UserParams;
+ parameters = _RPCList[_currentlyExecutingBatch].userParams;
}
else
{
@@ -6305,9 +6305,9 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
{
if (_inPrepare)
{
- if (!rec.Value.IsNull)
+ if (!rec.value.IsNull)
{
- _prepareHandle = rec.Value.Int32;
+ _prepareHandle = rec.value.Int32;
}
_inPrepare = false;
return;
@@ -6316,21 +6316,21 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
SqlParameterCollection parameters = GetCurrentParameterCollection();
int count = GetParameterCount(parameters);
- SqlParameter thisParam = GetParameterForOutputValueExtraction(parameters, rec.Parameter, count);
+ SqlParameter thisParam = GetParameterForOutputValueExtraction(parameters, rec.parameter, count);
if (thisParam != null)
{
// If the parameter's direction is InputOutput, Output or ReturnValue and it needs to be transparently encrypted/decrypted
// then simply decrypt, deserialize and set the value.
- if (rec.CipherMD != null &&
+ if (rec.cipherMD != null &&
thisParam.CipherMetadata != null &&
(thisParam.Direction == ParameterDirection.Output ||
thisParam.Direction == ParameterDirection.InputOutput ||
thisParam.Direction == ParameterDirection.ReturnValue))
{
- if (rec.TdsType != TdsEnums.SQLBIGVARBINARY)
+ if (rec.tdsType != TdsEnums.SQLBIGVARBINARY)
{
- throw SQL.InvalidDataTypeForEncryptedParameter(thisParam.GetPrefixedParameterName(), rec.TdsType, TdsEnums.SQLBIGVARBINARY);
+ throw SQL.InvalidDataTypeForEncryptedParameter(thisParam.GetPrefixedParameterName(), rec.tdsType, TdsEnums.SQLBIGVARBINARY);
}
// Decrypt the ciphertext
@@ -6340,15 +6340,15 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
throw ADP.ClosedConnectionError();
}
- if (!rec.Value.IsNull)
+ if (!rec.value.IsNull)
{
try
{
Debug.Assert(_activeConnection != null, @"_activeConnection should not be null");
// Get the key information from the parameter and decrypt the value.
- rec.CipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.Value.ByteArray, rec.CipherMD, _activeConnection, this);
+ rec.cipherMD.EncryptionInfo = thisParam.CipherMetadata.EncryptionInfo;
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(rec.value.ByteArray, rec.cipherMD, _activeConnection, this);
if (unencryptedBytes != null)
{
@@ -6392,13 +6392,13 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
Connection.CheckGetExtendedUDTInfo(rec, true);
//extract the byte array from the param value
- if (rec.Value.IsNull)
+ if (rec.value.IsNull)
{
data = DBNull.Value;
}
else
{
- data = rec.Value.ByteArray; //should work for both sql and non-sql values
+ data = rec.value.ByteArray; //should work for both sql and non-sql values
}
//call the connection to instantiate the UDT object
@@ -6421,21 +6421,21 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
}
else
{
- thisParam.SetSqlBuffer(rec.Value);
+ thisParam.SetSqlBuffer(rec.value);
}
- MetaType mt = MetaType.GetMetaTypeFromSqlDbType(rec.Type, rec.IsMultiValued);
+ MetaType mt = MetaType.GetMetaTypeFromSqlDbType(rec.type, rec.IsMultiValued);
- if (rec.Type == SqlDbType.Decimal)
+ if (rec.type == SqlDbType.Decimal)
{
- thisParam.ScaleInternal = rec.Scale;
- thisParam.PrecisionInternal = rec.Precision;
+ thisParam.ScaleInternal = rec.scale;
+ thisParam.PrecisionInternal = rec.precision;
}
else if (mt.IsVarTime)
{
- thisParam.ScaleInternal = rec.Scale;
+ thisParam.ScaleInternal = rec.scale;
}
- else if (rec.Type == SqlDbType.Xml)
+ else if (rec.type == SqlDbType.Xml)
{
SqlCachedBuffer cachedBuffer = (thisParam.Value as SqlCachedBuffer);
if (cachedBuffer != null)
@@ -6444,10 +6444,10 @@ internal void OnReturnValue(SqlReturnValue rec, TdsParserStateObject stateObj)
}
}
- if (rec.Collation != null)
+ if (rec.collation != null)
{
Debug.Assert(mt.IsCharType, "Invalid collation structure for non-char type");
- thisParam.Collation = rec.Collation;
+ thisParam.Collation = rec.collation;
}
}
}
@@ -6513,7 +6513,7 @@ private SqlParameterCollection GetCurrentParameterCollection()
{
if (_RPCList.Count > _currentlyExecutingBatch)
{
- return _RPCList[_currentlyExecutingBatch].UserParams;
+ return _RPCList[_currentlyExecutingBatch].userParams;
}
else
{
@@ -6597,44 +6597,44 @@ private void GetRPCObject(int systemParamCount, int userParamCount, ref _SqlRPC
}
}
- rpc.ProcId = 0;
- rpc.RpcName = null;
- rpc.Options = 0;
- rpc.SystemParamCount = systemParamCount;
+ rpc.ProcID = 0;
+ rpc.rpcName = null;
+ rpc.options = 0;
+ rpc.systemParamCount = systemParamCount;
- rpc.RecordsAffected = default(int?);
- rpc.CumulativeRecordsAffected = -1;
+ rpc.recordsAffected = default(int?);
+ rpc.cumulativeRecordsAffected = -1;
- rpc.ErrorsIndexStart = 0;
- rpc.ErrorsIndexEnd = 0;
- rpc.Errors = null;
+ rpc.errorsIndexStart = 0;
+ rpc.errorsIndexEnd = 0;
+ rpc.errors = null;
- rpc.WarningsIndexStart = 0;
- rpc.WarningsIndexEnd = 0;
- rpc.Warnings = null;
- rpc.NeedsFetchParameterEncryptionMetadata = false;
+ rpc.warningsIndexStart = 0;
+ rpc.warningsIndexEnd = 0;
+ rpc.warnings = null;
+ rpc.needsFetchParameterEncryptionMetadata = false;
- int currentCount = rpc.SystemParams?.Length ?? 0;
+ int currentCount = rpc.systemParams?.Length ?? 0;
// Make sure there is enough space in the parameters and paramoptions arrays
if (currentCount < systemParamCount)
{
- Array.Resize(ref rpc.SystemParams, systemParamCount);
- Array.Resize(ref rpc.SystemParamOptions, systemParamCount);
+ Array.Resize(ref rpc.systemParams, systemParamCount);
+ Array.Resize(ref rpc.systemParamOptions, systemParamCount);
for (int index = currentCount; index < systemParamCount; index++)
{
- rpc.SystemParams[index] = new SqlParameter();
+ rpc.systemParams[index] = new SqlParameter();
}
}
for (int ii = 0; ii < systemParamCount; ii++)
{
- rpc.SystemParamOptions[ii] = 0;
+ rpc.systemParamOptions[ii] = 0;
}
- if ((rpc.UserParamMap?.Length ?? 0) < userParamCount)
+ if ((rpc.userParamMap?.Length ?? 0) < userParamCount)
{
- Array.Resize(ref rpc.UserParamMap, userParamCount);
+ Array.Resize(ref rpc.userParamMap, userParamCount);
}
}
@@ -6702,15 +6702,15 @@ private void SetUpRPCParameters(_SqlRPC rpc, bool inSchema, SqlParameterCollecti
}
}
- rpc.UserParamMap[userParamCount] = ((((long)options) << 32) | (long)index);
+ rpc.userParamMap[userParamCount] = ((((long)options) << 32) | (long)index);
userParamCount += 1;
// Must set parameter option bit for LOB_COOKIE if unfilled LazyMat blob
}
}
- rpc.UserParamCount = userParamCount;
- rpc.UserParams = parameters;
+ rpc.userParamCount = userParamCount;
+ rpc.userParams = parameters;
}
//
@@ -6729,20 +6729,20 @@ private _SqlRPC BuildPrepExec(CommandBehavior behavior)
_SqlRPC rpc = null;
GetRPCObject(systemParameterCount, userParameterCount, ref rpc);
- rpc.ProcId = TdsEnums.RPC_PROCID_PREPEXEC;
- rpc.RpcName = TdsEnums.SP_PREPEXEC;
+ rpc.ProcID = TdsEnums.RPC_PROCID_PREPEXEC;
+ rpc.rpcName = TdsEnums.SP_PREPEXEC;
//@handle
- sqlParam = rpc.SystemParams[0];
+ sqlParam = rpc.systemParams[0];
sqlParam.SqlDbType = SqlDbType.Int;
sqlParam.Value = _prepareHandle;
sqlParam.Size = 4;
sqlParam.Direction = ParameterDirection.InputOutput;
- rpc.SystemParamOptions[0] = TdsEnums.RPC_PARAM_BYREF;
+ rpc.systemParamOptions[0] = TdsEnums.RPC_PARAM_BYREF;
//@batch_params
string paramList = BuildParamList(_stateObj.Parser, _parameters);
- sqlParam = rpc.SystemParams[1];
+ sqlParam = rpc.systemParams[1];
sqlParam.SqlDbType = ((paramList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Value = paramList;
sqlParam.Size = paramList.Length;
@@ -6750,7 +6750,7 @@ private _SqlRPC BuildPrepExec(CommandBehavior behavior)
//@batch_text
string text = GetCommandText(behavior);
- sqlParam = rpc.SystemParams[2];
+ sqlParam = rpc.systemParams[2];
sqlParam.SqlDbType = ((text.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = text.Length;
sqlParam.Value = text;
@@ -6820,10 +6820,10 @@ private void BuildRPC(bool inSchema, SqlParameterCollection parameters, ref _Sql
// 4-part name 1 + 128 + 1 + 1 + 1 + 128 + 1 + 1 + 1 + 128 + 1 + 1 + 1 + 128 + 1 = 523
// each char takes 2 bytes. 523 * 2 = 1046
int commandTextLength = ADP.CharSize * CommandText.Length;
- rpc.ProcId = 0;
+ rpc.ProcID = 0;
if (commandTextLength <= MaxRPCNameLength)
{
- rpc.RpcName = CommandText; // just get the raw command text
+ rpc.rpcName = CommandText; // just get the raw command text
}
else
{
@@ -6849,11 +6849,11 @@ private _SqlRPC BuildExecute(bool inSchema)
_SqlRPC rpc = null;
GetRPCObject(systemParameterCount, userParameterCount, ref rpc);
- rpc.ProcId = TdsEnums.RPC_PROCID_EXECUTE;
- rpc.RpcName = TdsEnums.SP_EXECUTE;
+ rpc.ProcID = TdsEnums.RPC_PROCID_EXECUTE;
+ rpc.rpcName = TdsEnums.SP_EXECUTE;
//@handle
- SqlParameter sqlParam = rpc.SystemParams[0];
+ SqlParameter sqlParam = rpc.systemParams[0];
sqlParam.SqlDbType = SqlDbType.Int;
sqlParam.Value = _prepareHandle;
sqlParam.Size = 4;
@@ -6887,15 +6887,15 @@ private void BuildExecuteSql(CommandBehavior behavior, string commandText, SqlPa
}
GetRPCObject(systemParamCount, userParamCount, ref rpc);
- rpc.ProcId = TdsEnums.RPC_PROCID_EXECUTESQL;
- rpc.RpcName = TdsEnums.SP_EXECUTESQL;
+ rpc.ProcID = TdsEnums.RPC_PROCID_EXECUTESQL;
+ rpc.rpcName = TdsEnums.SP_EXECUTESQL;
// @sql
if (commandText == null)
{
commandText = GetCommandText(behavior);
}
- sqlParam = rpc.SystemParams[0];
+ sqlParam = rpc.systemParams[0];
sqlParam.SqlDbType = ((commandText.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = commandText.Length;
sqlParam.Value = commandText;
@@ -6904,7 +6904,7 @@ private void BuildExecuteSql(CommandBehavior behavior, string commandText, SqlPa
if (userParamCount > 0)
{
string paramList = BuildParamList(_stateObj.Parser, _batchRPCMode ? parameters : _parameters);
- sqlParam = rpc.SystemParams[1];
+ sqlParam = rpc.systemParams[1];
sqlParam.SqlDbType = ((paramList.Length << 1) <= TdsEnums.TYPE_SIZE_LIMIT) ? SqlDbType.NVarChar : SqlDbType.NText;
sqlParam.Size = paramList.Length;
sqlParam.Value = paramList;
@@ -7446,7 +7446,7 @@ internal void AddBatchCommand(SqlBatchCommand batchCommand)
_SqlRPC rpc = new _SqlRPC
{
- BatchCommand = batchCommand
+ batchCommand = batchCommand
};
string commandText = batchCommand.CommandText;
CommandType cmdType = batchCommand.CommandType;
@@ -7477,24 +7477,24 @@ internal void AddBatchCommand(SqlBatchCommand batchCommand)
{
Debug.Assert(_batchRPCMode, "Command is not in batch RPC Mode");
Debug.Assert(_RPCList != null, "batch command have been cleared");
- return _RPCList[commandIndex].RecordsAffected;
+ return _RPCList[commandIndex].recordsAffected;
}
internal SqlBatchCommand GetCurrentBatchCommand()
{
if (_batchRPCMode)
{
- return _RPCList[_currentlyExecutingBatch].BatchCommand;
+ return _RPCList[_currentlyExecutingBatch].batchCommand;
}
else
{
- return _rpcArrayOf1?[0].BatchCommand;
+ return _rpcArrayOf1?[0].batchCommand;
}
}
internal SqlBatchCommand GetBatchCommand(int index)
{
- return _RPCList[index].BatchCommand;
+ return _RPCList[index].batchCommand;
}
internal int GetCurrentBatchIndex()
@@ -7505,17 +7505,17 @@ internal int GetCurrentBatchIndex()
internal SqlException GetErrors(int commandIndex)
{
SqlException result = null;
- int length = (_RPCList[commandIndex].ErrorsIndexEnd - _RPCList[commandIndex].ErrorsIndexStart);
+ int length = (_RPCList[commandIndex].errorsIndexEnd - _RPCList[commandIndex].errorsIndexStart);
if (0 < length)
{
SqlErrorCollection errors = new SqlErrorCollection();
- for (int i = _RPCList[commandIndex].ErrorsIndexStart; i < _RPCList[commandIndex].ErrorsIndexEnd; ++i)
+ for (int i = _RPCList[commandIndex].errorsIndexStart; i < _RPCList[commandIndex].errorsIndexEnd; ++i)
{
- errors.Add(_RPCList[commandIndex].Errors[i]);
+ errors.Add(_RPCList[commandIndex].errors[i]);
}
- for (int i = _RPCList[commandIndex].WarningsIndexStart; i < _RPCList[commandIndex].WarningsIndexEnd; ++i)
+ for (int i = _RPCList[commandIndex].warningsIndexStart; i < _RPCList[commandIndex].warningsIndexEnd; ++i)
{
- errors.Add(_RPCList[commandIndex].Warnings[i]);
+ errors.Add(_RPCList[commandIndex].warnings[i]);
}
result = SqlException.CreateException(errors, Connection.ServerVersion, Connection.ClientConnectionId, innerException: null, batchCommand: null);
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
index 7f977324f5..62145bc69e 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
@@ -3041,17 +3041,17 @@ private Assembly ResolveTypeAssembly(AssemblyName asmRef, bool throwOnError)
// TODO - move UDT code to separate file.
internal void CheckGetExtendedUDTInfo(SqlMetaDataPriv metaData, bool fThrow)
{
- if (metaData.Udt?.Type == null)
+ if (metaData.udt?.Type == null)
{ // If null, we have not obtained extended info.
- Debug.Assert(!ADP.IsEmpty(metaData.Udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
+ Debug.Assert(!ADP.IsEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
// Parameter throwOnError determines whether exception from Assembly.Load is thrown.
- metaData.Udt.Type =
- Type.GetType(typeName: metaData.Udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);
+ metaData.udt.Type =
+ Type.GetType(typeName: metaData.udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);
- if (fThrow && metaData.Udt.Type == null)
+ if (fThrow && metaData.udt.Type == null)
{
// TODO - BUG - UNDONE - Fix before Whidbey RTM - better message!
- throw SQL.UDTUnexpectedResult(metaData.Udt.AssemblyQualifiedName);
+ throw SQL.UDTUnexpectedResult(metaData.udt.AssemblyQualifiedName);
}
}
}
@@ -3068,7 +3068,7 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
// Since the serializer doesn't handle nulls...
if (ADP.IsNull(value))
{
- Type t = metaData.Udt?.Type;
+ Type t = metaData.udt?.Type;
Debug.Assert(t != null, "Unexpected null of udtType on GetUdtValue!");
o = t.InvokeMember("Null", BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Static, null, null, new Object[] { }, CultureInfo.InvariantCulture);
Debug.Assert(o != null);
@@ -3079,7 +3079,7 @@ internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnD
MemoryStream stm = new MemoryStream((byte[])value);
- o = Server.SerializationHelperSql9.Deserialize(stm, metaData.Udt?.Type);
+ o = Server.SerializationHelperSql9.Deserialize(stm, metaData.udt?.Type);
Debug.Assert(o != null, "object could NOT be created");
return o;
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs
index 3421f8cda9..69605d85eb 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs
@@ -337,59 +337,59 @@ internal virtual SmiExtendedMetaData[] GetInternalSmiMetaData()
if (!colMetaData.IsHidden)
{
- SqlCollation collation = colMetaData.Collation;
+ SqlCollation collation = colMetaData.collation;
string typeSpecificNamePart1 = null;
string typeSpecificNamePart2 = null;
string typeSpecificNamePart3 = null;
- if (SqlDbType.Xml == colMetaData.Type)
+ if (SqlDbType.Xml == colMetaData.type)
{
- typeSpecificNamePart1 = colMetaData.XmlSchemaCollection?.Database;
- typeSpecificNamePart2 = colMetaData.XmlSchemaCollection?.OwningSchema;
- typeSpecificNamePart3 = colMetaData.XmlSchemaCollection?.Name;
+ typeSpecificNamePart1 = colMetaData.xmlSchemaCollection?.Database;
+ typeSpecificNamePart2 = colMetaData.xmlSchemaCollection?.OwningSchema;
+ typeSpecificNamePart3 = colMetaData.xmlSchemaCollection?.Name;
}
- else if (SqlDbType.Udt == colMetaData.Type)
+ else if (SqlDbType.Udt == colMetaData.type)
{
Connection.CheckGetExtendedUDTInfo(colMetaData, true); // SQLBUDT #370593 ensure that colMetaData.udtType is set
- typeSpecificNamePart1 = colMetaData.Udt?.DatabaseName;
- typeSpecificNamePart2 = colMetaData.Udt?.SchemaName;
- typeSpecificNamePart3 = colMetaData.Udt?.TypeName;
+ typeSpecificNamePart1 = colMetaData.udt?.DatabaseName;
+ typeSpecificNamePart2 = colMetaData.udt?.SchemaName;
+ typeSpecificNamePart3 = colMetaData.udt?.TypeName;
}
- int length = colMetaData.Length;
+ int length = colMetaData.length;
if (length > TdsEnums.MAXSIZE)
{
length = (int)SmiMetaData.UnlimitedMaxLengthIndicator;
}
- else if (SqlDbType.NChar == colMetaData.Type
- || SqlDbType.NVarChar == colMetaData.Type)
+ else if (SqlDbType.NChar == colMetaData.type
+ || SqlDbType.NVarChar == colMetaData.type)
{
length /= ADP.CharSize;
}
metaDataReturn[returnIndex] = new SmiQueryMetaData(
- colMetaData.Type,
+ colMetaData.type,
length,
- colMetaData.Precision,
- colMetaData.Scale,
+ colMetaData.precision,
+ colMetaData.scale,
collation != null ? collation.LCID : _defaultLCID,
collation != null ? collation.SqlCompareOptions : SqlCompareOptions.None,
- colMetaData.Udt?.Type,
+ colMetaData.udt?.Type,
false, // isMultiValued
null, // fieldmetadata
null, // extended properties
- colMetaData.Column,
+ colMetaData.column,
typeSpecificNamePart1,
typeSpecificNamePart2,
typeSpecificNamePart3,
colMetaData.IsNullable,
- colMetaData.ServerName,
- colMetaData.CatalogName,
- colMetaData.SchemaName,
- colMetaData.TableName,
- colMetaData.BaseColumn,
+ colMetaData.serverName,
+ colMetaData.catalogName,
+ colMetaData.schemaName,
+ colMetaData.tableName,
+ colMetaData.baseColumn,
colMetaData.IsKey,
colMetaData.IsIdentity,
colMetaData.IsReadOnly,
@@ -590,47 +590,47 @@ internal DataTable BuildSchemaTable()
_SqlMetaData col = md[i];
DataRow schemaRow = schemaTable.NewRow();
- schemaRow[ColumnName] = col.Column;
- schemaRow[Ordinal] = col.Ordinal;
+ schemaRow[ColumnName] = col.column;
+ schemaRow[Ordinal] = col.ordinal;
//
// be sure to return character count for string types, byte count otherwise
// col.length is always byte count so for unicode types, half the length
//
// For MAX and XML datatypes, we get 0x7fffffff from the server. Do not divide this.
- if (col.CipherMD != null)
+ if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null && col.BaseTI.MetaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
- schemaRow[Size] = (col.BaseTI.MetaType.IsSizeInCharacters && (col.BaseTI.Length != 0x7fffffff)) ? (col.BaseTI.Length / 2) : col.BaseTI.Length;
+ Debug.Assert(col.baseTI != null && col.baseTI.metaType != null, "col.baseTI and col.baseTI.metaType should not be null.");
+ schemaRow[Size] = (col.baseTI.metaType.IsSizeInCharacters && (col.baseTI.length != 0x7fffffff)) ? (col.baseTI.length / 2) : col.baseTI.length;
}
else
{
- schemaRow[Size] = (col.MetaType.IsSizeInCharacters && (col.Length != 0x7fffffff)) ? (col.Length / 2) : col.Length;
+ schemaRow[Size] = (col.metaType.IsSizeInCharacters && (col.length != 0x7fffffff)) ? (col.length / 2) : col.length;
}
schemaRow[DataType] = GetFieldTypeInternal(col);
schemaRow[ProviderSpecificDataType] = GetProviderSpecificFieldTypeInternal(col);
- schemaRow[NonVersionedProviderType] = (int)(col.CipherMD != null ? col.BaseTI.Type : col.Type); // SqlDbType enum value - does not change with TypeSystem.
+ schemaRow[NonVersionedProviderType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type); // SqlDbType enum value - does not change with TypeSystem.
schemaRow[DataTypeName] = GetDataTypeNameInternal(col);
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.Is2008DateTimeType)
{
schemaRow[ProviderType] = SqlDbType.NVarChar;
- switch (col.Type)
+ switch (col.type)
{
case SqlDbType.Date:
schemaRow[Size] = TdsEnums.WHIDBEY_DATE_LENGTH;
break;
case SqlDbType.Time:
- Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.Scale || (0 <= col.Scale && col.Scale <= 7), "Invalid scale for Time column: " + col.Scale);
- schemaRow[Size] = TdsEnums.WHIDBEY_TIME_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale ? col.Scale : col.MetaType.Scale];
+ Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.scale || (0 <= col.scale && col.scale <= 7), "Invalid scale for Time column: " + col.scale);
+ schemaRow[Size] = TdsEnums.WHIDBEY_TIME_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale ? col.scale : col.metaType.Scale];
break;
case SqlDbType.DateTime2:
- Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.Scale || (0 <= col.Scale && col.Scale <= 7), "Invalid scale for DateTime2 column: " + col.Scale);
- schemaRow[Size] = TdsEnums.WHIDBEY_DATETIME2_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale ? col.Scale : col.MetaType.Scale];
+ Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.scale || (0 <= col.scale && col.scale <= 7), "Invalid scale for DateTime2 column: " + col.scale);
+ schemaRow[Size] = TdsEnums.WHIDBEY_DATETIME2_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale ? col.scale : col.metaType.Scale];
break;
case SqlDbType.DateTimeOffset:
- Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.Scale || (0 <= col.Scale && col.Scale <= 7), "Invalid scale for DateTimeOffset column: " + col.Scale);
- schemaRow[Size] = TdsEnums.WHIDBEY_DATETIMEOFFSET_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale ? col.Scale : col.MetaType.Scale];
+ Debug.Assert(TdsEnums.UNKNOWN_PRECISION_SCALE == col.scale || (0 <= col.scale && col.scale <= 7), "Invalid scale for DateTimeOffset column: " + col.scale);
+ schemaRow[Size] = TdsEnums.WHIDBEY_DATETIMEOFFSET_LENGTH[TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale ? col.scale : col.metaType.Scale];
break;
}
}
@@ -651,19 +651,19 @@ internal DataTable BuildSchemaTable()
// TypeSystem.SQLServer2005 and above
// SqlDbType enum value - always the actual type for SQLServer2005.
- schemaRow[ProviderType] = (int)(col.CipherMD != null ? col.BaseTI.Type : col.Type);
+ schemaRow[ProviderType] = (int)(col.cipherMD != null ? col.baseTI.type : col.type);
- if (col.Type == SqlDbType.Udt)
+ if (col.type == SqlDbType.Udt)
{ // Additional metadata for UDTs.
Debug.Assert(Connection.Is2005OrNewer, "Invalid Column type received from the server");
- schemaRow[UdtAssemblyQualifiedName] = col.Udt?.AssemblyQualifiedName;
+ schemaRow[UdtAssemblyQualifiedName] = col.udt?.AssemblyQualifiedName;
}
- else if (col.Type == SqlDbType.Xml)
+ else if (col.type == SqlDbType.Xml)
{ // Additional metadata for Xml.
Debug.Assert(Connection.Is2005OrNewer, "Invalid DataType (Xml) for the column");
- schemaRow[XmlSchemaCollectionDatabase] = col.XmlSchemaCollection?.Database;
- schemaRow[XmlSchemaCollectionOwningSchema] = col.XmlSchemaCollection?.OwningSchema;
- schemaRow[XmlSchemaCollectionName] = col.XmlSchemaCollection?.Name;
+ schemaRow[XmlSchemaCollectionDatabase] = col.xmlSchemaCollection?.Database;
+ schemaRow[XmlSchemaCollectionOwningSchema] = col.xmlSchemaCollection?.OwningSchema;
+ schemaRow[XmlSchemaCollectionName] = col.xmlSchemaCollection?.Name;
}
}
else
@@ -671,53 +671,53 @@ internal DataTable BuildSchemaTable()
// TypeSystem.SQLServer2000
// SqlDbType enum value - variable for certain types when SQLServer2000.
- schemaRow[ProviderType] = GetVersionedMetaType(col.MetaType).SqlDbType;
+ schemaRow[ProviderType] = GetVersionedMetaType(col.metaType).SqlDbType;
}
- if (col.CipherMD != null)
+ if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.BaseTI.Precision)
+ Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.precision)
{
- schemaRow[Precision] = col.BaseTI.Precision;
+ schemaRow[Precision] = col.baseTI.precision;
}
else
{
- schemaRow[Precision] = col.BaseTI.MetaType.Precision;
+ schemaRow[Precision] = col.baseTI.metaType.Precision;
}
}
- else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.Precision)
+ else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.precision)
{
- schemaRow[Precision] = col.Precision;
+ schemaRow[Precision] = col.precision;
}
else
{
- schemaRow[Precision] = col.MetaType.Precision;
+ schemaRow[Precision] = col.metaType.Precision;
}
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && col.Is2008DateTimeType)
{
schemaRow[Scale] = MetaType.MetaNVarChar.Scale;
}
- else if (col.CipherMD != null)
+ else if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null, @"col.baseTI should not be null.");
- if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.BaseTI.Scale)
+ Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
+ if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.baseTI.scale)
{
- schemaRow[Scale] = col.BaseTI.Scale;
+ schemaRow[Scale] = col.baseTI.scale;
}
else
{
- schemaRow[Scale] = col.BaseTI.MetaType.Scale;
+ schemaRow[Scale] = col.baseTI.metaType.Scale;
}
}
- else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.Scale)
+ else if (TdsEnums.UNKNOWN_PRECISION_SCALE != col.scale)
{
- schemaRow[Scale] = col.Scale;
+ schemaRow[Scale] = col.scale;
}
else
{
- schemaRow[Scale] = col.MetaType.Scale;
+ schemaRow[Scale] = col.metaType.Scale;
}
schemaRow[AllowDBNull] = col.IsNullable;
@@ -734,19 +734,19 @@ internal DataTable BuildSchemaTable()
schemaRow[IsIdentity] = col.IsIdentity;
schemaRow[IsAutoIncrement] = col.IsIdentity;
- if (col.CipherMD != null)
+ if (col.cipherMD != null)
{
- Debug.Assert(col.BaseTI != null, @"col.baseTI should not be null.");
- Debug.Assert(col.BaseTI.MetaType != null, @"col.baseTI.metaType should not be null.");
- schemaRow[IsLong] = col.BaseTI.MetaType.IsLong;
+ Debug.Assert(col.baseTI != null, @"col.baseTI should not be null.");
+ Debug.Assert(col.baseTI.metaType != null, @"col.baseTI.metaType should not be null.");
+ schemaRow[IsLong] = col.baseTI.metaType.IsLong;
}
else
{
- schemaRow[IsLong] = col.MetaType.IsLong;
+ schemaRow[IsLong] = col.metaType.IsLong;
}
// mark unique for timestamp columns
- if (SqlDbType.Timestamp == col.Type)
+ if (SqlDbType.Timestamp == col.type)
{
schemaRow[IsUnique] = true;
schemaRow[IsRowVersion] = true;
@@ -760,29 +760,29 @@ internal DataTable BuildSchemaTable()
schemaRow[IsReadOnly] = col.IsReadOnly;
schemaRow[IsColumnSet] = col.IsColumnSet;
- if (!ADP.IsEmpty(col.ServerName))
+ if (!ADP.IsEmpty(col.serverName))
{
- schemaRow[BaseServerName] = col.ServerName;
+ schemaRow[BaseServerName] = col.serverName;
}
- if (!ADP.IsEmpty(col.CatalogName))
+ if (!ADP.IsEmpty(col.catalogName))
{
- schemaRow[BaseCatalogName] = col.CatalogName;
+ schemaRow[BaseCatalogName] = col.catalogName;
}
- if (!ADP.IsEmpty(col.SchemaName))
+ if (!ADP.IsEmpty(col.schemaName))
{
- schemaRow[BaseSchemaName] = col.SchemaName;
+ schemaRow[BaseSchemaName] = col.schemaName;
}
- if (!ADP.IsEmpty(col.TableName))
+ if (!ADP.IsEmpty(col.tableName))
{
- schemaRow[BaseTableName] = col.TableName;
+ schemaRow[BaseTableName] = col.tableName;
}
- if (!ADP.IsEmpty(col.BaseColumn))
+ if (!ADP.IsEmpty(col.baseColumn))
{
- schemaRow[BaseColumnName] = col.BaseColumn;
+ schemaRow[BaseColumnName] = col.baseColumn;
}
- else if (!ADP.IsEmpty(col.Column))
+ else if (!ADP.IsEmpty(col.column))
{
- schemaRow[BaseColumnName] = col.Column;
+ schemaRow[BaseColumnName] = col.column;
}
schemaTable.Rows.Add(schemaRow);
@@ -1408,21 +1408,21 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
Debug.Assert(Connection.Is2005OrNewer, "Invalid Column type received from the server");
- dataTypeName = metaData.Udt?.DatabaseName + "." + metaData.Udt?.SchemaName + "." + metaData.Udt?.TypeName;
+ dataTypeName = metaData.udt?.DatabaseName + "." + metaData.udt?.SchemaName + "." + metaData.udt?.TypeName;
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null && metaData.BaseTI.MetaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- dataTypeName = metaData.BaseTI.MetaType.TypeName;
+ Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ dataTypeName = metaData.baseTI.metaType.TypeName;
}
else
{
- dataTypeName = metaData.MetaType.TypeName;
+ dataTypeName = metaData.metaType.TypeName;
}
}
}
@@ -1430,7 +1430,7 @@ private string GetDataTypeNameInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2000
- dataTypeName = GetVersionedMetaType(metaData.MetaType).TypeName;
+ dataTypeName = GetVersionedMetaType(metaData.metaType).TypeName;
}
return dataTypeName;
@@ -1492,22 +1492,22 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
Debug.Assert(Connection.Is2005OrNewer, "Invalid Column type received from the server");
Connection.CheckGetExtendedUDTInfo(metaData, false);
- fieldType = metaData.Udt?.Type;
+ fieldType = metaData.udt?.Type;
}
else
{ // For all other types, including Xml - use data in MetaType.
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null && metaData.BaseTI.MetaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
- fieldType = metaData.BaseTI.MetaType.ClassType;
+ Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null, "metaData.baseTI and metaData.baseTI.metaType should not be null.");
+ fieldType = metaData.baseTI.metaType.ClassType;
}
else
{
- fieldType = metaData.MetaType.ClassType; // Com+ type.
+ fieldType = metaData.metaType.ClassType; // Com+ type.
}
}
}
@@ -1515,7 +1515,7 @@ private Type GetFieldTypeInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2000
- fieldType = GetVersionedMetaType(metaData.MetaType).ClassType; // Com+ type.
+ fieldType = GetVersionedMetaType(metaData.metaType).ClassType; // Com+ type.
}
return fieldType;
@@ -1526,13 +1526,13 @@ virtual internal int GetLocaleId(int i)
_SqlMetaData sqlMetaData = MetaData[i];
int lcid;
- if (sqlMetaData.CipherMD != null)
+ if (sqlMetaData.cipherMD != null)
{
// If this column is encrypted, get the collation from baseTI
//
- if (sqlMetaData.BaseTI.Collation != null)
+ if (sqlMetaData.baseTI.collation != null)
{
- lcid = sqlMetaData.BaseTI.Collation.LCID;
+ lcid = sqlMetaData.baseTI.collation.LCID;
}
else
{
@@ -1541,9 +1541,9 @@ virtual internal int GetLocaleId(int i)
}
else
{
- if (sqlMetaData.Collation != null)
+ if (sqlMetaData.collation != null)
{
- lcid = sqlMetaData.Collation.LCID;
+ lcid = sqlMetaData.collation.LCID;
}
else
{
@@ -1558,8 +1558,8 @@ override public string GetName(int i)
{
CheckMetaDataIsReady(columnIndex: i);
- Debug.Assert(_metaData[i].Column != null, "MDAC 66681");
- return _metaData[i].Column;
+ Debug.Assert(_metaData[i].column != null, "MDAC 66681");
+ return _metaData[i].column;
}
///
@@ -1603,24 +1603,24 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2005 and above
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
Debug.Assert(Connection.Is2005OrNewer, "Invalid Column type received from the server");
Connection.CheckGetExtendedUDTInfo(metaData, false);
- providerSpecificFieldType = metaData.Udt?.Type;
+ providerSpecificFieldType = metaData.udt?.Type;
}
else
{
// For all other types, including Xml - use data in MetaType.
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null && metaData.BaseTI.MetaType != null,
+ Debug.Assert(metaData.baseTI != null && metaData.baseTI.metaType != null,
"metaData.baseTI and metaData.baseTI.metaType should not be null.");
- providerSpecificFieldType = metaData.BaseTI.MetaType.SqlType; // SqlType type.
+ providerSpecificFieldType = metaData.baseTI.metaType.SqlType; // SqlType type.
}
else
{
- providerSpecificFieldType = metaData.MetaType.SqlType; // SqlType type.
+ providerSpecificFieldType = metaData.metaType.SqlType; // SqlType type.
}
}
}
@@ -1628,7 +1628,7 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData)
{
// TypeSystem.SQLServer2000
- providerSpecificFieldType = GetVersionedMetaType(metaData.MetaType).SqlType; // SqlType type.
+ providerSpecificFieldType = GetVersionedMetaType(metaData.metaType).SqlType; // SqlType type.
}
return providerSpecificFieldType;
@@ -1676,15 +1676,15 @@ override public DataTable GetSchemaTable()
try
{
statistics = SqlStatistics.StartTimer(Statistics);
- if (_metaData == null || _metaData.SchemaTable == null)
+ if (_metaData == null || _metaData.schemaTable == null)
{
if (this.MetaData != null)
{
- _metaData.SchemaTable = BuildSchemaTable();
- Debug.Assert(_metaData.SchemaTable != null, "No schema information yet!");
+ _metaData.schemaTable = BuildSchemaTable();
+ Debug.Assert(_metaData.schemaTable != null, "No schema information yet!");
}
}
- return _metaData?.SchemaTable;
+ return _metaData?.schemaTable;
}
finally
{
@@ -1707,12 +1707,12 @@ virtual public XmlReader GetXmlReader(int i)
// If this ever changes, the following code should be changed to be like GetStream\GetTextReader
CheckDataIsReady(columnIndex: i, methodName: "GetXmlReader");
- MetaType mt = _metaData[i].MetaType;
+ MetaType mt = _metaData[i].metaType;
// XmlReader only allowed on XML types
if (mt.SqlDbType != SqlDbType.Xml)
{
- throw SQL.XmlReaderNotSupportOnColumnType(_metaData[i].Column);
+ throw SQL.XmlReaderNotSupportOnColumnType(_metaData[i].column);
}
if (IsCommandBehavior(CommandBehavior.SequentialAccess))
@@ -1746,17 +1746,17 @@ override public Stream GetStream(int i)
CheckDataIsReady(columnIndex: i, methodName: "GetStream");
// Streaming is not supported on encrypted columns.
- if (_metaData[i] != null && _metaData[i].CipherMD != null)
+ if (_metaData[i] != null && _metaData[i].cipherMD != null)
{
- throw SQL.StreamNotSupportOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.StreamNotSupportOnEncryptedColumn(_metaData[i].column);
}
// Stream is only for Binary, Image, VarBinary, Udt and Xml types
// NOTE: IsBinType also includes Timestamp for some reason...
- MetaType mt = _metaData[i].MetaType;
+ MetaType mt = _metaData[i].metaType;
if (((!mt.IsBinType) || (mt.SqlDbType == SqlDbType.Timestamp)) && (mt.SqlDbType != SqlDbType.Variant))
{
- throw SQL.StreamNotSupportOnColumnType(_metaData[i].Column);
+ throw SQL.StreamNotSupportOnColumnType(_metaData[i].column);
}
// For non-variant types with sequential access, we support proper streaming
@@ -1804,10 +1804,10 @@ override public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIn
CheckDataIsReady(columnIndex: i, allowPartiallyReadColumn: true, methodName: "GetBytes");
// don't allow get bytes on non-long or non-binary columns
- MetaType mt = _metaData[i].MetaType;
+ MetaType mt = _metaData[i].metaType;
if (!(mt.IsLong || mt.IsBinType) || (SqlDbType.Xml == mt.SqlDbType))
{
- throw SQL.NonBlobColumn(_metaData[i].Column);
+ throw SQL.NonBlobColumn(_metaData[i].column);
}
try
@@ -1867,9 +1867,9 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
{
Debug.Assert(!HasActiveStreamOrTextReaderOnColumn(i), "Column has an active Stream or TextReader");
- if (_metaData[i] != null && _metaData[i].CipherMD != null)
+ if (_metaData[i] != null && _metaData[i].cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
if (_sharedState._nextColumnHeaderToRead <= i)
@@ -1888,7 +1888,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
}
// If there are an unknown (-1) number of bytes left for a PLP, read its size
- if ((-1 == _sharedState._columnDataBytesRemaining) && (_metaData[i].MetaType.IsPlp))
+ if ((-1 == _sharedState._columnDataBytesRemaining) && (_metaData[i].metaType.IsPlp))
{
ulong left;
result = _parser.TryPlpBytesLeft(_stateObj, out left);
@@ -1907,7 +1907,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
// if no buffer is passed in, return the number total of bytes, or -1
if (buffer == null)
{
- if (_metaData[i].MetaType.IsPlp)
+ if (_metaData[i].metaType.IsPlp)
{
remaining = (long)_parser.PlpBytesTotalLength(_stateObj);
return TdsOperationStatus.Done;
@@ -1928,7 +1928,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
long cb = dataIndex - _columnDataBytesRead;
// if dataIndex is outside of the data range, return 0
- if ((cb > _sharedState._columnDataBytesRemaining) && !_metaData[i].MetaType.IsPlp)
+ if ((cb > _sharedState._columnDataBytesRemaining) && !_metaData[i].metaType.IsPlp)
{
return TdsOperationStatus.Done;
}
@@ -1947,7 +1947,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
// Skip if needed
if (cb > 0)
{
- if (_metaData[i].MetaType.IsPlp)
+ if (_metaData[i].metaType.IsPlp)
{
ulong skipped;
result = _parser.TrySkipPlpValue((ulong)cb, _stateObj, out skipped);
@@ -1993,17 +1993,17 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf
// the use of GetBytes on string data columns, but
// GetSqlBinary isn't supposed to. What we end up
// doing isn't exactly pretty, but it does work.
- if (_metaData[i].MetaType.IsBinType)
+ if (_metaData[i].metaType.IsBinType)
{
data = GetSqlBinary(i).Value;
}
else
{
- Debug.Assert(_metaData[i].MetaType.IsLong, "non long type?");
- Debug.Assert(_metaData[i].MetaType.IsCharType, "non-char type?");
+ Debug.Assert(_metaData[i].metaType.IsLong, "non long type?");
+ Debug.Assert(_metaData[i].metaType.IsCharType, "non-char type?");
SqlString temp = GetSqlString(i);
- if (_metaData[i].MetaType.IsNCharType)
+ if (_metaData[i].metaType.IsNCharType)
{
data = temp.GetUnicodeBytes();
}
@@ -2171,7 +2171,7 @@ internal TdsOperationStatus TryGetBytesInternalSequential(int i, byte[] buffer,
else
{
// if plp columns, do partial reads. Don't read the entire value in one shot.
- if (_metaData[i].MetaType.IsPlp)
+ if (_metaData[i].metaType.IsPlp)
{
// Read in data
TdsOperationStatus result = _stateObj.TryReadPlpBytes(ref buffer, index, length, out bytesRead);
@@ -2247,29 +2247,29 @@ override public TextReader GetTextReader(int i)
// Xml type is not supported
MetaType mt = null;
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- Debug.Assert(_metaData[i].BaseTI != null, "_metaData[i].baseTI should not be null.");
- mt = _metaData[i].BaseTI.MetaType;
+ Debug.Assert(_metaData[i].baseTI != null, "_metaData[i].baseTI should not be null.");
+ mt = _metaData[i].baseTI.metaType;
}
else
{
- mt = _metaData[i].MetaType;
+ mt = _metaData[i].metaType;
}
Debug.Assert(mt != null, @"mt should not be null.");
if (((!mt.IsCharType) && (mt.SqlDbType != SqlDbType.Variant)) || (mt.SqlDbType == SqlDbType.Xml))
{
- throw SQL.TextReaderNotSupportOnColumnType(_metaData[i].Column);
+ throw SQL.TextReaderNotSupportOnColumnType(_metaData[i].column);
}
// For non-variant types with sequential access, we support proper streaming
if ((mt.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)))
{
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
System.Text.Encoding encoding;
@@ -2280,7 +2280,7 @@ override public TextReader GetTextReader(int i)
}
else
{
- encoding = _metaData[i].Encoding;
+ encoding = _metaData[i].encoding;
}
_currentTextReader = new SqlSequentialTextReader(this, i, encoding);
@@ -2329,27 +2329,27 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
}
MetaType mt = null;
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- Debug.Assert(_metaData[i].BaseTI != null, @"_metaData[i].baseTI should not be null.");
- mt = _metaData[i].BaseTI.MetaType;
+ Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
+ mt = _metaData[i].baseTI.metaType;
}
else
{
- mt = _metaData[i].MetaType;
+ mt = _metaData[i].metaType;
}
Debug.Assert(mt != null, "mt should not be null.");
SqlDbType sqlDbType;
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- Debug.Assert(_metaData[i].BaseTI != null, @"_metaData[i].baseTI should not be null.");
- sqlDbType = _metaData[i].BaseTI.Type;
+ Debug.Assert(_metaData[i].baseTI != null, @"_metaData[i].baseTI should not be null.");
+ sqlDbType = _metaData[i].baseTI.type;
}
else
{
- sqlDbType = _metaData[i].Type;
+ sqlDbType = _metaData[i].type;
}
try
@@ -2364,9 +2364,9 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
throw ADP.InvalidDataLength(length);
}
- if (_metaData[i].CipherMD != null)
+ if (_metaData[i].cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(_metaData[i].column);
}
// if bad buffer index, throw
@@ -2515,13 +2515,13 @@ private long GetCharsFromPlpData(int i, long dataIndex, char[] buffer, int buffe
AssertReaderState(requireData: true, permitAsync: false, columnIndex: i, enforceSequentialAccess: true);
Debug.Assert(!HasActiveStreamOrTextReaderOnColumn(i), "Column has active Stream or TextReader");
// don't allow get bytes on non-long or non-binary columns
- Debug.Assert(_metaData[i].MetaType.IsPlp, "GetCharsFromPlpData called on a non-plp column!");
+ Debug.Assert(_metaData[i].metaType.IsPlp, "GetCharsFromPlpData called on a non-plp column!");
// Must be sequential reading
Debug.Assert(IsCommandBehavior(CommandBehavior.SequentialAccess), "GetCharsFromPlpData called for non-Sequential access");
- if (!_metaData[i].MetaType.IsCharType)
+ if (!_metaData[i].metaType.IsCharType)
{
- throw SQL.NonCharColumn(_metaData[i].Column);
+ throw SQL.NonCharColumn(_metaData[i].column);
}
if (_sharedState._nextColumnHeaderToRead <= i)
@@ -2547,7 +2547,7 @@ private long GetCharsFromPlpData(int i, long dataIndex, char[] buffer, int buffe
if (dataIndex == 0)
_stateObj._plpdecoder = null;
- bool isUnicode = _metaData[i].MetaType.IsNCharType;
+ bool isUnicode = _metaData[i].metaType.IsNCharType;
// If there are an unknown (-1) number of bytes left for a PLP, read its size
if (-1 == _sharedState._columnDataBytesRemaining)
@@ -2934,7 +2934,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// Dev11 Bug #336820, Dev10 Bug #479607 (SqlClient: IsDBNull always returns false for timestamp datatype)
// Due to a bug in TdsParser.GetNullSqlValue, Timestamps' IsNull is not correctly set - so we need to bypass the following check
- Debug.Assert(!data.IsEmpty || data.IsNull || metaData.Type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
+ Debug.Assert(!data.IsEmpty || data.IsNull || metaData.type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
// Convert 2008 types to string
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.Is2008DateTimeType)
@@ -2949,7 +2949,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// TypeSystem.SQLServer2005
- if (metaData.Type == SqlDbType.Udt)
+ if (metaData.type == SqlDbType.Udt)
{
var connection = _connection;
if (connection != null)
@@ -2971,7 +2971,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
{
// TypeSystem.SQLServer2000
- if (metaData.Type == SqlDbType.Xml)
+ if (metaData.type == SqlDbType.Xml)
{
return data.SqlString;
}
@@ -3126,7 +3126,7 @@ private object GetValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaDa
{
// Dev11 Bug #336820, Dev10 Bug #479607 (SqlClient: IsDBNull always returns false for timestamp datatype)
// Due to a bug in TdsParser.GetNullSqlValue, Timestamps' IsNull is not correctly set - so we need to bypass the following check
- Debug.Assert(!data.IsEmpty || data.IsNull || metaData.Type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
+ Debug.Assert(!data.IsEmpty || data.IsNull || metaData.type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.Is2008DateTimeType)
{
@@ -3147,7 +3147,7 @@ private object GetValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaDa
{
// TypeSystem.SQLServer2005
- if (metaData.Type != SqlDbType.Udt)
+ if (metaData.type != SqlDbType.Udt)
{
return data.Value;
}
@@ -3243,16 +3243,16 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
else if (typeof(T) == typeof(XmlReader))
{
// XmlReader only allowed on XML types
- if (metaData.MetaType.SqlDbType != SqlDbType.Xml)
+ if (metaData.metaType.SqlDbType != SqlDbType.Xml)
{
- throw SQL.XmlReaderNotSupportOnColumnType(metaData.Column);
+ throw SQL.XmlReaderNotSupportOnColumnType(metaData.column);
}
if (IsCommandBehavior(CommandBehavior.SequentialAccess))
{
// Wrap the sequential stream in an XmlReader
- _currentStream = new SqlSequentialStream(this, metaData.Ordinal);
- _lastColumnWithDataChunkRead = metaData.Ordinal;
+ _currentStream = new SqlSequentialStream(this, metaData.ordinal);
+ _lastColumnWithDataChunkRead = metaData.ordinal;
return (T)(object)SqlTypeWorkarounds.SqlXmlCreateSqlXmlReader(_currentStream, closeInput: true, async: isAsync);
}
else
@@ -3272,11 +3272,11 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
else if (typeof(T) == typeof(TextReader))
{
// Xml type is not supported
- MetaType metaType = metaData.MetaType;
- if (metaData.CipherMD != null)
+ MetaType metaType = metaData.metaType;
+ if (metaData.cipherMD != null)
{
- Debug.Assert(metaData.BaseTI != null, "_metaData[i].baseTI should not be null.");
- metaType = metaData.BaseTI.MetaType;
+ Debug.Assert(metaData.baseTI != null, "_metaData[i].baseTI should not be null.");
+ metaType = metaData.baseTI.metaType;
}
if (
@@ -3284,25 +3284,25 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
(metaType.SqlDbType == SqlDbType.Xml)
)
{
- throw SQL.TextReaderNotSupportOnColumnType(metaData.Column);
+ throw SQL.TextReaderNotSupportOnColumnType(metaData.column);
}
// For non-variant types with sequential access, we support proper streaming
if ((metaType.SqlDbType != SqlDbType.Variant) && IsCommandBehavior(CommandBehavior.SequentialAccess))
{
- if (metaData.CipherMD != null)
+ if (metaData.cipherMD != null)
{
- throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(metaData.Column);
+ throw SQL.SequentialAccessNotSupportedOnEncryptedColumn(metaData.column);
}
System.Text.Encoding encoding = SqlUnicodeEncoding.SqlUnicodeEncodingInstance;
if (!metaType.IsNCharType)
{
- encoding = metaData.Encoding;
+ encoding = metaData.encoding;
}
- _currentTextReader = new SqlSequentialTextReader(this, metaData.Ordinal, encoding);
- _lastColumnWithDataChunkRead = metaData.Ordinal;
+ _currentTextReader = new SqlSequentialTextReader(this, metaData.ordinal, encoding);
+ _lastColumnWithDataChunkRead = metaData.ordinal;
return (T)(object)_currentTextReader;
}
else
@@ -3314,25 +3314,25 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met
}
else if (typeof(T) == typeof(Stream))
{
- if (metaData != null && metaData.CipherMD != null)
+ if (metaData != null && metaData.cipherMD != null)
{
- throw SQL.StreamNotSupportOnEncryptedColumn(metaData.Column);
+ throw SQL.StreamNotSupportOnEncryptedColumn(metaData.column);
}
// Stream is only for Binary, Image, VarBinary, Udt, Xml and Timestamp(RowVersion) types
- MetaType metaType = metaData.MetaType;
+ MetaType metaType = metaData.metaType;
if (
(!metaType.IsBinType || metaType.SqlDbType == SqlDbType.Timestamp) &&
metaType.SqlDbType != SqlDbType.Variant
)
{
- throw SQL.StreamNotSupportOnColumnType(metaData.Column);
+ throw SQL.StreamNotSupportOnColumnType(metaData.column);
}
if ((metaType.SqlDbType != SqlDbType.Variant) && (IsCommandBehavior(CommandBehavior.SequentialAccess)))
{
- _currentStream = new SqlSequentialStream(this, metaData.Ordinal);
- _lastColumnWithDataChunkRead = metaData.Ordinal;
+ _currentStream = new SqlSequentialStream(this, metaData.ordinal);
+ _lastColumnWithDataChunkRead = metaData.ordinal;
return (T)(object)_currentStream;
}
else
@@ -3542,7 +3542,7 @@ private TdsOperationStatus TryHasMoreResults(out bool moreResults)
if (_altRowStatus == ALTROWSTATUS.Null)
{
// cache the regular metadata
- _altMetaDataSetCollection.MetaDataSet = _metaData;
+ _altMetaDataSetCollection.metaDataSet = _metaData;
_metaData = null;
}
else
@@ -3841,7 +3841,7 @@ private TdsOperationStatus TryNextResult(out bool more)
break;
case ALTROWSTATUS.Done:
// restore the row-metaData
- _metaData = _altMetaDataSetCollection.MetaDataSet;
+ _metaData = _altMetaDataSetCollection.metaDataSet;
Debug.Assert(_altRowStatus == ALTROWSTATUS.Done, "invalid AltRowStatus");
_altRowStatus = ALTROWSTATUS.Null;
break;
@@ -4273,7 +4273,7 @@ private TdsOperationStatus TryReadColumnData()
TdsOperationStatus result = _parser.TryReadSqlValue(_data[_sharedState._nextColumnDataToRead], columnMetaData, (int)_sharedState._columnDataBytesRemaining, _stateObj,
_command != null ? _command.ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting.UseConnectionSetting,
- columnMetaData.Column, _command);
+ columnMetaData.column, _command);
if (result != TdsOperationStatus.Done)
{
// will read UDTs as VARBINARY.
@@ -4369,7 +4369,7 @@ internal TdsOperationStatus TryReadColumnInternal(int i, bool readHeaderOnly/* =
Debug.Assert(i == _sharedState._nextColumnDataToRead || // Either we haven't read the column yet
((i + 1 < _sharedState._nextColumnDataToRead) && (IsCommandBehavior(CommandBehavior.SequentialAccess))) || // Or we're in sequential mode and we've read way past the column (i.e. it was not the last column we read)
(!_data[i].IsEmpty || _data[i].IsNull) || // Or we should have data stored for the column (unless the column was null)
- (_metaData[i].Type == SqlDbType.Timestamp), // Or Dev11 Bug #336820, Dev10 Bug #479607 (SqlClient: IsDBNull always returns false for timestamp datatype)
+ (_metaData[i].type == SqlDbType.Timestamp), // Or Dev11 Bug #336820, Dev10 Bug #479607 (SqlClient: IsDBNull always returns false for timestamp datatype)
// Due to a bug in TdsParser.GetNullSqlValue, Timestamps' IsNull is not correctly set - so we need to bypass the check
"Gone past column, be we have no data stored for it");
return TdsOperationStatus.Done;
@@ -4454,7 +4454,7 @@ out dataLength
if (isNull)
{
- if (columnMetaData.Type != SqlDbType.Timestamp)
+ if (columnMetaData.type != SqlDbType.Timestamp)
{
TdsParser.GetNullSqlValue(
_data[_sharedState._nextColumnDataToRead],
@@ -4475,7 +4475,7 @@ out dataLength
columnMetaData,
(int)dataLength, _stateObj,
_command != null ? _command.ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting.UseConnectionSetting,
- columnMetaData.Column
+ columnMetaData.column
);
if (result != TdsOperationStatus.Done)
{
@@ -4511,7 +4511,7 @@ out dataLength
// Trigger new behavior for RowVersion to send DBNull.Value by allowing entry for Timestamp or discard entry for Timestamp for legacy support.
// if LegacyRowVersionNullBehavior is enabled, Timestamp type must enter "else" block.
- if (isNull && (!LocalAppContextSwitches.LegacyRowVersionNullBehavior || columnMetaData.Type != SqlDbType.Timestamp))
+ if (isNull && (!LocalAppContextSwitches.LegacyRowVersionNullBehavior || columnMetaData.type != SqlDbType.Timestamp))
{
TdsParser.GetNullSqlValue(
_data[_sharedState._nextColumnDataToRead],
@@ -4534,7 +4534,7 @@ out dataLength
// can read it out of order
result = _parser.TryReadSqlValue(_data[_sharedState._nextColumnDataToRead], columnMetaData, (int)dataLength, _stateObj,
_command != null ? _command.ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting.UseConnectionSetting,
- columnMetaData.Column);
+ columnMetaData.column);
if (result != TdsOperationStatus.Done)
{
// will read UDTs as VARBINARY.
@@ -4566,7 +4566,7 @@ private bool WillHaveEnoughData(int targetColumn, bool headerOnly = false)
{
AssertReaderState(requireData: true, permitAsync: true, columnIndex: targetColumn);
- if ((_lastColumnWithDataChunkRead == _sharedState._nextColumnDataToRead) && (_metaData[_lastColumnWithDataChunkRead].MetaType.IsPlp))
+ if ((_lastColumnWithDataChunkRead == _sharedState._nextColumnDataToRead) && (_metaData[_lastColumnWithDataChunkRead].metaType.IsPlp))
{
// In the middle of reading a Plp - no idea how much is left
return false;
@@ -4603,22 +4603,22 @@ private bool WillHaveEnoughData(int targetColumn, bool headerOnly = false)
{
// NOTE: This is mostly duplicated from TryProcessColumnHeaderNoNBC and TryGetTokenLength
- var metaType = _metaData[currentColumn].MetaType;
+ var metaType = _metaData[currentColumn].metaType;
if ((metaType.IsLong) || (metaType.IsPlp) || (metaType.SqlDbType == SqlDbType.Udt) || (metaType.SqlDbType == SqlDbType.Structured))
{
// Plp, Udt and TVP types have an unknownable size - so return that the estimate failed
return false;
}
int maxHeaderSize;
- byte typeAndMask = (byte)(_metaData[currentColumn].TdsType & TdsEnums.SQLLenMask);
+ byte typeAndMask = (byte)(_metaData[currentColumn].tdsType & TdsEnums.SQLLenMask);
if ((typeAndMask == TdsEnums.SQLVarLen) || (typeAndMask == TdsEnums.SQLVarCnt))
{
- if (0 != (_metaData[currentColumn].TdsType & 0x80))
+ if (0 != (_metaData[currentColumn].tdsType & 0x80))
{
// UInt16 represents size
maxHeaderSize = 2;
}
- else if (0 == (_metaData[currentColumn].TdsType & 0x0c))
+ else if (0 == (_metaData[currentColumn].tdsType & 0x0c))
{
// UInt32 represents size
maxHeaderSize = 4;
@@ -4637,7 +4637,7 @@ private bool WillHaveEnoughData(int targetColumn, bool headerOnly = false)
bytesRemaining = checked(bytesRemaining - maxHeaderSize);
if ((currentColumn < targetColumn) || (!headerOnly))
{
- bytesRemaining = checked(bytesRemaining - _metaData[currentColumn].Length);
+ bytesRemaining = checked(bytesRemaining - _metaData[currentColumn].length);
}
}
@@ -4657,7 +4657,7 @@ private TdsOperationStatus TryResetBlobState()
// If we haven't already entirely read the column
if (_sharedState._nextColumnDataToRead < _sharedState._nextColumnHeaderToRead)
{
- if ((_sharedState._nextColumnHeaderToRead > 0) && (_metaData[_sharedState._nextColumnHeaderToRead - 1].MetaType.IsPlp))
+ if ((_sharedState._nextColumnHeaderToRead > 0) && (_metaData[_sharedState._nextColumnHeaderToRead - 1].metaType.IsPlp))
{
if (_stateObj._longlen != 0)
{
@@ -4823,7 +4823,7 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn
_tableNames = null;
if (_metaData != null)
{
- _metaData.SchemaTable = null;
+ _metaData.schemaTable = null;
_data = SqlBuffer.CreateBufferArray(metaData.Length);
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
index 4d6356cbeb..0aaa4a6d93 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
@@ -746,7 +746,7 @@ override internal bool Is2000
{
get
{
- return _loginAck.IsVersion8;
+ return _loginAck.isVersion8;
}
}
@@ -812,8 +812,8 @@ override public string ServerVersion
{
get
{
- return (string.Format("{0:00}.{1:00}.{2:0000}", _loginAck.MajorVersion,
- (short)_loginAck.MinorVersion, _loginAck.BuildNum));
+ return (string.Format("{0:00}.{1:00}.{2:0000}", _loginAck.majorVersion,
+ (short)_loginAck.minorVersion, _loginAck.buildNum));
}
}
public int ServerProcessId
@@ -845,7 +845,7 @@ protected override bool UnbindOnTransactionCompletion
///
/// Validates if federated authentication is used, Access Token used by this connection is active for the value of 'accessTokenExpirationBufferTime'.
///
- internal override bool IsAccessTokenExpired => _federatedAuthenticationInfoRequested && DateTime.FromFileTimeUtc(_fedAuthToken.ExpirationFileTime) < DateTime.UtcNow.AddSeconds(accessTokenExpirationBufferTime);
+ internal override bool IsAccessTokenExpired => _federatedAuthenticationInfoRequested && DateTime.FromFileTimeUtc(_fedAuthToken.expirationFileTime) < DateTime.UtcNow.AddSeconds(accessTokenExpirationBufferTime);
////////////////////////////////////////////////////////////////////////////////////////
// GENERAL METHODS
@@ -1545,37 +1545,37 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
}
}
- login.Authentication = ConnectionOptions.Authentication;
- login.Timeout = timeoutInSeconds;
- login.UserInstance = ConnectionOptions.UserInstance;
- login.HostName = ConnectionOptions.ObtainWorkstationId();
- login.UserName = ConnectionOptions.UserID;
- login.Password = ConnectionOptions.Password;
- login.ApplicationName = ConnectionOptions.ApplicationName;
+ login.authentication = ConnectionOptions.Authentication;
+ login.timeout = timeoutInSeconds;
+ login.userInstance = ConnectionOptions.UserInstance;
+ login.hostName = ConnectionOptions.ObtainWorkstationId();
+ login.userName = ConnectionOptions.UserID;
+ login.password = ConnectionOptions.Password;
+ login.applicationName = ConnectionOptions.ApplicationName;
- login.Language = _currentLanguage;
- if (!login.UserInstance)
+ login.language = _currentLanguage;
+ if (!login.userInstance)
{ // Do not send attachdbfilename or database to SSE primary instance
- login.Database = CurrentDatabase;
+ login.database = CurrentDatabase;
;
- login.AttachDbFilename = ConnectionOptions.AttachDBFilename;
+ login.attachDBFilename = ConnectionOptions.AttachDBFilename;
}
// VSTS#795621 - Ensure ServerName is Sent During TdsLogin To Enable Sql Azure Connectivity.
// Using server.UserServerName (versus ConnectionOptions.DataSource) since TdsLogin requires
// serverName to always be non-null.
- login.ServerName = server.UserServerName;
+ login.serverName = server.UserServerName;
- login.UseReplication = ConnectionOptions.Replication;
- login.UseSspi = ConnectionOptions.IntegratedSecurity // Treat AD Integrated like Windows integrated when against a non-FedAuth endpoint
+ login.useReplication = ConnectionOptions.Replication;
+ login.useSSPI = ConnectionOptions.IntegratedSecurity // Treat AD Integrated like Windows integrated when against a non-FedAuth endpoint
|| (ConnectionOptions.Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated && !_fedAuthRequired);
- login.PacketSize = _currentPacketSize;
- login.NewPassword = newPassword;
- login.ReadOnlyIntent = ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly;
- login.Credential = _credential;
+ login.packetSize = _currentPacketSize;
+ login.newPassword = newPassword;
+ login.readOnlyIntent = ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly;
+ login.credential = _credential;
if (newSecurePassword != null)
{
- login.NewSecurePassword = newSecurePassword;
+ login.newSecurePassword = newSecurePassword;
}
TdsEnums.FeatureExtension requestedFeatures = TdsEnums.FeatureExtension.None;
@@ -1605,9 +1605,9 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
_fedAuthFeatureExtensionData =
new FederatedAuthenticationFeatureExtensionData
{
- LibraryType = TdsEnums.FedAuthLibrary.MSAL,
- Authentication = ConnectionOptions.Authentication,
- FedAuthRequiredPreLoginResponse = _fedAuthRequired
+ libraryType = TdsEnums.FedAuthLibrary.MSAL,
+ authentication = ConnectionOptions.Authentication,
+ fedAuthRequiredPreLoginResponse = _fedAuthRequired
};
}
@@ -1616,9 +1616,9 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
requestedFeatures |= TdsEnums.FeatureExtension.FedAuth;
_fedAuthFeatureExtensionData = new FederatedAuthenticationFeatureExtensionData
{
- LibraryType = TdsEnums.FedAuthLibrary.SecurityToken,
- FedAuthRequiredPreLoginResponse = _fedAuthRequired,
- AccessToken = _accessTokenInBytes
+ libraryType = TdsEnums.FedAuthLibrary.SecurityToken,
+ fedAuthRequiredPreLoginResponse = _fedAuthRequired,
+ accessToken = _accessTokenInBytes
};
// No need any further info from the server for token based authentication. So set _federatedAuthenticationRequested to true
_federatedAuthenticationRequested = true;
@@ -2563,14 +2563,14 @@ internal void OnLoginAck(SqlLoginAck rec)
// UNDONE: throw an error if this is not 7.0 or 7.1[5].
if (_recoverySessionData != null)
{
- if (_recoverySessionData._tdsVersion != rec.TdsVersion)
+ if (_recoverySessionData._tdsVersion != rec.tdsVersion)
{
throw SQL.CR_TDSVersionNotPreserved(this);
}
}
if (_currentSessionData != null)
{
- _currentSessionData._tdsVersion = rec.TdsVersion;
+ _currentSessionData._tdsVersion = rec.tdsVersion;
}
}
@@ -2607,7 +2607,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo)
Debug.Assert(_dbConnectionPool.AuthenticationContexts != null);
// Construct the dbAuthenticationContextKey with information from FedAuthInfo and store for later use, when inserting in to the token cache.
- _dbConnectionPoolAuthenticationContextKey = new DbConnectionPoolAuthenticationContextKey(fedAuthInfo.StsUrl, fedAuthInfo.Spn);
+ _dbConnectionPoolAuthenticationContextKey = new DbConnectionPoolAuthenticationContextKey(fedAuthInfo.stsurl, fedAuthInfo.spn);
// Try to retrieve the authentication context from the pool, if one does exist for this key.
if (_dbConnectionPool.AuthenticationContexts.TryGetValue(_dbConnectionPoolAuthenticationContextKey, out dbConnectionPoolAuthenticationContext))
@@ -2700,11 +2700,11 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo)
// If the code flow is here, then we are re-using the context from the cache for this connection attempt and not
// generating a new access token on this thread.
- _fedAuthToken.AccessToken = dbConnectionPoolAuthenticationContext.AccessToken;
- _fedAuthToken.ExpirationFileTime = dbConnectionPoolAuthenticationContext.ExpirationTime.ToFileTime();
+ _fedAuthToken.accessToken = dbConnectionPoolAuthenticationContext.AccessToken;
+ _fedAuthToken.expirationFileTime = dbConnectionPoolAuthenticationContext.ExpirationTime.ToFileTime();
}
- Debug.Assert(_fedAuthToken != null && _fedAuthToken.AccessToken != null, "_fedAuthToken and _fedAuthToken.accessToken cannot be null.");
+ Debug.Assert(_fedAuthToken != null && _fedAuthToken.accessToken != null, "_fedAuthToken and _fedAuthToken.accessToken cannot be null.");
_parser.SendFedAuthToken(_fedAuthToken);
}
@@ -2801,8 +2801,8 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
{
var authParamsBuilder = new SqlAuthenticationParameters.Builder(
authenticationMethod: ConnectionOptions.Authentication,
- resource: fedAuthInfo.Spn,
- authority: fedAuthInfo.StsUrl,
+ resource: fedAuthInfo.spn,
+ authority: fedAuthInfo.stsurl,
serverName: ConnectionOptions.DataSource,
databaseName: ConnectionOptions.InitialCatalog)
.WithConnectionId(_clientConnectionId)
@@ -2898,7 +2898,7 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
break;
}
- Debug.Assert(_fedAuthToken.AccessToken != null, "AccessToken should not be null.");
+ Debug.Assert(_fedAuthToken.accessToken != null, "AccessToken should not be null.");
#if DEBUG
if (_forceMsalRetry)
{
@@ -2967,13 +2967,13 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
}
Debug.Assert(_fedAuthToken != null, "fedAuthToken should not be null.");
- Debug.Assert(_fedAuthToken.AccessToken != null && _fedAuthToken.AccessToken.Length > 0, "fedAuthToken.accessToken should not be null or empty.");
+ Debug.Assert(_fedAuthToken.accessToken != null && _fedAuthToken.accessToken.Length > 0, "fedAuthToken.accessToken should not be null or empty.");
// Store the newly generated token in _newDbConnectionPoolAuthenticationContext, only if using pooling.
if (_dbConnectionPool != null)
{
- DateTime expirationTime = DateTime.FromFileTimeUtc(_fedAuthToken.ExpirationFileTime);
- _newDbConnectionPoolAuthenticationContext = new DbConnectionPoolAuthenticationContext(_fedAuthToken.AccessToken, expirationTime);
+ DateTime expirationTime = DateTime.FromFileTimeUtc(_fedAuthToken.expirationFileTime);
+ _newDbConnectionPoolAuthenticationContext = new DbConnectionPoolAuthenticationContext(_fedAuthToken.accessToken, expirationTime);
}
SqlClientEventSource.Log.TryTraceEvent(" {0}, Finished generating federated authentication token.", ObjectID);
return _fedAuthToken;
@@ -3052,7 +3052,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data)
Debug.Assert(_fedAuthFeatureExtensionData != null, "_fedAuthFeatureExtensionData must not be null when _federatedAuthenticationRequested == true");
- switch (_fedAuthFeatureExtensionData.LibraryType)
+ switch (_fedAuthFeatureExtensionData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
case TdsEnums.FedAuthLibrary.SecurityToken:
@@ -3068,7 +3068,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data)
Debug.Fail("Unknown _fedAuthLibrary type");
SqlClientEventSource.Log.TryTraceEvent(" {0}, Attempting to use unknown federated authentication library", ObjectID);
- throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.LibraryType);
+ throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.libraryType);
}
_federatedAuthenticationAcknowledged = true;
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
index 09d91fe1cc..fb0884bb36 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -4303,9 +4303,9 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
{
return result;
}
- a.TdsVersion = (uint)((((((b[0] << 8) | b[1]) << 8) | b[2]) << 8) | b[3]); // bytes are in motorola order (high byte first)
- uint majorMinor = a.TdsVersion & 0xff00ffff;
- uint increment = (a.TdsVersion >> 16) & 0xff;
+ a.tdsVersion = (uint)((((((b[0] << 8) | b[1]) << 8) | b[2]) << 8) | b[3]); // bytes are in motorola order (high byte first)
+ uint majorMinor = a.tdsVersion & 0xff00ffff;
+ uint increment = (a.tdsVersion >> 16) & 0xff;
// Server responds:
// 0x07000000 -> 7.0 // Notice server response format is different for bwd compat
@@ -4364,7 +4364,7 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
_is2000SP1 |= _is2005; // includes all lower versions
_is2000 |= _is2000SP1; //
- a.IsVersion8 = _is2000;
+ a.isVersion8 = _is2000;
stateObj._outBytesUsed = stateObj._outputHeaderLen;
byte len;
@@ -4374,17 +4374,17 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
return result;
}
- result = stateObj.TryReadString(len, out a.ProgramName);
+ result = stateObj.TryReadString(len, out a.programName);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out a.MajorVersion);
+ result = stateObj.TryReadByte(out a.majorVersion);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out a.MinorVersion);
+ result = stateObj.TryReadByte(out a.minorVersion);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4401,7 +4401,7 @@ private TdsOperationStatus TryProcessLoginAck(TdsParserStateObject stateObj, out
return result;
}
- a.BuildNum = (short)((buildNumHi << 8) + buildNumLo);
+ a.buildNum = (short)((buildNumHi << 8) + buildNumLo);
Debug.Assert(_state == TdsParserState.OpenNotLoggedIn, "ProcessLoginAck called with state not TdsParserState.OpenNotLoggedIn");
_state = TdsParserState.OpenLoggedIn;
@@ -4529,10 +4529,10 @@ private TdsOperationStatus TryProcessFedAuthInfo(TdsParserStateObject stateObj,
switch ((TdsEnums.FedAuthInfoId)id)
{
case TdsEnums.FedAuthInfoId.Spn:
- tempFedAuthInfo.Spn = data;
+ tempFedAuthInfo.spn = data;
break;
case TdsEnums.FedAuthInfoId.Stsurl:
- tempFedAuthInfo.StsUrl = data;
+ tempFedAuthInfo.stsurl = data;
break;
default:
SqlClientEventSource.Log.TryAdvancedTraceEvent(" Ignoring unknown federated authentication info option: {0}", id);
@@ -4547,7 +4547,7 @@ private TdsOperationStatus TryProcessFedAuthInfo(TdsParserStateObject stateObj,
}
SqlClientEventSource.Log.TryTraceEvent(" Processed FEDAUTHINFO token stream: {0}", tempFedAuthInfo);
- if (string.IsNullOrWhiteSpace(tempFedAuthInfo.StsUrl) || string.IsNullOrWhiteSpace(tempFedAuthInfo.Spn))
+ if (string.IsNullOrWhiteSpace(tempFedAuthInfo.stsurl) || string.IsNullOrWhiteSpace(tempFedAuthInfo.spn))
{
// We should be receiving both stsurl and spn
SqlClientEventSource.Log.TryTraceEvent(" FEDAUTHINFO token stream does not contain both STSURL and SPN.");
@@ -4695,10 +4695,10 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
TdsOperationStatus result;
returnValue = null;
SqlReturnValue rec = new SqlReturnValue();
- rec.Length = length; // In 2005 this length is -1
+ rec.length = length; // In 2005 this length is -1
if (_is2005)
{
- result = stateObj.TryReadUInt16(out rec.ParmIndex);
+ result = stateObj.TryReadUInt16(out rec.parmIndex);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4710,10 +4710,10 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
{
return result;
}
- rec.Parameter = null;
+ rec.parameter = null;
if (len > 0)
{
- result = stateObj.TryReadString(len, out rec.Parameter);
+ result = stateObj.TryReadString(len, out rec.parameter);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4767,7 +4767,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
// Check if the column is encrypted.
if (_serverSupportsColumnEncryption)
{
- rec.IsEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ rec.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// read the type
@@ -4801,46 +4801,46 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
}
}
- rec.MetaType = MetaType.GetSqlDataType(tdsType, userType, tdsLen);
- rec.Type = rec.MetaType.SqlDbType;
+ rec.metaType = MetaType.GetSqlDataType(tdsType, userType, tdsLen);
+ rec.type = rec.metaType.SqlDbType;
// always use the nullable type for parameters if 2000 or later
// 7.0 sometimes sends fixed length return values
if (_is2000)
{
- rec.TdsType = rec.MetaType.NullableType;
+ rec.tdsType = rec.metaType.NullableType;
rec.IsNullable = true;
if (tdsLen == TdsEnums.SQL_USHORTVARMAXLEN)
{
Debug.Assert(_is2005, "plp data from pre-2005 server");
- rec.MetaType = MetaType.GetMaxMetaTypeFromMetaType(rec.MetaType);
+ rec.metaType = MetaType.GetMaxMetaTypeFromMetaType(rec.metaType);
}
}
else
{ // For 7.0, keep the fixed type if that is what is returned
- if (rec.MetaType.NullableType == tdsType)
+ if (rec.metaType.NullableType == tdsType)
rec.IsNullable = true;
- rec.TdsType = (byte)tdsType;
+ rec.tdsType = (byte)tdsType;
}
- if (rec.Type == SqlDbType.Decimal)
+ if (rec.type == SqlDbType.Decimal)
{
- result = stateObj.TryReadByte(out rec.Precision);
+ result = stateObj.TryReadByte(out rec.precision);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out rec.Scale);
+ result = stateObj.TryReadByte(out rec.scale);
if (result != TdsOperationStatus.Done)
{
return result;
}
}
- if (rec.MetaType.IsVarTime)
+ if (rec.metaType.IsVarTime)
{
- result = stateObj.TryReadByte(out rec.Scale);
+ result = stateObj.TryReadByte(out rec.scale);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4856,7 +4856,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
}
}
- if (rec.Type == SqlDbType.Xml)
+ if (rec.type == SqlDbType.Xml)
{
// Read schema info
byte schemapresent;
@@ -4873,13 +4873,13 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
{
return result;
}
- if (rec.XmlSchemaCollection is null)
+ if (rec.xmlSchemaCollection is null)
{
- rec.XmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
+ rec.xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
}
if (len != 0)
{
- result = stateObj.TryReadString(len, out rec.XmlSchemaCollection.Database);
+ result = stateObj.TryReadString(len, out rec.xmlSchemaCollection.Database);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4893,7 +4893,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
}
if (len != 0)
{
- result = stateObj.TryReadString(len, out rec.XmlSchemaCollection.OwningSchema);
+ result = stateObj.TryReadString(len, out rec.xmlSchemaCollection.OwningSchema);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4909,7 +4909,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
if (slen != 0)
{
- result = stateObj.TryReadString(slen, out rec.XmlSchemaCollection.Name);
+ result = stateObj.TryReadString(slen, out rec.xmlSchemaCollection.Name);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -4918,39 +4918,39 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
}
}
- else if (_is2000 && rec.MetaType.IsCharType)
+ else if (_is2000 && rec.metaType.IsCharType)
{
// read the collation for 8.x servers
- result = TryProcessCollation(stateObj, out rec.Collation);
+ result = TryProcessCollation(stateObj, out rec.collation);
if (result != TdsOperationStatus.Done)
{
return result;
}
- if (rec.Collation.IsUTF8)
+ if (rec.collation.IsUTF8)
{ // UTF8 collation
- rec.Encoding = Encoding.UTF8;
+ rec.encoding = Encoding.UTF8;
}
else
{
- int codePage = GetCodePage(rec.Collation, stateObj);
+ int codePage = GetCodePage(rec.collation, stateObj);
// if the column lcid is the same as the default, use the default encoder
if (codePage == _defaultCodePage)
{
- rec.CodePage = _defaultCodePage;
- rec.Encoding = _defaultEncoding;
+ rec.codePage = _defaultCodePage;
+ rec.encoding = _defaultEncoding;
}
else
{
- rec.CodePage = codePage;
- rec.Encoding = System.Text.Encoding.GetEncoding(rec.CodePage);
+ rec.codePage = codePage;
+ rec.encoding = System.Text.Encoding.GetEncoding(rec.codePage);
}
}
}
// For encrypted parameters, read the unencrypted type and encryption information.
- if (_serverSupportsColumnEncryption && rec.IsEncrypted)
+ if (_serverSupportsColumnEncryption && rec.isEncrypted)
{
result = TryProcessTceCryptoMetadata(stateObj, rec, cipherTable: null, columnEncryptionSetting: columnEncryptionSetting, isReturnValue: true);
if (result != TdsOperationStatus.Done)
@@ -4973,20 +4973,20 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
int intlen = valLen > (ulong)(Int32.MaxValue) ? Int32.MaxValue : (int)valLen;
- if (rec.MetaType.IsPlp)
+ if (rec.metaType.IsPlp)
{
intlen = Int32.MaxValue; // If plp data, read it all
}
if (isNull)
{
- GetNullSqlValue(rec.Value, rec, SqlCommandColumnEncryptionSetting.Disabled, _connHandler);
+ GetNullSqlValue(rec.value, rec, SqlCommandColumnEncryptionSetting.Disabled, _connHandler);
}
else
{
// We should never do any decryption here, so pass disabled as the command encryption override.
// We only read the binary value and decryption will be performed by OnReturnValue().
- result = TryReadSqlValue(rec.Value, rec, intlen, stateObj, SqlCommandColumnEncryptionSetting.Disabled, columnName: null /*Not used*/);
+ result = TryReadSqlValue(rec.value, rec, intlen, stateObj, SqlCommandColumnEncryptionSetting.Disabled, columnName: null /*Not used*/);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5035,8 +5035,8 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
}
// Read the base TypeInfo
- col.BaseTI = new SqlMetaDataPriv();
- result = TryProcessTypeInfo(stateObj, col.BaseTI, userType);
+ col.baseTI = new SqlMetaDataPriv();
+ result = TryProcessTypeInfo(stateObj, col.baseTI, userType);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5084,7 +5084,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
return result;
}
- Debug.Assert(col.CipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
+ Debug.Assert(col.cipherMD == null, "col.cipherMD should be null in TryProcessTceCryptoMetadata.");
// Check if TCE is enable and if it is set the crypto MD for the column.
// TCE is enabled if the command is set to enabled or to resultset only and this is not a return value
@@ -5095,7 +5095,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
_connHandler != null && _connHandler.ConnectionOptions != null &&
_connHandler.ConnectionOptions.ColumnEncryptionSetting == SqlConnectionColumnEncryptionSetting.Enabled))
{
- col.CipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
+ col.cipherMD = new SqlCipherMetadata(cipherTable != null ? (SqlTceCipherInfoEntry)cipherTable[index] : null,
index,
cipherAlgorithmId: cipherAlgorithmId,
cipherAlgorithmName: cipherAlgorithmName,
@@ -5105,7 +5105,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta
else
{
// If TCE is disabled mark the MD as not encrypted.
- col.IsEncrypted = false;
+ col.isEncrypted = false;
}
return TdsOperationStatus.Done;
@@ -5297,7 +5297,7 @@ internal void DrainData(TdsParserStateObject stateObj)
// iia. if we still have bytes left from a partially read column, skip
if (sharedState._nextColumnDataToRead < sharedState._nextColumnHeaderToRead)
{
- if ((sharedState._nextColumnHeaderToRead > 0) && (metadata[sharedState._nextColumnHeaderToRead - 1].MetaType.IsPlp))
+ if ((sharedState._nextColumnHeaderToRead > 0) && (metadata[sharedState._nextColumnHeaderToRead - 1].metaType.IsPlp))
{
if (stateObj._longlen != 0)
{
@@ -5386,7 +5386,7 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
metaData = null;
_SqlMetaDataSet altMetaDataSet = new _SqlMetaDataSet(cColumns, null);
- TdsOperationStatus result = stateObj.TryReadUInt16(out altMetaDataSet.Id);
+ TdsOperationStatus result = stateObj.TryReadUInt16(out altMetaDataSet.id);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5415,12 +5415,12 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
// internal meta data class
_SqlMetaData col = altMetaDataSet[i];
- result = stateObj.TryReadByte(out col.Op);
+ result = stateObj.TryReadByte(out col.op);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadUInt16(out col.Operand);
+ result = stateObj.TryReadUInt16(out col.operand);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5433,57 +5433,57 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
return result;
}
- if (ADP.IsEmpty(col.Column))
+ if (ADP.IsEmpty(col.column))
{
// create column name from op
- switch (col.Op)
+ switch (col.op)
{
case TdsEnums.AOPAVG:
- col.Column = "avg";
+ col.column = "avg";
break;
case TdsEnums.AOPCNT:
- col.Column = "cnt";
+ col.column = "cnt";
break;
case TdsEnums.AOPCNTB:
- col.Column = "cntb";
+ col.column = "cntb";
break;
case TdsEnums.AOPMAX:
- col.Column = "max";
+ col.column = "max";
break;
case TdsEnums.AOPMIN:
- col.Column = "min";
+ col.column = "min";
break;
case TdsEnums.AOPSUM:
- col.Column = "sum";
+ col.column = "sum";
break;
case TdsEnums.AOPANY:
- col.Column = "any";
+ col.column = "any";
break;
case TdsEnums.AOPNOOP:
- col.Column = "noop";
+ col.column = "noop";
break;
case TdsEnums.AOPSTDEV:
- col.Column = "stdev";
+ col.column = "stdev";
break;
case TdsEnums.AOPSTDEVP:
- col.Column = "stdevp";
+ col.column = "stdevp";
break;
case TdsEnums.AOPVAR:
- col.Column = "var";
+ col.column = "var";
break;
case TdsEnums.AOPVARP:
- col.Column = "varp";
+ col.column = "varp";
break;
}
}
@@ -5718,30 +5718,30 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
if (tdsType == TdsEnums.SQLXMLTYPE)
- col.Length = TdsEnums.SQL_USHORTVARMAXLEN; //Use the same length as other plp datatypes
+ col.length = TdsEnums.SQL_USHORTVARMAXLEN; //Use the same length as other plp datatypes
else if (IsVarTimeTds(tdsType))
- col.Length = 0; // placeholder until we read the scale, just make sure it's not SQL_USHORTVARMAXLEN
+ col.length = 0; // placeholder until we read the scale, just make sure it's not SQL_USHORTVARMAXLEN
else if (tdsType == TdsEnums.SQLDATE)
{
- col.Length = 3;
+ col.length = 3;
}
else
{
- result = TryGetTokenLength(tdsType, stateObj, out col.Length);
+ result = TryGetTokenLength(tdsType, stateObj, out col.length);
if (result != TdsOperationStatus.Done)
{
return result;
}
}
- col.MetaType = MetaType.GetSqlDataType(tdsType, userType, col.Length);
- col.Type = col.MetaType.SqlDbType;
+ col.metaType = MetaType.GetSqlDataType(tdsType, userType, col.length);
+ col.type = col.metaType.SqlDbType;
// If 7.0, do not change to nullable type
if (_is2000)
- col.TdsType = (col.IsNullable ? col.MetaType.NullableType : col.MetaType.TDSType);
+ col.tdsType = (col.IsNullable ? col.metaType.NullableType : col.metaType.TDSType);
else
- col.TdsType = tdsType;
+ col.tdsType = tdsType;
if (_is2005)
{
@@ -5754,7 +5754,7 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
}
- if (col.Length == TdsEnums.SQL_USHORTVARMAXLEN)
+ if (col.length == TdsEnums.SQL_USHORTVARMAXLEN)
{
Debug.Assert(tdsType == TdsEnums.SQLXMLTYPE ||
tdsType == TdsEnums.SQLBIGVARCHAR ||
@@ -5762,9 +5762,9 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
tdsType == TdsEnums.SQLNVARCHAR ||
tdsType == TdsEnums.SQLUDT,
"Invalid streaming datatype");
- col.MetaType = MetaType.GetMaxMetaTypeFromMetaType(col.MetaType);
- Debug.Assert(col.MetaType.IsLong, "Max datatype not IsLong");
- col.Length = Int32.MaxValue;
+ col.metaType = MetaType.GetMaxMetaTypeFromMetaType(col.metaType);
+ Debug.Assert(col.metaType.IsLong, "Max datatype not IsLong");
+ col.length = Int32.MaxValue;
if (tdsType == TdsEnums.SQLXMLTYPE)
{
byte schemapresent;
@@ -5781,13 +5781,13 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
{
return result;
}
- if (col.XmlSchemaCollection is null)
+ if (col.xmlSchemaCollection is null)
{
- col.XmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
+ col.xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
}
if (byteLen != 0)
{
- result = stateObj.TryReadString(byteLen, out col.XmlSchemaCollection.Database);
+ result = stateObj.TryReadString(byteLen, out col.xmlSchemaCollection.Database);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5801,7 +5801,7 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
if (byteLen != 0)
{
- result = stateObj.TryReadString(byteLen, out col.XmlSchemaCollection.OwningSchema);
+ result = stateObj.TryReadString(byteLen, out col.xmlSchemaCollection.OwningSchema);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5816,7 +5816,7 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
if (byteLen != 0)
{
- result = stateObj.TryReadString(shortLen, out col.XmlSchemaCollection.Name);
+ result = stateObj.TryReadString(shortLen, out col.xmlSchemaCollection.Name);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5827,44 +5827,44 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
}
- if (col.Type == SqlDbType.Decimal)
+ if (col.type == SqlDbType.Decimal)
{
- result = stateObj.TryReadByte(out col.Precision);
+ result = stateObj.TryReadByte(out col.precision);
if (result != TdsOperationStatus.Done)
{
return result;
}
- result = stateObj.TryReadByte(out col.Scale);
+ result = stateObj.TryReadByte(out col.scale);
if (result != TdsOperationStatus.Done)
{
return result;
}
}
- if (col.MetaType.IsVarTime)
+ if (col.metaType.IsVarTime)
{
- result = stateObj.TryReadByte(out col.Scale);
+ result = stateObj.TryReadByte(out col.scale);
if (result != TdsOperationStatus.Done)
{
return result;
}
- Debug.Assert(0 <= col.Scale && col.Scale <= 7);
+ Debug.Assert(0 <= col.scale && col.scale <= 7);
// calculate actual column length here
// TODO: variable-length calculation needs to be encapsulated better
- switch (col.MetaType.SqlDbType)
+ switch (col.metaType.SqlDbType)
{
case SqlDbType.Time:
- col.Length = MetaType.GetTimeSizeFromScale(col.Scale);
+ col.length = MetaType.GetTimeSizeFromScale(col.scale);
break;
case SqlDbType.DateTime2:
// Date in number of days (3 bytes) + time
- col.Length = 3 + MetaType.GetTimeSizeFromScale(col.Scale);
+ col.length = 3 + MetaType.GetTimeSizeFromScale(col.scale);
break;
case SqlDbType.DateTimeOffset:
// Date in days (3 bytes) + offset in minutes (2 bytes) + time
- col.Length = 5 + MetaType.GetTimeSizeFromScale(col.Scale);
+ col.length = 5 + MetaType.GetTimeSizeFromScale(col.scale);
break;
default:
@@ -5874,31 +5874,31 @@ private TdsOperationStatus TryProcessTypeInfo(TdsParserStateObject stateObj, Sql
}
// read the collation for 7.x servers
- if (_is2000 && col.MetaType.IsCharType && (tdsType != TdsEnums.SQLXMLTYPE))
+ if (_is2000 && col.metaType.IsCharType && (tdsType != TdsEnums.SQLXMLTYPE))
{
- result = TryProcessCollation(stateObj, out col.Collation);
+ result = TryProcessCollation(stateObj, out col.collation);
if (result != TdsOperationStatus.Done)
{
return result;
}
- if (col.Collation.IsUTF8)
+ if (col.collation.IsUTF8)
{ // UTF8 collation
- col.Encoding = Encoding.UTF8;
+ col.encoding = Encoding.UTF8;
}
else
{
- int codePage = GetCodePage(col.Collation, stateObj);
+ int codePage = GetCodePage(col.collation, stateObj);
if (codePage == _defaultCodePage)
{
- col.CodePage = _defaultCodePage;
- col.Encoding = _defaultEncoding;
+ col.codePage = _defaultCodePage;
+ col.encoding = _defaultEncoding;
}
else
{
- col.CodePage = codePage;
- col.Encoding = System.Text.Encoding.GetEncoding(col.CodePage);
+ col.codePage = codePage;
+ col.encoding = System.Text.Encoding.GetEncoding(col.codePage);
}
}
}
@@ -5954,7 +5954,7 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
col.IsColumnSet = (TdsEnums.IsColumnSet == (flags & TdsEnums.IsColumnSet));
if (fColMD && _serverSupportsColumnEncryption)
{
- col.IsEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
+ col.isEncrypted = (TdsEnums.IsEncrypted == (flags & TdsEnums.IsEncrypted));
}
// Read TypeInfo
@@ -5965,12 +5965,12 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
}
// Read tablename if present
- if (col.MetaType.IsLong && !col.MetaType.IsPlp)
+ if (col.metaType.IsLong && !col.metaType.IsPlp)
{
if (_is2005)
{
int unusedLen = 0xFFFF; //We ignore this value
- result = TryProcessOneTable(stateObj, ref unusedLen, out col.MultiPartTableName);
+ result = TryProcessOneTable(stateObj, ref unusedLen, out col.multiPartTableName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -5994,12 +5994,12 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
// all of which may contain "." and unable to parse correctly from the string alone
// example "select * from pubs..[A.B.C.D.E]" AND only when * will contain a image/text/ntext column
// by delay parsing from execute to SqlDataReader.GetSchemaTable to enable more scenarios
- col.MultiPartTableName = new MultiPartTableName(tableName);
+ col.multiPartTableName = new MultiPartTableName(tableName);
}
}
// Read the TCE column cryptoinfo
- if (fColMD && _serverSupportsColumnEncryption && col.IsEncrypted)
+ if (fColMD && _serverSupportsColumnEncryption && col.isEncrypted)
{
// If the column is encrypted, we should have a valid cipherTable
if (cipherTable != null)
@@ -6018,7 +6018,7 @@ private TdsOperationStatus TryCommonProcessMetaData(TdsParserStateObject stateOb
{
return result;
}
- result = stateObj.TryReadString(byteLen, out col.Column);
+ result = stateObj.TryReadString(byteLen, out col.column);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6041,7 +6041,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
{
return result;
}
- metaData.Length = shortLength;
+ metaData.length = shortLength;
// database name
result = stateObj.TryReadByte(out byteLength);
@@ -6049,13 +6049,13 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
{
return result;
}
- if (metaData.Udt is null)
+ if (metaData.udt is null)
{
- metaData.Udt = new SqlMetaDataUdt();
+ metaData.udt = new SqlMetaDataUdt();
}
if (byteLength != 0)
{
- result = stateObj.TryReadString(byteLength, out metaData.Udt.DatabaseName);
+ result = stateObj.TryReadString(byteLength, out metaData.udt.DatabaseName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6070,7 +6070,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
}
if (byteLength != 0)
{
- result = stateObj.TryReadString(byteLength, out metaData.Udt.SchemaName);
+ result = stateObj.TryReadString(byteLength, out metaData.udt.SchemaName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6085,7 +6085,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
}
if (byteLength != 0)
{
- result = stateObj.TryReadString(byteLength, out metaData.Udt.TypeName);
+ result = stateObj.TryReadString(byteLength, out metaData.udt.TypeName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6099,7 +6099,7 @@ private TdsOperationStatus TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsPa
}
if (shortLength != 0)
{
- result = stateObj.TryReadString(shortLength, out metaData.Udt.AssemblyQualifiedName);
+ result = stateObj.TryReadString(shortLength, out metaData.udt.AssemblyQualifiedName);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6313,7 +6313,7 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
{
return result;
}
- result = stateObj.TryReadByte(out col.TableNum);
+ result = stateObj.TryReadByte(out col.tableNum);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6341,7 +6341,7 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
{
return result;
}
- result = stateObj.TryReadString(len, out col.BaseColumn);
+ result = stateObj.TryReadString(len, out col.baseColumn);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6350,10 +6350,10 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
// Fixup column name - only if result of a table - that is if it was not the result of
// an expression.
- if ((reader.TableNames != null) && (col.TableNum > 0))
+ if ((reader.TableNames != null) && (col.tableNum > 0))
{
- Debug.Assert(reader.TableNames.Length >= col.TableNum, "invalid tableNames array!");
- col.MultiPartTableName = reader.TableNames[col.TableNum - 1];
+ Debug.Assert(reader.TableNames.Length >= col.tableNum, "invalid tableNames array!");
+ col.multiPartTableName = reader.TableNames[col.tableNum - 1];
}
// MDAC 60109: expressions are readonly
@@ -6388,7 +6388,7 @@ internal TdsOperationStatus TryProcessColumnHeader(SqlMetaDataPriv col, TdsParse
private TdsOperationStatus TryProcessColumnHeaderNoNBC(SqlMetaDataPriv col, TdsParserStateObject stateObj, out bool isNull, out ulong length)
{
- if (col.MetaType.IsLong && !col.MetaType.IsPlp)
+ if (col.metaType.IsLong && !col.metaType.IsPlp)
{
//
// we don't care about TextPtrs, simply go after the data after it
@@ -6444,7 +6444,7 @@ private TdsOperationStatus TryProcessColumnHeaderNoNBC(SqlMetaDataPriv col, TdsP
length = 0;
return result;
}
- isNull = IsNull(col.MetaType, longlen);
+ isNull = IsNull(col.metaType, longlen);
length = (isNull ? 0 : longlen);
return TdsOperationStatus.Done;
}
@@ -6511,9 +6511,9 @@ private TdsOperationStatus TryProcessRow(_SqlMetaDataSet columns, object[] buffe
// We only read up to 2Gb. Throw if data is larger. Very large data
// should be read in chunks in sequential read mode
// For Plp columns, we may have gotten only the length of the first chunk
- result = TryReadSqlValue(data, md, md.MetaType.IsPlp ? (Int32.MaxValue) : (int)len, stateObj,
+ result = TryReadSqlValue(data, md, md.metaType.IsPlp ? (Int32.MaxValue) : (int)len, stateObj,
SqlCommandColumnEncryptionSetting.Disabled /*Column Encryption Disabled for Bulk Copy*/,
- md.Column);
+ md.column);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6562,13 +6562,13 @@ internal static object GetNullSqlValue(
SqlCommandColumnEncryptionSetting columnEncryptionSetting,
SqlInternalConnectionTds connection)
{
- SqlDbType type = md.Type;
+ SqlDbType type = md.type;
if (type == SqlDbType.VarBinary && // if its a varbinary
- md.IsEncrypted &&// and encrypted
+ md.isEncrypted &&// and encrypted
ShouldHonorTceForRead(columnEncryptionSetting, connection))
{
- type = md.BaseTI.Type; // the use the actual (plaintext) type
+ type = md.baseTI.type; // the use the actual (plaintext) type
}
switch (type)
@@ -6668,7 +6668,7 @@ internal static object GetNullSqlValue(
break;
default:
- Debug.Fail("unknown null sqlType!" + md.Type.ToString());
+ Debug.Fail("unknown null sqlType!" + md.type.ToString());
break;
}
@@ -6707,7 +6707,7 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
TdsOperationStatus result;
- if (md.MetaType.IsPlp)
+ if (md.metaType.IsPlp)
{
result = TrySkipPlpValue(UInt64.MaxValue, stateObj, out _);
if (result != TdsOperationStatus.Done)
@@ -6715,10 +6715,10 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
return result;
}
}
- else if (md.MetaType.IsLong)
+ else if (md.metaType.IsLong)
{
- Debug.Assert(!md.MetaType.IsPlp, "Plp types must be handled using SkipPlpValue");
+ Debug.Assert(!md.metaType.IsPlp, "Plp types must be handled using SkipPlpValue");
byte textPtrLen;
result = stateObj.TryReadByte(out textPtrLen);
@@ -6736,7 +6736,7 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
}
int length;
- result = TryGetTokenLength(md.TdsType, stateObj, out length);
+ result = TryGetTokenLength(md.tdsType, stateObj, out length);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -6751,14 +6751,14 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,
else
{
int length;
- result = TryGetTokenLength(md.TdsType, stateObj, out length);
+ result = TryGetTokenLength(md.tdsType, stateObj, out length);
if (result != TdsOperationStatus.Done)
{
return result;
}
// if false, no value to skip - it's null
- if (!IsNull(md.MetaType, (ulong)length))
+ if (!IsNull(md.metaType, (ulong)length))
{
result = stateObj.TrySkipBytes(length);
if (result != TdsOperationStatus.Done)
@@ -6873,14 +6873,14 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
throw SQL.UnsupportedNormalizationVersion(normalizationVersion);
}
- byte tdsType = md.BaseTI.TdsType;
+ byte tdsType = md.baseTI.tdsType;
int length = unencryptedBytes.Length;
// For normalized types, the length and scale of the actual type might be different than the value's.
- int denormalizedLength = md.BaseTI.Length;
- byte denormalizedScale = md.BaseTI.Scale;
+ int denormalizedLength = md.baseTI.length;
+ byte denormalizedScale = md.baseTI.scale;
- Debug.Assert(false == md.BaseTI.IsEncrypted, "Double encryption detected");
+ Debug.Assert(false == md.baseTI.isEncrypted, "Double encryption detected");
switch (tdsType)
{
// We normalize to allow conversion across data types. All data types below are serialized into a BIGINT.
@@ -7028,7 +7028,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with zeros to get to the fixed length size.
if (tdsType == TdsEnums.SQLBINARY || tdsType == TdsEnums.SQLBIGBINARY)
{
- byte[] bytes = new byte[md.BaseTI.Length];
+ byte[] bytes = new byte[md.baseTI.length];
Buffer.BlockCopy(unencryptedBytes, 0, bytes, 0, unencryptedBytes.Length);
unencryptedBytes = bytes;
}
@@ -7054,7 +7054,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
bits[i] = BitConverter.ToInt32(unencryptedBytes, index);
index += 4;
}
- value.SetToDecimal(md.BaseTI.Precision, md.BaseTI.Scale, fPositive, bits);
+ value.SetToDecimal(md.baseTI.precision, md.baseTI.scale, fPositive, bits);
break;
case TdsEnums.SQLCHAR:
@@ -7063,7 +7063,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
case TdsEnums.SQLBIGVARCHAR:
case TdsEnums.SQLTEXT:
{
- System.Text.Encoding encoding = md.BaseTI.Encoding;
+ System.Text.Encoding encoding = md.baseTI.encoding;
if (encoding == null)
{
@@ -7080,7 +7080,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLCHAR || tdsType == TdsEnums.SQLBIGCHAR)
{
- strValue = strValue.PadRight(md.BaseTI.Length);
+ strValue = strValue.PadRight(md.baseTI.length);
}
value.SetToString(strValue);
@@ -7096,7 +7096,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
// If this is a fixed length type, pad with spaces to get to the fixed length size.
if (tdsType == TdsEnums.SQLNCHAR)
{
- strValue = strValue.PadRight(md.BaseTI.Length / ADP.CharSize);
+ strValue = strValue.PadRight(md.baseTI.length / ADP.CharSize);
}
value.SetToString(strValue);
@@ -7127,7 +7127,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
break;
default:
- MetaType metaType = md.BaseTI.MetaType;
+ MetaType metaType = md.baseTI.metaType;
// If we don't have a metatype already, construct one to get the proper type name.
if (metaType == null)
@@ -7149,10 +7149,10 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value,
string columnName,
SqlCommand command = null)
{
- bool isPlp = md.MetaType.IsPlp;
- byte tdsType = md.TdsType;
+ bool isPlp = md.metaType.IsPlp;
+ byte tdsType = md.tdsType;
TdsOperationStatus result;
- Debug.Assert(isPlp || !IsNull(md.MetaType, (ulong)length), "null value should not get here!");
+ Debug.Assert(isPlp || !IsNull(md.metaType, (ulong)length), "null value should not get here!");
if (isPlp)
{
// We must read the column value completely, no matter what length is passed in
@@ -7165,7 +7165,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value,
{
case TdsEnums.SQLDECIMALN:
case TdsEnums.SQLNUMERICN:
- result = TryReadSqlDecimal(value, length, md.Precision, md.Scale, stateObj);
+ result = TryReadSqlDecimal(value, length, md.precision, md.scale, stateObj);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -7202,7 +7202,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value,
}
}
- if (md.IsEncrypted
+ if (md.isEncrypted
&& ((columnEncryptionOverride == SqlCommandColumnEncryptionSetting.Enabled
|| columnEncryptionOverride == SqlCommandColumnEncryptionSetting.ResultSetOnly)
|| (columnEncryptionOverride == SqlCommandColumnEncryptionSetting.UseConnectionSetting
@@ -7212,7 +7212,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value,
try
{
// CipherInfo is present, decrypt and read
- byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md.CipherMD, _connHandler.Connection, command);
+ byte[] unencryptedBytes = SqlSecurityUtility.DecryptWithKey(b, md.cipherMD, _connHandler.Connection, command);
if (unencryptedBytes != null)
{
@@ -7251,7 +7251,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value,
case TdsEnums.SQLNCHAR:
case TdsEnums.SQLNVARCHAR:
case TdsEnums.SQLNTEXT:
- result = TryReadSqlStringValue(value, tdsType, length, md.Encoding, isPlp, stateObj);
+ result = TryReadSqlStringValue(value, tdsType, length, md.encoding, isPlp, stateObj);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -7274,7 +7274,7 @@ internal TdsOperationStatus TryReadSqlValue(SqlBuffer value,
case TdsEnums.SQLTIME:
case TdsEnums.SQLDATETIME2:
case TdsEnums.SQLDATETIMEOFFSET:
- result = TryReadSqlDateTime(value, tdsType, length, md.Scale, stateObj);
+ result = TryReadSqlDateTime(value, tdsType, length, md.scale, stateObj);
if (result != TdsOperationStatus.Done)
{
return result;
@@ -8769,21 +8769,21 @@ internal int GetEncodingCharLength(string value, int numChars, int charOffset, E
internal TdsOperationStatus TryGetDataLength(SqlMetaDataPriv colmeta, TdsParserStateObject stateObj, out ulong length)
{
// Handle 2005 specific tokens
- if (_is2005 && colmeta.MetaType.IsPlp)
+ if (_is2005 && colmeta.metaType.IsPlp)
{
- Debug.Assert(colmeta.TdsType == TdsEnums.SQLXMLTYPE ||
- colmeta.TdsType == TdsEnums.SQLBIGVARCHAR ||
- colmeta.TdsType == TdsEnums.SQLBIGVARBINARY ||
- colmeta.TdsType == TdsEnums.SQLNVARCHAR ||
+ Debug.Assert(colmeta.tdsType == TdsEnums.SQLXMLTYPE ||
+ colmeta.tdsType == TdsEnums.SQLBIGVARCHAR ||
+ colmeta.tdsType == TdsEnums.SQLBIGVARBINARY ||
+ colmeta.tdsType == TdsEnums.SQLNVARCHAR ||
// Large UDTs is WinFS-only
- colmeta.TdsType == TdsEnums.SQLUDT,
+ colmeta.tdsType == TdsEnums.SQLUDT,
"GetDataLength:Invalid streaming datatype");
return stateObj.TryReadPlpLength(true, out length);
}
else
{
int intLength;
- TdsOperationStatus result = TryGetTokenLength(colmeta.TdsType, stateObj, out intLength);
+ TdsOperationStatus result = TryGetTokenLength(colmeta.tdsType, stateObj, out intLength);
if (result != TdsOperationStatus.Done)
{
length = 0;
@@ -9050,21 +9050,21 @@ static private int StateValueLength(int dataLen)
internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionData fedAuthFeatureData,
bool write /* if false just calculates the length */)
{
- Debug.Assert(fedAuthFeatureData.LibraryType == TdsEnums.FedAuthLibrary.MSAL || fedAuthFeatureData.LibraryType == TdsEnums.FedAuthLibrary.SecurityToken,
+ Debug.Assert(fedAuthFeatureData.libraryType == TdsEnums.FedAuthLibrary.MSAL || fedAuthFeatureData.libraryType == TdsEnums.FedAuthLibrary.SecurityToken,
"only fed auth library type MSAL and Security Token are supported in writing feature request");
int dataLen = 0;
int totalLen = 0;
// set dataLen and totalLen
- switch (fedAuthFeatureData.LibraryType)
+ switch (fedAuthFeatureData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
dataLen = 2; // length of feature data = 1 byte for library and echo + 1 byte for workflow
break;
case TdsEnums.FedAuthLibrary.SecurityToken:
- Debug.Assert(fedAuthFeatureData.AccessToken != null, "AccessToken should not be null.");
- dataLen = 1 + sizeof(int) + fedAuthFeatureData.AccessToken.Length; // length of feature data = 1 byte for library and echo, security token length and sizeof(int) for token lengh itself
+ Debug.Assert(fedAuthFeatureData.accessToken != null, "AccessToken should not be null.");
+ dataLen = 1 + sizeof(int) + fedAuthFeatureData.accessToken.Length; // length of feature data = 1 byte for library and echo, security token length and sizeof(int) for token lengh itself
break;
default:
Debug.Fail("Unrecognized library type for fedauth feature extension request");
@@ -9082,7 +9082,7 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
byte options = 0x00;
// set upper 7 bits of options to indicate fed auth library type
- switch (fedAuthFeatureData.LibraryType)
+ switch (fedAuthFeatureData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
Debug.Assert(_connHandler._federatedAuthenticationInfoRequested == true, "_federatedAuthenticationInfoRequested field should be true");
@@ -9097,7 +9097,7 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
break;
}
- options |= (byte)(fedAuthFeatureData.FedAuthRequiredPreLoginResponse == true ? 0x01 : 0x00);
+ options |= (byte)(fedAuthFeatureData.fedAuthRequiredPreLoginResponse == true ? 0x01 : 0x00);
// write dataLen and options
WriteInt(dataLen, _physicalStateObj);
@@ -9105,11 +9105,11 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
// write workflow for FedAuthLibrary.MSAL
// write accessToken for FedAuthLibrary.SecurityToken
- switch (fedAuthFeatureData.LibraryType)
+ switch (fedAuthFeatureData.libraryType)
{
case TdsEnums.FedAuthLibrary.MSAL:
byte workflow = 0x00;
- switch (fedAuthFeatureData.Authentication)
+ switch (fedAuthFeatureData.authentication)
{
case SqlAuthenticationMethod.ActiveDirectoryPassword:
workflow = TdsEnums.MSALWORKFLOW_ACTIVEDIRECTORYPASSWORD;
@@ -9151,8 +9151,8 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
_physicalStateObj.WriteByte(workflow);
break;
case TdsEnums.FedAuthLibrary.SecurityToken:
- WriteInt(fedAuthFeatureData.AccessToken.Length, _physicalStateObj);
- _physicalStateObj.WriteByteArray(fedAuthFeatureData.AccessToken, fedAuthFeatureData.AccessToken.Length, 0);
+ WriteInt(fedAuthFeatureData.accessToken.Length, _physicalStateObj);
+ _physicalStateObj.WriteByteArray(fedAuthFeatureData.accessToken, fedAuthFeatureData.accessToken.Length, 0);
break;
default:
Debug.Assert(false, "Unrecognized FedAuthLibrary type for feature extension request");
@@ -9287,7 +9287,7 @@ private void WriteLoginData(SqlLogin rec,
{
WriteUnsignedInt(recoverySessionData._tdsVersion, _physicalStateObj);
}
- WriteInt(rec.PacketSize, _physicalStateObj);
+ WriteInt(rec.packetSize, _physicalStateObj);
WriteInt(TdsEnums.CLIENT_PROG_VER, _physicalStateObj);
WriteInt(TdsParserStaticMethods.GetCurrentProcessIdForTdsLoginOnly(), _physicalStateObj); //MDAC 84718
WriteInt(0, _physicalStateObj); // connectionID is unused
@@ -9329,27 +9329,27 @@ private void WriteLoginData(SqlLogin rec,
// second byte
log7Flags |= TdsEnums.INIT_LANG_FATAL << 8;
log7Flags |= TdsEnums.ODBC_ON << 9;
- if (rec.UseReplication)
+ if (rec.useReplication)
{
log7Flags |= TdsEnums.REPL_ON << 12;
}
- if (rec.UseSspi)
+ if (rec.useSSPI)
{
log7Flags |= TdsEnums.SSPI_ON << 15;
}
// third byte
- if (rec.ReadOnlyIntent)
+ if (rec.readOnlyIntent)
{
log7Flags |= TdsEnums.READONLY_INTENT_ON << 21; // read-only intent flag is a first bit of fSpare1
}
// 4th one
- if (!ADP.IsEmpty(rec.NewPassword) || (rec.NewSecurePassword != null && rec.NewSecurePassword.Length != 0))
+ if (!ADP.IsEmpty(rec.newPassword) || (rec.newSecurePassword != null && rec.newSecurePassword.Length != 0))
{
log7Flags |= 1 << 24;
}
- if (rec.UserInstance)
+ if (rec.userInstance)
{
log7Flags |= 1 << 26;
}
@@ -9372,12 +9372,12 @@ private void WriteLoginData(SqlLogin rec,
// note that you must always set ibHostName since it indicaters the beginning of the variable length section of the login record
WriteShort(offset, _physicalStateObj); // host name offset
- WriteShort(rec.HostName.Length, _physicalStateObj);
- offset += rec.HostName.Length * 2;
+ WriteShort(rec.hostName.Length, _physicalStateObj);
+ offset += rec.hostName.Length * 2;
// Only send user/password over if not fSSPI or fed auth MSAL... If both user/password and SSPI are in login
// rec, only SSPI is used. Confirmed same bahavior as in luxor.
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
WriteShort(offset, _physicalStateObj); // userName offset
WriteShort(userName.Length, _physicalStateObj);
@@ -9398,12 +9398,12 @@ private void WriteLoginData(SqlLogin rec,
}
WriteShort(offset, _physicalStateObj); // app name offset
- WriteShort(rec.ApplicationName.Length, _physicalStateObj);
- offset += rec.ApplicationName.Length * 2;
+ WriteShort(rec.applicationName.Length, _physicalStateObj);
+ offset += rec.applicationName.Length * 2;
WriteShort(offset, _physicalStateObj); // server name offset
- WriteShort(rec.ServerName.Length, _physicalStateObj);
- offset += rec.ServerName.Length * 2;
+ WriteShort(rec.serverName.Length, _physicalStateObj);
+ offset += rec.serverName.Length * 2;
WriteShort(offset, _physicalStateObj);
if (useFeatureExt)
@@ -9421,12 +9421,12 @@ private void WriteLoginData(SqlLogin rec,
offset += clientInterfaceName.Length * 2;
WriteShort(offset, _physicalStateObj); // language name offset
- WriteShort(rec.Language.Length, _physicalStateObj);
- offset += rec.Language.Length * 2;
+ WriteShort(rec.language.Length, _physicalStateObj);
+ offset += rec.language.Length * 2;
WriteShort(offset, _physicalStateObj); // database name offset
- WriteShort(rec.Database.Length, _physicalStateObj);
- offset += rec.Database.Length * 2;
+ WriteShort(rec.database.Length, _physicalStateObj);
+ offset += rec.database.Length * 2;
// UNDONE: NIC address
// previously we declared the array and simply sent it over - byte[] of 0's
@@ -9438,7 +9438,7 @@ private void WriteLoginData(SqlLogin rec,
_physicalStateObj.WriteByteArray(s_nicAddress, s_nicAddress.Length, 0);
WriteShort(offset, _physicalStateObj); // ibSSPI offset
- if (rec.UseSspi)
+ if (rec.useSSPI)
{
WriteShort((int)outSSPILength, _physicalStateObj);
offset += (int)outSSPILength;
@@ -9449,8 +9449,8 @@ private void WriteLoginData(SqlLogin rec,
}
WriteShort(offset, _physicalStateObj); // DB filename offset
- WriteShort(rec.AttachDbFilename.Length, _physicalStateObj);
- offset += rec.AttachDbFilename.Length * 2;
+ WriteShort(rec.attachDBFilename.Length, _physicalStateObj);
+ offset += rec.attachDBFilename.Length * 2;
WriteShort(offset, _physicalStateObj); // reset password offset
WriteShort(encryptedChangePasswordLengthInBytes / 2, _physicalStateObj);
@@ -9458,11 +9458,11 @@ private void WriteLoginData(SqlLogin rec,
WriteInt(0, _physicalStateObj); // reserved for chSSPI
// write variable length portion
- WriteString(rec.HostName, _physicalStateObj);
+ WriteString(rec.hostName, _physicalStateObj);
// if we are using SSPI or fed auth MSAL, do not send over username/password, since we will use SSPI instead
// same behavior as Luxor
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
WriteString(userName, _physicalStateObj);
@@ -9470,9 +9470,9 @@ private void WriteLoginData(SqlLogin rec,
_physicalStateObj._tracePasswordOffset = _physicalStateObj._outBytesUsed;
_physicalStateObj._tracePasswordLength = encryptedPasswordLengthInBytes;
- if (rec.Credential != null)
+ if (rec.credential != null)
{
- _physicalStateObj.WriteSecureString(rec.Credential.Password);
+ _physicalStateObj.WriteSecureString(rec.credential.Password);
}
else
{
@@ -9480,8 +9480,8 @@ private void WriteLoginData(SqlLogin rec,
}
}
- WriteString(rec.ApplicationName, _physicalStateObj);
- WriteString(rec.ServerName, _physicalStateObj);
+ WriteString(rec.applicationName, _physicalStateObj);
+ WriteString(rec.serverName, _physicalStateObj);
// write ibFeatureExtLong
if (useFeatureExt)
@@ -9495,22 +9495,22 @@ private void WriteLoginData(SqlLogin rec,
}
WriteString(clientInterfaceName, _physicalStateObj);
- WriteString(rec.Language, _physicalStateObj);
- WriteString(rec.Database, _physicalStateObj);
+ WriteString(rec.language, _physicalStateObj);
+ WriteString(rec.database, _physicalStateObj);
// send over SSPI data if we are using SSPI
- if (rec.UseSspi)
+ if (rec.useSSPI)
_physicalStateObj.WriteByteArray(outSSPIBuff, (int)outSSPILength, 0);
- WriteString(rec.AttachDbFilename, _physicalStateObj);
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ WriteString(rec.attachDBFilename, _physicalStateObj);
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
// Cache offset in packet for tracing.
_physicalStateObj._traceChangePasswordOffset = _physicalStateObj._outBytesUsed;
_physicalStateObj._traceChangePasswordLength = encryptedChangePasswordLengthInBytes;
- if (rec.NewSecurePassword != null)
+ if (rec.newSecurePassword != null)
{
- _physicalStateObj.WriteSecureString(rec.NewSecurePassword);
+ _physicalStateObj.WriteSecureString(rec.newSecurePassword);
}
else
{
@@ -9599,12 +9599,12 @@ private int ApplyFeatureExData(TdsEnums.FeatureExtension requestedFeatures,
internal void SendFedAuthToken(SqlFedAuthToken fedAuthToken)
{
Debug.Assert(fedAuthToken != null, "fedAuthToken cannot be null");
- Debug.Assert(fedAuthToken.AccessToken != null, "fedAuthToken.accessToken cannot be null");
+ Debug.Assert(fedAuthToken.accessToken != null, "fedAuthToken.accessToken cannot be null");
SqlClientEventSource.Log.TryTraceEvent(" Sending federated authentication token");
_physicalStateObj._outputMessageType = TdsEnums.MT_FEDAUTH;
- byte[] accessToken = fedAuthToken.AccessToken;
+ byte[] accessToken = fedAuthToken.accessToken;
// Send total length (length of token plus 4 bytes for the token length field)
// If we were sending a nonce, this would include that length as well
@@ -10140,30 +10140,30 @@ internal Task TdsExecuteRPC(SqlCommand cmd, IList<_SqlRPC> rpcArray, int timeout
if (startParam == 0 || ii > startRpc)
{
- if (rpcext.ProcId != 0 && _is2000)
+ if (rpcext.ProcID != 0 && _is2000)
{
// Perf optimization for 2000 and later,
- Debug.Assert(rpcext.ProcId < 255, "rpcExec:ProcID can't be larger than 255");
+ Debug.Assert(rpcext.ProcID < 255, "rpcExec:ProcID can't be larger than 255");
WriteShort(0xffff, stateObj);
- WriteShort((short)(rpcext.ProcId), stateObj);
+ WriteShort((short)(rpcext.ProcID), stateObj);
}
else
{
- Debug.Assert(!ADP.IsEmpty(rpcext.RpcName), "must have an RPC name");
- tempLen = rpcext.RpcName.Length;
+ Debug.Assert(!ADP.IsEmpty(rpcext.rpcName), "must have an RPC name");
+ tempLen = rpcext.rpcName.Length;
WriteShort(tempLen, stateObj);
- WriteString(rpcext.RpcName, tempLen, 0, stateObj);
+ WriteString(rpcext.rpcName, tempLen, 0, stateObj);
}
// Options
- WriteShort((short)rpcext.Options, stateObj);
+ WriteShort((short)rpcext.options, stateObj);
byte[] enclavePackage = cmd.enclavePackage != null ? cmd.enclavePackage.EnclavePackageBytes : null;
WriteEnclaveInfo(stateObj, enclavePackage);
}
// Stream out parameters
- int parametersLength = rpcext.UserParamCount + rpcext.SystemParamCount;
+ int parametersLength = rpcext.userParamCount + rpcext.systemParamCount;
bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn();
bool enableOptimizedParameterBinding = cmd.EnableOptimizedParameterBinding && cmd.CommandType == CommandType.Text;
@@ -11403,9 +11403,9 @@ internal void LoadColumnEncryptionKeys(_SqlMetaDataSet metadataCollection, SqlCo
if (metadataCollection[col] != null)
{
_SqlMetaData md = metadataCollection[col];
- if (md.IsEncrypted)
+ if (md.isEncrypted)
{
- SqlSecurityUtility.DecryptSymmetricKey(md.CipherMD, connection, command);
+ SqlSecurityUtility.DecryptSymmetricKey(md.cipherMD, connection, command);
}
}
}
@@ -11453,14 +11453,14 @@ internal void WriteCekTable(_SqlMetaDataSet metadataCollection, TdsParserStateOb
// Note- Cek table (with 0 entries) will be present if TCE
// was enabled and server supports it!
// OR if encryption was disabled in connection options
- if (metadataCollection.CekTable == null ||
+ if (metadataCollection.cekTable == null ||
!ShouldEncryptValuesForBulkCopy())
{
WriteShort(0x00, stateObj);
return;
}
- SqlTceCipherInfoTable cekTable = metadataCollection.CekTable;
+ SqlTceCipherInfoTable cekTable = metadataCollection.cekTable;
ushort count = (ushort)cekTable.Size;
WriteShort(count, stateObj);
@@ -11477,17 +11477,17 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
// Write the UserType (4 byte value)
WriteInt(0x0, stateObj); // TODO: fix this- timestamp columns have 0x50 value here
- Debug.Assert(SqlDbType.Xml != mdPriv.Type);
- Debug.Assert(SqlDbType.Udt != mdPriv.Type);
+ Debug.Assert(SqlDbType.Xml != mdPriv.type);
+ Debug.Assert(SqlDbType.Udt != mdPriv.type);
- stateObj.WriteByte(mdPriv.TdsType);
+ stateObj.WriteByte(mdPriv.tdsType);
- switch (mdPriv.Type)
+ switch (mdPriv.type)
{
case SqlDbType.Decimal:
- WriteTokenLength(mdPriv.TdsType, mdPriv.Length, stateObj);
- stateObj.WriteByte(mdPriv.Precision);
- stateObj.WriteByte(mdPriv.Scale);
+ WriteTokenLength(mdPriv.tdsType, mdPriv.length, stateObj);
+ stateObj.WriteByte(mdPriv.precision);
+ stateObj.WriteByte(mdPriv.scale);
break;
case SqlDbType.Date:
// Nothing more to write!
@@ -11495,14 +11495,14 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
case SqlDbType.Time:
case SqlDbType.DateTime2:
case SqlDbType.DateTimeOffset:
- stateObj.WriteByte(mdPriv.Scale);
+ stateObj.WriteByte(mdPriv.scale);
break;
default:
- WriteTokenLength(mdPriv.TdsType, mdPriv.Length, stateObj);
- if (mdPriv.MetaType.IsCharType && _is2000)
+ WriteTokenLength(mdPriv.tdsType, mdPriv.length, stateObj);
+ if (mdPriv.metaType.IsCharType && _is2000)
{
- WriteUnsignedInt(mdPriv.Collation._info, stateObj);
- stateObj.WriteByte(mdPriv.Collation._sortId);
+ WriteUnsignedInt(mdPriv.collation._info, stateObj);
+ stateObj.WriteByte(mdPriv.collation._sortId);
}
break;
}
@@ -11515,34 +11515,34 @@ internal void WriteTceUserTypeAndTypeInfo(SqlMetaDataPriv mdPriv, TdsParserState
internal void WriteCryptoMetadata(_SqlMetaData md, TdsParserStateObject stateObj)
{
if (!_serverSupportsColumnEncryption || // TCE Feature supported
- !md.IsEncrypted || // Column is not encrypted
+ !md.isEncrypted || // Column is not encrypted
!ShouldEncryptValuesForBulkCopy())
{ // TCE disabled on connection string
return;
}
// Write the ordinal
- WriteShort(md.CipherMD.CekTableOrdinal, stateObj);
+ WriteShort(md.cipherMD.CekTableOrdinal, stateObj);
// Write UserType and TYPEINFO
- WriteTceUserTypeAndTypeInfo(md.BaseTI, stateObj);
+ WriteTceUserTypeAndTypeInfo(md.baseTI, stateObj);
// Write Encryption Algo
- stateObj.WriteByte(md.CipherMD.CipherAlgorithmId);
+ stateObj.WriteByte(md.cipherMD.CipherAlgorithmId);
- if (TdsEnums.CustomCipherAlgorithmId == md.CipherMD.CipherAlgorithmId)
+ if (TdsEnums.CustomCipherAlgorithmId == md.cipherMD.CipherAlgorithmId)
{
// Write the algorithm name
- Debug.Assert(md.CipherMD.CipherAlgorithmName.Length < 256);
- stateObj.WriteByte((byte)md.CipherMD.CipherAlgorithmName.Length);
- WriteString(md.CipherMD.CipherAlgorithmName, stateObj);
+ Debug.Assert(md.cipherMD.CipherAlgorithmName.Length < 256);
+ stateObj.WriteByte((byte)md.cipherMD.CipherAlgorithmName.Length);
+ WriteString(md.cipherMD.CipherAlgorithmName, stateObj);
}
// Write Encryption Algo Type
- stateObj.WriteByte(md.CipherMD.EncryptionType);
+ stateObj.WriteByte(md.cipherMD.EncryptionType);
// Write Normalization Version
- stateObj.WriteByte(md.CipherMD.NormalizationRuleVersion);
+ stateObj.WriteByte(md.cipherMD.NormalizationRuleVersion);
}
internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int count, TdsParserStateObject stateObj)
@@ -11585,7 +11585,7 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
{ // TCE Supported
if (ShouldEncryptValuesForBulkCopy())
{ // TCE enabled on connection options
- flags |= (UInt16)(md.IsEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
+ flags |= (UInt16)(md.isEncrypted ? (UInt16)(TdsEnums.IsEncrypted << 8) : (UInt16)0);
}
}
@@ -11596,13 +11596,13 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
// discuss ...
// xml datatype does not have token length in its metadata. So it should be a noop.
- switch (md.Type)
+ switch (md.type)
{
case SqlDbType.Decimal:
- stateObj.WriteByte(md.TdsType);
- WriteTokenLength(md.TdsType, md.Length, stateObj);
- stateObj.WriteByte(md.Precision);
- stateObj.WriteByte(md.Scale);
+ stateObj.WriteByte(md.tdsType);
+ WriteTokenLength(md.tdsType, md.length, stateObj);
+ stateObj.WriteByte(md.precision);
+ stateObj.WriteByte(md.scale);
break;
case SqlDbType.Xml:
// TODO: This doesn't look right. Needs fixing.
@@ -11610,38 +11610,38 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
break;
case SqlDbType.Udt:
stateObj.WriteByte(TdsEnums.SQLBIGVARBINARY);
- WriteTokenLength(TdsEnums.SQLBIGVARBINARY, md.Length, stateObj);
+ WriteTokenLength(TdsEnums.SQLBIGVARBINARY, md.length, stateObj);
break;
case SqlDbType.Date:
- stateObj.WriteByte(md.TdsType);
+ stateObj.WriteByte(md.tdsType);
break;
case SqlDbType.Time:
case SqlDbType.DateTime2:
case SqlDbType.DateTimeOffset:
- stateObj.WriteByte(md.TdsType);
- stateObj.WriteByte(md.Scale);
+ stateObj.WriteByte(md.tdsType);
+ stateObj.WriteByte(md.scale);
break;
default:
- stateObj.WriteByte(md.TdsType);
- WriteTokenLength(md.TdsType, md.Length, stateObj);
- if (md.MetaType.IsCharType && _is2000)
+ stateObj.WriteByte(md.tdsType);
+ WriteTokenLength(md.tdsType, md.length, stateObj);
+ if (md.metaType.IsCharType && _is2000)
{
- WriteUnsignedInt(md.Collation._info, stateObj);
- stateObj.WriteByte(md.Collation._sortId);
+ WriteUnsignedInt(md.collation._info, stateObj);
+ stateObj.WriteByte(md.collation._sortId);
}
break;
}
- if (md.MetaType.IsLong && !md.MetaType.IsPlp)
+ if (md.metaType.IsLong && !md.metaType.IsPlp)
{
- WriteShort(md.TableName.Length, stateObj);
- WriteString(md.TableName, stateObj);
+ WriteShort(md.tableName.Length, stateObj);
+ WriteString(md.tableName, stateObj);
}
WriteCryptoMetadata(md, stateObj);
- stateObj.WriteByte((byte)md.Column.Length);
- WriteString(md.Column, stateObj);
+ stateObj.WriteByte((byte)md.column.Length);
+ WriteString(md.column, stateObj);
}
} // end for loop
}
@@ -11677,7 +11677,7 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
}
int actualLengthInBytes;
- switch (metadata.BaseTI.MetaType.NullableType)
+ switch (metadata.baseTI.metaType.NullableType)
{
case TdsEnums.SQLBIGBINARY:
case TdsEnums.SQLBIGVARBINARY:
@@ -11692,10 +11692,10 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
// to report the size of data to be copied out (for serialization). If we underreport the
// size, truncation will happen for us!
actualLengthInBytes = (isSqlType) ? ((SqlBinary)value).Length : ((byte[])value).Length;
- if (metadata.BaseTI.Length > 0 &&
- actualLengthInBytes > metadata.BaseTI.Length)
+ if (metadata.baseTI.length > 0 &&
+ actualLengthInBytes > metadata.baseTI.length)
{ // see comments agove
- actualLengthInBytes = metadata.BaseTI.Length;
+ actualLengthInBytes = metadata.baseTI.length;
}
break;
@@ -11714,10 +11714,10 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
actualLengthInBytes = _defaultEncoding.GetByteCount(stringValue);
// If the string length is > max length, then use the max length (see comments above)
- if (metadata.BaseTI.Length > 0 &&
- actualLengthInBytes > metadata.BaseTI.Length)
+ if (metadata.baseTI.length > 0 &&
+ actualLengthInBytes > metadata.baseTI.length)
{
- actualLengthInBytes = metadata.BaseTI.Length; // this ensure truncation!
+ actualLengthInBytes = metadata.baseTI.length; // this ensure truncation!
}
break;
@@ -11726,16 +11726,16 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
case TdsEnums.SQLNTEXT:
actualLengthInBytes = ((isSqlType) ? ((SqlString)value).Value.Length : ((string)value).Length) * 2;
- if (metadata.BaseTI.Length > 0 &&
- actualLengthInBytes > metadata.BaseTI.Length)
+ if (metadata.baseTI.length > 0 &&
+ actualLengthInBytes > metadata.baseTI.length)
{ // see comments above
- actualLengthInBytes = metadata.BaseTI.Length;
+ actualLengthInBytes = metadata.baseTI.length;
}
break;
default:
- actualLengthInBytes = metadata.BaseTI.Length;
+ actualLengthInBytes = metadata.baseTI.length;
break;
}
@@ -11744,28 +11744,28 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin
{
// SqlType
serializedValue = SerializeUnencryptedSqlValue(value,
- metadata.BaseTI.MetaType,
+ metadata.baseTI.metaType,
actualLengthInBytes,
offset: 0,
- normalizationVersion: metadata.CipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
else
{
serializedValue = SerializeUnencryptedValue(value,
- metadata.BaseTI.MetaType,
- metadata.BaseTI.Scale,
+ metadata.baseTI.metaType,
+ metadata.baseTI.scale,
actualLengthInBytes,
offset: 0,
isDataFeed: isDataFeed,
- normalizationVersion: metadata.CipherMD.NormalizationRuleVersion,
+ normalizationVersion: metadata.cipherMD.NormalizationRuleVersion,
stateObj: stateObj);
}
Debug.Assert(serializedValue != null, "serializedValue should not be null in TdsExecuteRPC.");
return SqlSecurityUtility.EncryptWithKey(
serializedValue,
- metadata.CipherMD,
+ metadata.cipherMD,
_connHandler.Connection,
null);
}
@@ -11788,24 +11788,24 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
}
try
{
- if (metadata.Encoding != null)
+ if (metadata.encoding != null)
{
- _defaultEncoding = metadata.Encoding;
+ _defaultEncoding = metadata.encoding;
}
- if (metadata.Collation != null)
+ if (metadata.collation != null)
{
// Replace encoding if it is UTF8
- if (metadata.Collation.IsUTF8)
+ if (metadata.collation.IsUTF8)
{
_defaultEncoding = Encoding.UTF8;
}
- _defaultCollation = metadata.Collation;
+ _defaultCollation = metadata.collation;
_defaultLCID = _defaultCollation.LCID;
}
- _defaultCodePage = metadata.CodePage;
+ _defaultCodePage = metadata.codePage;
- MetaType metatype = metadata.MetaType;
+ MetaType metatype = metadata.metaType;
int ccb = 0;
int ccbStringBytes = 0;
@@ -11876,7 +11876,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
break;
default:
- ccb = metadata.Length;
+ ccb = metadata.length;
break;
}
}
@@ -11900,7 +11900,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
case SqlDbType.NText:
case SqlDbType.Image:
stateObj.WriteByteArray(s_longDataHeader, s_longDataHeader.Length, 0);
- WriteTokenLength(metadata.TdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
+ WriteTokenLength(metadata.tdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
break;
case SqlDbType.VarChar:
@@ -11915,7 +11915,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
}
else
{
- WriteTokenLength(metadata.TdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
+ WriteTokenLength(metadata.tdsType, ccbStringBytes == 0 ? ccb : ccbStringBytes, stateObj);
}
if (isSqlType)
@@ -11924,7 +11924,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars
}
else if (metatype.SqlDbType != SqlDbType.Udt || metatype.IsLong)
{
- internalWriteTask = WriteValue(value, metatype, metadata.Scale, ccb, ccbStringBytes, 0, stateObj, metadata.Length, isDataFeed);
+ internalWriteTask = WriteValue(value, metatype, metadata.scale, ccb, ccbStringBytes, 0, stateObj, metadata.length, isDataFeed);
if ((internalWriteTask == null) && (_asyncWrite))
{
internalWriteTask = stateObj.WaitForAccumulatedWrites();
@@ -13873,7 +13873,7 @@ internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPr
if (stateObj._plpdecoder == null)
{
- Encoding enc = metadata.Encoding;
+ Encoding enc = metadata.encoding;
if (enc == null)
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
index 8d336f50ee..473b3b638a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
@@ -127,7 +127,7 @@ private static string GetTokenHash(SqlFedAuthToken token)
return "null";
// Here we mimic how ADAL calculates hash for token. They use UTF8 instead of Unicode.
- var originalTokenString = SqlAuthenticationToken.AccessTokenStringFromBytes(token.AccessToken);
+ var originalTokenString = SqlAuthenticationToken.AccessTokenStringFromBytes(token.accessToken);
var bytesInUtf8 = Encoding.UTF8.GetBytes(originalTokenString);
using (var sha256 = SHA256.Create())
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
index f833fc09fa..eeeb457e7c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
@@ -16,14 +16,14 @@ namespace Microsoft.Data.SqlClient
///
internal sealed class SqlEncryptionKeyInfo
{
- public byte[] EncryptedKey; // the encrypted "column encryption key"
- public int DatabaseId;
- public int CekId;
- public int CekVersion;
- public byte[] CekMdVersion;
- public string KeyPath;
- public string KeyStoreName;
- public string AlgorithmName;
+ internal byte[] encryptedKey; // the encrypted "column encryption key"
+ internal int databaseId;
+ internal int cekId;
+ internal int cekVersion;
+ internal byte[] cekMdVersion;
+ internal string keyPath;
+ internal string keyStoreName;
+ internal string algorithmName;
}
///
@@ -68,7 +68,7 @@ internal sealed class SqlTceCipherInfoEntry
///
/// Return the ordinal.
///
- public int Ordinal
+ internal int Ordinal
{
get
{
@@ -79,7 +79,7 @@ public int Ordinal
///
/// Return the DatabaseID.
///
- public int DatabaseId
+ internal int DatabaseId
{
get
{
@@ -90,7 +90,7 @@ public int DatabaseId
///
/// Return the CEK ID.
///
- public int CekId
+ internal int CekId
{
get
{
@@ -101,7 +101,7 @@ public int CekId
///
/// Return the CEK Version.
///
- public int CekVersion
+ internal int CekVersion
{
get
{
@@ -112,7 +112,7 @@ public int CekVersion
///
/// Return the CEK MD Version.
///
- public byte[] CekMdVersion
+ internal byte[] CekMdVersion
{
get
{
@@ -123,7 +123,7 @@ public byte[] CekMdVersion
///
/// Return the list of Column Encryption Key Values.
///
- public List ColumnEncryptionKeyValues
+ internal List ColumnEncryptionKeyValues
{
get
{
@@ -142,21 +142,21 @@ public List ColumnEncryptionKeyValues
///
///
///
- public void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
+ internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion, byte[] cekMdVersion, string keyPath, string keyStoreName, string algorithmName)
{
Debug.Assert(_columnEncryptionKeyValues != null, "_columnEncryptionKeyValues should already be initialized.");
SqlEncryptionKeyInfo encryptionKey = new SqlEncryptionKeyInfo
{
- EncryptedKey = encryptedKey,
- DatabaseId = databaseId,
- CekId = cekId,
- CekVersion = cekVersion,
- CekMdVersion = cekMdVersion,
- KeyPath = keyPath,
- KeyStoreName = keyStoreName,
- AlgorithmName = algorithmName
+ encryptedKey = encryptedKey,
+ databaseId = databaseId,
+ cekId = cekId,
+ cekVersion = cekVersion,
+ cekMdVersion = cekMdVersion,
+ keyPath = keyPath,
+ keyStoreName = keyStoreName,
+ algorithmName = algorithmName
};
_columnEncryptionKeyValues.Add(encryptionKey);
@@ -180,7 +180,7 @@ public void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion,
/// Constructor.
///
///
- public SqlTceCipherInfoEntry(int ordinal = 0)
+ internal SqlTceCipherInfoEntry(int ordinal = 0)
{
_ordinal = ordinal;
_databaseId = 0;
@@ -200,13 +200,13 @@ internal sealed class SqlTceCipherInfoTable
{
private readonly SqlTceCipherInfoEntry[] _keyList;
- public SqlTceCipherInfoTable(int tabSize)
+ internal SqlTceCipherInfoTable(int tabSize)
{
Debug.Assert(0 < tabSize, "Invalid Table Size");
_keyList = new SqlTceCipherInfoEntry[tabSize];
}
- public SqlTceCipherInfoEntry this[int index]
+ internal SqlTceCipherInfoEntry this[int index]
{
get
{
@@ -220,7 +220,7 @@ public SqlTceCipherInfoEntry this[int index]
}
}
- public int Size
+ internal int Size
{
get
{
@@ -231,12 +231,12 @@ public int Size
internal sealed partial class _SqlMetaDataSet
{
- public readonly SqlTceCipherInfoTable CekTable; // table of "column encryption keys" used for this metadataset
+ internal readonly SqlTceCipherInfoTable cekTable; // table of "column encryption keys" used for this metadataset
- public _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
+ internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
: this(count)
{
- CekTable = cipherTable;
+ cekTable = cipherTable;
}
}
@@ -289,7 +289,7 @@ internal sealed class SqlCipherMetadata
///
/// Return the Encryption Info Entry.
///
- public SqlTceCipherInfoEntry EncryptionInfo
+ internal SqlTceCipherInfoEntry EncryptionInfo
{
get
{
@@ -305,7 +305,7 @@ public SqlTceCipherInfoEntry EncryptionInfo
///
/// Return the cipher's encryption algorithm id.
///
- public byte CipherAlgorithmId
+ internal byte CipherAlgorithmId
{
get
{
@@ -316,7 +316,7 @@ public byte CipherAlgorithmId
///
/// Return the cipher's encryption algorithm name (could be null).
///
- public string CipherAlgorithmName
+ internal string CipherAlgorithmName
{
get
{
@@ -327,7 +327,7 @@ public string CipherAlgorithmName
///
/// Return EncryptionType (Deterministic, Randomized, etc.)
///
- public byte EncryptionType
+ internal byte EncryptionType
{
get
{
@@ -338,7 +338,7 @@ public byte EncryptionType
///
/// Return normalization rule version.
///
- public byte NormalizationRuleVersion
+ internal byte NormalizationRuleVersion
{
get
{
@@ -349,7 +349,7 @@ public byte NormalizationRuleVersion
///
/// Return the cipher encryption algorithm handle.
///
- public SqlClientEncryptionAlgorithm CipherAlgorithm
+ internal SqlClientEncryptionAlgorithm CipherAlgorithm
{
get
{
@@ -365,7 +365,7 @@ public SqlClientEncryptionAlgorithm CipherAlgorithm
///
/// Return Encryption Key Info.
///
- public SqlEncryptionKeyInfo EncryptionKeyInfo
+ internal SqlEncryptionKeyInfo EncryptionKeyInfo
{
get
{
@@ -382,7 +382,7 @@ public SqlEncryptionKeyInfo EncryptionKeyInfo
///
/// Return Ordinal into Cek Table.
///
- public ushort CekTableOrdinal
+ internal ushort CekTableOrdinal
{
get
{
@@ -399,7 +399,7 @@ public ushort CekTableOrdinal
///
///
///
- public SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
+ internal SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
ushort ordinal,
byte cipherAlgorithmId,
string cipherAlgorithmName,
@@ -421,7 +421,7 @@ public SqlCipherMetadata(SqlTceCipherInfoEntry sqlTceCipherInfoEntry,
/// Do we have an handle to the cipher encryption algorithm already ?
///
///
- public bool IsAlgorithmInitialized()
+ internal bool IsAlgorithmInitialized()
{
return _sqlClientEncryptionAlgorithm != null ? true : false;
}
@@ -429,19 +429,19 @@ public bool IsAlgorithmInitialized()
internal partial class SqlMetaDataPriv
{
- public bool IsEncrypted; // TCE encrypted?
- public SqlMetaDataPriv BaseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
- public SqlCipherMetadata CipherMD; // Cipher related metadata for encrypted columns.
+ internal bool isEncrypted; // TCE encrypted?
+ internal SqlMetaDataPriv baseTI; // for encrypted columns, represents the TYPE_INFO for plaintext value
+ internal SqlCipherMetadata cipherMD; // Cipher related metadata for encrypted columns.
///
/// Is the algorithm handle for the cipher encryption initialized ?
///
///
- public bool IsAlgorithmInitialized()
+ internal bool IsAlgorithmInitialized()
{
- if (CipherMD != null)
+ if (cipherMD != null)
{
- return CipherMD.IsAlgorithmInitialized();
+ return cipherMD.IsAlgorithmInitialized();
}
return false;
@@ -451,13 +451,13 @@ public bool IsAlgorithmInitialized()
/// Returns the normalization rule version byte.
///
///
- public byte NormalizationRuleVersion
+ internal byte NormalizationRuleVersion
{
get
{
- if (CipherMD != null)
+ if (cipherMD != null)
{
- return CipherMD.NormalizationRuleVersion;
+ return cipherMD.NormalizationRuleVersion;
}
return 0x00;
@@ -489,7 +489,7 @@ internal sealed class SqlColumnEncryptionInputParameterInfo
///
/// Return the SMI Parameter Metadata.
///
- public SmiParameterMetaData ParameterMetadata
+ internal SmiParameterMetaData ParameterMetadata
{
get
{
@@ -502,7 +502,7 @@ public SmiParameterMetaData ParameterMetadata
/// This is pre-calculated and cached since members are immutable.
/// Does not include _smiParameterMetadata's serialization.
///
- public byte[] SerializedWireFormat
+ internal byte[] SerializedWireFormat
{
get
{
@@ -515,7 +515,7 @@ public byte[] SerializedWireFormat
///
///
///
- public SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
+ internal SqlColumnEncryptionInputParameterInfo(SmiParameterMetaData smiParameterMetadata, SqlCipherMetadata cipherMetadata)
{
Debug.Assert(smiParameterMetadata != null, "smiParameterMetadata should not be null.");
Debug.Assert(cipherMetadata != null, "cipherMetadata should not be null");
@@ -549,7 +549,7 @@ private byte[] SerializeToWriteFormat()
totalLength += sizeof(int);
// Metadata version of the encryption key.
- totalLength += _cipherMetadata.EncryptionKeyInfo.CekMdVersion.Length;
+ totalLength += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
// Normalization Rule Version.
totalLength += sizeof(byte);
@@ -566,17 +566,17 @@ private byte[] SerializeToWriteFormat()
serializedWireFormat[consumedBytes++] = _cipherMetadata.EncryptionType;
// 3 - Write the database id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.DatabaseId, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.databaseId, serializedWireFormat, ref consumedBytes);
// 4 - Write the id of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.CekId, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekId, serializedWireFormat, ref consumedBytes);
// 5 - Write the version of the encryption key.
- SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.CekVersion, serializedWireFormat, ref consumedBytes);
+ SerializeIntIntoBuffer(_cipherMetadata.EncryptionKeyInfo.cekVersion, serializedWireFormat, ref consumedBytes);
// 6 - Write the metadata version of the encryption key.
- Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.CekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.CekMdVersion.Length);
- consumedBytes += _cipherMetadata.EncryptionKeyInfo.CekMdVersion.Length;
+ Buffer.BlockCopy(_cipherMetadata.EncryptionKeyInfo.cekMdVersion, 0, serializedWireFormat, consumedBytes, _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length);
+ consumedBytes += _cipherMetadata.EncryptionKeyInfo.cekMdVersion.Length;
// 7 - Write Normalization Rule Version.
serializedWireFormat[consumedBytes++] = _cipherMetadata.NormalizationRuleVersion;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
index 7d2e51eaed..fc10fda351 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/EnclaveDelegate.cs
@@ -76,9 +76,9 @@ private List GetDecryptedKeysToBeSentToEnclave(Concurre
decryptedKeysToBeSentToEnclave.Add(
new ColumnEncryptionKeyInfo(
sqlClientSymmetricKey.RootKey,
- cipherInfo.ColumnEncryptionKeyValues[0].DatabaseId,
- cipherInfo.ColumnEncryptionKeyValues[0].CekMdVersion,
- cipherInfo.ColumnEncryptionKeyValues[0].CekId
+ cipherInfo.ColumnEncryptionKeyValues[0].databaseId,
+ cipherInfo.ColumnEncryptionKeyValues[0].cekMdVersion,
+ cipherInfo.ColumnEncryptionKeyValues[0].cekId
)
);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs
index d6d40e2b10..018440c743 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationToken.cs
@@ -40,9 +40,9 @@ internal SqlFedAuthToken ToSqlFedAuthToken()
var tokenBytes = AccessTokenBytesFromString(AccessToken);
return new SqlFedAuthToken
{
- AccessToken = tokenBytes,
- DataLen = (uint)tokenBytes.Length,
- ExpirationFileTime = ExpiresOn.ToFileTime()
+ accessToken = tokenBytes,
+ dataLen = (uint)tokenBytes.Length,
+ expirationFileTime = ExpiresOn.ToFileTime()
};
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs
index 4150c50f26..2b656501a5 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCachedBuffer.cs
@@ -50,7 +50,7 @@ internal static TdsOperationStatus TryCreate(SqlMetaDataPriv metadata, TdsParser
}
// For now we only handle Plp data from the parser directly.
- Debug.Assert(metadata.MetaType.IsPlp, "SqlCachedBuffer call on a non-plp data");
+ Debug.Assert(metadata.metaType.IsPlp, "SqlCachedBuffer call on a non-plp data");
do
{
if (plplength == 0)
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
index 0ce84a0b07..964e46aca3 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlQueryMetadataCache.cs
@@ -313,8 +313,8 @@ private ConcurrentDictionary CreateCopyOfEnclaveKeys
SqlTceCipherInfoEntry copy = new(ordinal);
foreach (SqlEncryptionKeyInfo cekInfo in original.ColumnEncryptionKeyValues)
{
- copy.Add(cekInfo.EncryptedKey, cekInfo.DatabaseId, cekInfo.CekId, cekInfo.CekVersion,
- cekInfo.CekMdVersion, cekInfo.KeyPath, cekInfo.KeyStoreName, cekInfo.AlgorithmName);
+ copy.Add(cekInfo.encryptedKey, cekInfo.databaseId, cekInfo.cekId, cekInfo.cekVersion,
+ cekInfo.cekMdVersion, cekInfo.keyPath, cekInfo.keyStoreName, cekInfo.algorithmName);
}
enclaveKeys.TryAdd(ordinal, copy);
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
index 4fe330fe95..90fb9a5d32 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
@@ -227,7 +227,7 @@ internal static byte[] DecryptWithKey(byte[] cipherText, SqlCipherMetadata md, S
catch (Exception e)
{
// compute the strings to pass
- string keyStr = GetBytesAsString(md.EncryptionKeyInfo.EncryptedKey, fLast: true, countOfBytes: 10);
+ string keyStr = GetBytesAsString(md.EncryptionKeyInfo.encryptedKey, fLast: true, countOfBytes: 10);
string valStr = GetBytesAsString(cipherText, fLast: false, countOfBytes: 10);
throw SQL.ThrowDecryptionFailed(keyStr, valStr, e);
}
@@ -275,7 +275,7 @@ internal static void DecryptSymmetricKey(SqlTceCipherInfoEntry sqlTceCipherInfoE
{
try
{
- sqlClientSymmetricKey = ShouldUseInstanceLevelProviderFlow(keyInfo.KeyStoreName, connection, command) ?
+ sqlClientSymmetricKey = ShouldUseInstanceLevelProviderFlow(keyInfo.keyStoreName, connection, command) ?
GetKeyFromLocalProviders(keyInfo, connection, command) :
globalCekCache.GetKey(keyInfo, connection, command);
encryptionkeyInfoChosen = keyInfo;
@@ -303,10 +303,10 @@ private static SqlClientSymmetricKey GetKeyFromLocalProviders(SqlEncryptionKeyIn
Debug.Assert(SqlConnection.ColumnEncryptionTrustedMasterKeyPaths is not null, @"SqlConnection.ColumnEncryptionTrustedMasterKeyPaths should not be null");
- ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.KeyPath);
- if (!TryGetColumnEncryptionKeyStoreProvider(keyInfo.KeyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
+ ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.keyPath);
+ if (!TryGetColumnEncryptionKeyStoreProvider(keyInfo.keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
{
- throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.KeyStoreName,
+ throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.keyStoreName,
SqlConnection.GetColumnEncryptionSystemKeyStoreProvidersNames(),
GetListOfProviderNamesThatWereSearched(connection, command));
}
@@ -316,13 +316,13 @@ private static SqlClientSymmetricKey GetKeyFromLocalProviders(SqlEncryptionKeyIn
byte[] plaintextKey;
try
{
- plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.KeyPath, keyInfo.AlgorithmName, keyInfo.EncryptedKey);
+ plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.keyPath, keyInfo.algorithmName, keyInfo.encryptedKey);
}
catch (Exception e)
{
// Generate a new exception and throw.
- string keyHex = GetBytesAsString(keyInfo.EncryptedKey, fLast: true, countOfBytes: 10);
- throw SQL.KeyDecryptionFailed(keyInfo.KeyStoreName, keyHex, e);
+ string keyHex = GetBytesAsString(keyInfo.encryptedKey, fLast: true, countOfBytes: 10);
+ throw SQL.KeyDecryptionFailed(keyInfo.keyStoreName, keyHex, e);
}
return new SqlClientSymmetricKey(plaintextKey);
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
index 3e2d318b9a..fb9ea2997d 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSymmetricKeyCache.cs
@@ -35,16 +35,16 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
string serverName = connection.DataSource;
Debug.Assert(serverName is not null, @"serverName should not be null.");
- StringBuilder cacheLookupKeyBuilder = new StringBuilder(serverName, capacity: serverName.Length + SqlSecurityUtility.GetBase64LengthFromByteLength(keyInfo.EncryptedKey.Length) + keyInfo.KeyStoreName.Length + 2/*separators*/);
+ StringBuilder cacheLookupKeyBuilder = new StringBuilder(serverName, capacity: serverName.Length + SqlSecurityUtility.GetBase64LengthFromByteLength(keyInfo.encryptedKey.Length) + keyInfo.keyStoreName.Length + 2/*separators*/);
#if DEBUG
int capacity = cacheLookupKeyBuilder.Capacity;
#endif //DEBUG
cacheLookupKeyBuilder.Append(":");
- cacheLookupKeyBuilder.Append(Convert.ToBase64String(keyInfo.EncryptedKey));
+ cacheLookupKeyBuilder.Append(Convert.ToBase64String(keyInfo.encryptedKey));
cacheLookupKeyBuilder.Append(":");
- cacheLookupKeyBuilder.Append(keyInfo.KeyStoreName);
+ cacheLookupKeyBuilder.Append(keyInfo.keyStoreName);
string cacheLookupKey = cacheLookupKeyBuilder.ToString();
@@ -58,12 +58,12 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
Debug.Assert(SqlConnection.ColumnEncryptionTrustedMasterKeyPaths is not null, @"SqlConnection.ColumnEncryptionTrustedMasterKeyPaths should not be null");
- SqlSecurityUtility.ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.KeyPath);
+ SqlSecurityUtility.ThrowIfKeyPathIsNotTrustedForServer(serverName, keyInfo.keyPath);
// Key Not found, attempt to look up the provider and decrypt CEK
- if (!SqlSecurityUtility.TryGetColumnEncryptionKeyStoreProvider(keyInfo.KeyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
+ if (!SqlSecurityUtility.TryGetColumnEncryptionKeyStoreProvider(keyInfo.keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider, connection, command))
{
- throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.KeyStoreName,
+ throw SQL.UnrecognizedKeyStoreProviderName(keyInfo.keyStoreName,
SqlConnection.GetColumnEncryptionSystemKeyStoreProvidersNames(),
SqlSecurityUtility.GetListOfProviderNamesThatWereSearched(connection, command));
}
@@ -75,13 +75,13 @@ internal SqlClientSymmetricKey GetKey(SqlEncryptionKeyInfo keyInfo, SqlConnectio
{
// to prevent conflicts between CEK caches, global providers should not use their own CEK caches
provider.ColumnEncryptionKeyCacheTtl = new TimeSpan(0);
- plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.KeyPath, keyInfo.AlgorithmName, keyInfo.EncryptedKey);
+ plaintextKey = provider.DecryptColumnEncryptionKey(keyInfo.keyPath, keyInfo.algorithmName, keyInfo.encryptedKey);
}
catch (Exception e)
{
// Generate a new exception and throw.
- string keyHex = SqlSecurityUtility.GetBytesAsString(keyInfo.EncryptedKey, fLast: true, countOfBytes: 10);
- throw SQL.KeyDecryptionFailed(keyInfo.KeyStoreName, keyHex, e);
+ string keyHex = SqlSecurityUtility.GetBytesAsString(keyInfo.encryptedKey, fLast: true, countOfBytes: 10);
+ throw SQL.KeyDecryptionFailed(keyInfo.keyStoreName, keyHex, e);
}
encryptionKey = new SqlClientSymmetricKey(plaintextKey);
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
index b5e028f01e..4e9fb26c32 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -59,29 +59,29 @@ internal void TdsLogin(
#endif
SqlConnectionEncryptOption encrypt)
{
- _physicalStateObj.SetTimeoutSeconds(rec.Timeout);
+ _physicalStateObj.SetTimeoutSeconds(rec.timeout);
Debug.Assert(recoverySessionData == null || (requestedFeatures & TdsEnums.FeatureExtension.SessionRecovery) != 0, "Recovery session data without session recovery feature request");
- Debug.Assert(TdsEnums.MAXLEN_HOSTNAME >= rec.HostName.Length, "_workstationId.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_HOSTNAME >= rec.hostName.Length, "_workstationId.Length exceeds the max length for this value");
- Debug.Assert(!(rec.UseSspi && _connHandler._fedAuthRequired), "Cannot use SSPI when server has responded 0x01 for FedAuthRequired PreLogin Option.");
- Debug.Assert(!rec.UseSspi || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) == 0, "Cannot use both SSPI and FedAuth");
+ Debug.Assert(!(rec.useSSPI && _connHandler._fedAuthRequired), "Cannot use SSPI when server has responded 0x01 for FedAuthRequired PreLogin Option.");
+ Debug.Assert(!rec.useSSPI || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) == 0, "Cannot use both SSPI and FedAuth");
Debug.Assert(fedAuthFeatureExtensionData == null || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) != 0, "fedAuthFeatureExtensionData provided without fed auth feature request");
Debug.Assert(fedAuthFeatureExtensionData != null || (requestedFeatures & TdsEnums.FeatureExtension.FedAuth) == 0, "Fed Auth feature requested without specifying fedAuthFeatureExtensionData.");
- Debug.Assert(rec.UserName == null || (rec.UserName != null && TdsEnums.MAXLEN_CLIENTID >= rec.UserName.Length), "_userID.Length exceeds the max length for this value");
- Debug.Assert(rec.Credential == null || (rec.Credential != null && TdsEnums.MAXLEN_CLIENTID >= rec.Credential.UserId.Length), "_credential.UserId.Length exceeds the max length for this value");
+ Debug.Assert(rec.userName == null || (rec.userName != null && TdsEnums.MAXLEN_CLIENTID >= rec.userName.Length), "_userID.Length exceeds the max length for this value");
+ Debug.Assert(rec.credential == null || (rec.credential != null && TdsEnums.MAXLEN_CLIENTID >= rec.credential.UserId.Length), "_credential.UserId.Length exceeds the max length for this value");
- Debug.Assert(rec.Password == null || (rec.Password != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec.Password.Length), "_password.Length exceeds the max length for this value");
- Debug.Assert(rec.Credential == null || (rec.Credential != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec.Credential.Password.Length), "_credential.Password.Length exceeds the max length for this value");
+ Debug.Assert(rec.password == null || (rec.password != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec.password.Length), "_password.Length exceeds the max length for this value");
+ Debug.Assert(rec.credential == null || (rec.credential != null && TdsEnums.MAXLEN_CLIENTSECRET >= rec.credential.Password.Length), "_credential.Password.Length exceeds the max length for this value");
- Debug.Assert(rec.Credential != null || rec.UserName != null || rec.Password != null, "cannot mix the new secure password system and the connection string based password");
- Debug.Assert(rec.NewSecurePassword != null || rec.NewPassword != null, "cannot have both new secure change password and string based change password");
- Debug.Assert(TdsEnums.MAXLEN_APPNAME >= rec.ApplicationName.Length, "_applicationName.Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_SERVERNAME >= rec.ServerName.Length, "_dataSource.Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_LANGUAGE >= rec.Language.Length, "_currentLanguage .Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_DATABASE >= rec.Database.Length, "_initialCatalog.Length exceeds the max length for this value");
- Debug.Assert(TdsEnums.MAXLEN_ATTACHDBFILE >= rec.AttachDbFilename.Length, "_attachDBFileName.Length exceeds the max length for this value");
+ Debug.Assert(rec.credential != null || rec.userName != null || rec.password != null, "cannot mix the new secure password system and the connection string based password");
+ Debug.Assert(rec.newSecurePassword != null || rec.newPassword != null, "cannot have both new secure change password and string based change password");
+ Debug.Assert(TdsEnums.MAXLEN_APPNAME >= rec.applicationName.Length, "_applicationName.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_SERVERNAME >= rec.serverName.Length, "_dataSource.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_LANGUAGE >= rec.language.Length, "_currentLanguage .Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_DATABASE >= rec.database.Length, "_initialCatalog.Length exceeds the max length for this value");
+ Debug.Assert(TdsEnums.MAXLEN_ATTACHDBFILE >= rec.attachDBFilename.Length, "_attachDBFileName.Length exceeds the max length for this value");
Debug.Assert(_connHandler != null, "SqlConnectionInternalTds handler can not be null at this point.");
_connHandler!.TimeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.LoginBegin);
@@ -121,25 +121,25 @@ internal void TdsLogin(
string userName;
- if (rec.Credential != null)
+ if (rec.credential != null)
{
- userName = rec.Credential.UserId;
- encryptedPasswordLengthInBytes = rec.Credential.Password.Length * 2;
+ userName = rec.credential.UserId;
+ encryptedPasswordLengthInBytes = rec.credential.Password.Length * 2;
}
else
{
- userName = rec.UserName;
- encryptedPassword = TdsParserStaticMethods.ObfuscatePassword(rec.Password);
+ userName = rec.userName;
+ encryptedPassword = TdsParserStaticMethods.ObfuscatePassword(rec.password);
encryptedPasswordLengthInBytes = encryptedPassword.Length; // password in clear text is already encrypted and its length is in byte
}
- if (rec.NewSecurePassword != null)
+ if (rec.newSecurePassword != null)
{
- encryptedChangePasswordLengthInBytes = rec.NewSecurePassword.Length * 2;
+ encryptedChangePasswordLengthInBytes = rec.newSecurePassword.Length * 2;
}
else
{
- encryptedChangePassword = TdsParserStaticMethods.ObfuscatePassword(rec.NewPassword);
+ encryptedChangePassword = TdsParserStaticMethods.ObfuscatePassword(rec.newPassword);
encryptedChangePasswordLengthInBytes = encryptedChangePassword.Length;
}
@@ -156,10 +156,10 @@ internal void TdsLogin(
//
checked
{
- length += (rec.HostName.Length + rec.ApplicationName.Length +
- rec.ServerName.Length + clientInterfaceName.Length +
- rec.Language.Length + rec.Database.Length +
- rec.AttachDbFilename.Length) * 2;
+ length += (rec.hostName.Length + rec.applicationName.Length +
+ rec.serverName.Length + clientInterfaceName.Length +
+ rec.language.Length + rec.database.Length +
+ rec.attachDBFilename.Length) * 2;
if (useFeatureExt)
{
length += 4;
@@ -172,7 +172,7 @@ internal void TdsLogin(
uint outSSPILength = 0;
// only add lengths of password and username if not using SSPI or requesting federated authentication info
- if (!rec.UseSspi && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
+ if (!rec.useSSPI && !(_connHandler._federatedAuthenticationInfoRequested || _connHandler._federatedAuthenticationRequested))
{
checked
{
@@ -182,7 +182,7 @@ internal void TdsLogin(
}
else
{
- if (rec.UseSspi)
+ if (rec.useSSPI)
{
// now allocate proper length of buffer, and set length
outSSPILength = _authenticationProvider.MaxSSPILength;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index f5336cbd33..ce4cd7d20c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -77,10 +77,10 @@ internal enum TdsParserState
///
internal sealed class FederatedAuthenticationFeatureExtensionData
{
- public TdsEnums.FedAuthLibrary LibraryType;
- public bool FedAuthRequiredPreLoginResponse;
- public SqlAuthenticationMethod Authentication;
- public byte[] AccessToken;
+ internal TdsEnums.FedAuthLibrary libraryType;
+ internal bool fedAuthRequiredPreLoginResponse;
+ internal SqlAuthenticationMethod authentication;
+ internal byte[] accessToken;
}
internal sealed class RoutingInfo
@@ -99,54 +99,54 @@ internal RoutingInfo(byte protocol, ushort port, string servername)
internal sealed class SqlLogin
{
- public SqlAuthenticationMethod Authentication = SqlAuthenticationMethod.NotSpecified; // Authentication type
- public int Timeout; // login timeout
- public bool UserInstance = false; // user instance
- public string HostName = ""; // client machine name
- public string UserName = ""; // user id
- public string Password = ""; // password
- public string ApplicationName = ""; // application name
- public string ServerName = ""; // server name
- public string Language = ""; // initial language
- public string Database = ""; // initial database
- public string AttachDbFilename = ""; // DB filename to be attached
- public bool UseReplication = false; // user login for replication
- public string NewPassword = ""; // new password for reset password
- public bool UseSspi = false; // use integrated security
- public int PacketSize = SqlConnectionString.DEFAULT.Packet_Size; // packet size
- public bool ReadOnlyIntent = false; // read-only intent
- public SqlCredential Credential; // user id and password in SecureString
- public SecureString NewSecurePassword;
+ internal SqlAuthenticationMethod authentication = SqlAuthenticationMethod.NotSpecified; // Authentication type
+ internal int timeout; // login timeout
+ internal bool userInstance = false; // user instance
+ internal string hostName = ""; // client machine name
+ internal string userName = ""; // user id
+ internal string password = ""; // password
+ internal string applicationName = ""; // application name
+ internal string serverName = ""; // server name
+ internal string language = ""; // initial language
+ internal string database = ""; // initial database
+ internal string attachDBFilename = ""; // DB filename to be attached
+ internal bool useReplication = false; // user login for replication
+ internal string newPassword = ""; // new password for reset password
+ internal bool useSSPI = false; // use integrated security
+ internal int packetSize = SqlConnectionString.DEFAULT.Packet_Size; // packet size
+ internal bool readOnlyIntent = false; // read-only intent
+ internal SqlCredential credential; // user id and password in SecureString
+ internal SecureString newSecurePassword;
}
internal sealed class SqlLoginAck
{
- public byte MajorVersion;
- public byte MinorVersion;
- public short BuildNum;
- public uint TdsVersion;
+ internal byte majorVersion;
+ internal byte minorVersion;
+ internal short buildNum;
+ internal uint tdsVersion;
#if NETFRAMEWORK
- public string ProgramName;
+ internal string programName;
- public bool IsVersion8;
+ internal bool isVersion8;
#endif
}
internal sealed class SqlFedAuthInfo
{
- public string Spn;
- public string StsUrl;
+ internal string spn;
+ internal string stsurl;
public override string ToString()
{
- return $"STSURL: {StsUrl}, SPN: {Spn}";
+ return $"STSURL: {stsurl}, SPN: {spn}";
}
}
internal sealed class SqlFedAuthToken
{
- public uint DataLen;
- public byte[] AccessToken;
- public long ExpirationFileTime;
+ internal uint dataLen;
+ internal byte[] accessToken;
+ internal long expirationFileTime;
}
internal sealed class _SqlMetaData : SqlMetaDataPriv
@@ -168,58 +168,58 @@ private enum _SqlMetadataFlags : int
IsUpdatableMask = (Updatable | UpdateableUnknown) // two bit field (0 is read only, 1 is updatable, 2 is updatability unknown)
}
- public string Column;
- public string BaseColumn;
- public MultiPartTableName MultiPartTableName;
- public readonly int Ordinal;
- public byte TableNum;
- public byte Op; // for altrow-columns only
- public ushort Operand; // for altrow-columns only
- private _SqlMetadataFlags _flags;
+ internal string column;
+ internal string baseColumn;
+ internal MultiPartTableName multiPartTableName;
+ internal readonly int ordinal;
+ internal byte tableNum;
+ internal byte op; // for altrow-columns only
+ internal ushort operand; // for altrow-columns only
+ private _SqlMetadataFlags flags;
- public _SqlMetaData(int ordinal) : base()
+ internal _SqlMetaData(int ordinal) : base()
{
- Ordinal = ordinal;
+ this.ordinal = ordinal;
}
private bool HasFlag(_SqlMetadataFlags flag)
{
- return (_flags & flag) != 0;
+ return (flags & flag) != 0;
}
- public string ServerName
+ internal string serverName
{
get
{
- return MultiPartTableName.ServerName;
+ return multiPartTableName.ServerName;
}
}
- public string CatalogName
+ internal string catalogName
{
get
{
- return MultiPartTableName.CatalogName;
+ return multiPartTableName.CatalogName;
}
}
- public string SchemaName
+ internal string schemaName
{
get
{
- return MultiPartTableName.SchemaName;
+ return multiPartTableName.SchemaName;
}
}
- public string TableName
+ internal string tableName
{
get
{
- return MultiPartTableName.TableName;
+ return multiPartTableName.TableName;
}
}
public byte Updatability
{
- get => (byte)(_flags & _SqlMetadataFlags.IsUpdatableMask);
- set => _flags = (_SqlMetadataFlags)((value & (byte)_SqlMetadataFlags.IsUpdatableMask) | ((int)_flags & ~(byte)_SqlMetadataFlags.IsUpdatableMask));
+ get => (byte)(flags & _SqlMetadataFlags.IsUpdatableMask);
+ set => flags = (_SqlMetadataFlags)((value & (byte)_SqlMetadataFlags.IsUpdatableMask) | ((int)flags & ~(byte)_SqlMetadataFlags.IsUpdatableMask));
}
public bool IsReadOnly
@@ -265,55 +265,54 @@ public bool IsColumnSet
private void Set(_SqlMetadataFlags flag, bool value)
{
- _flags = value ? _flags | flag : _flags & ~flag;
+ flags = value ? flags | flag : flags & ~flag;
}
- public bool Is2008DateTimeType
+ internal bool Is2008DateTimeType
{
get
{
- return SqlDbType.Date == Type || SqlDbType.Time == Type || SqlDbType.DateTime2 == Type || SqlDbType.DateTimeOffset == Type;
+ return SqlDbType.Date == type || SqlDbType.Time == type || SqlDbType.DateTime2 == type || SqlDbType.DateTimeOffset == type;
}
}
- public bool IsLargeUdt
+ internal bool IsLargeUdt
{
get
{
- return Type == SqlDbType.Udt && Length == int.MaxValue;
+ return type == SqlDbType.Udt && length == int.MaxValue;
}
}
public object Clone()
{
- _SqlMetaData result = new(Ordinal);
+ _SqlMetaData result = new _SqlMetaData(ordinal);
result.CopyFrom(this);
- result.Column = Column;
- result.BaseColumn = BaseColumn;
- result.MultiPartTableName = MultiPartTableName;
- result.TableNum = TableNum;
- result._flags = _flags;
- result.Op = Op;
- result.Operand = Operand;
+ result.column = column;
+ result.baseColumn = baseColumn;
+ result.multiPartTableName = multiPartTableName;
+ result.tableNum = tableNum;
+ result.flags = flags;
+ result.op = op;
+ result.operand = operand;
return result;
}
}
internal sealed partial class _SqlMetaDataSet
{
- public ushort Id; // for altrow-columns only
+ internal ushort id; // for altrow-columns only
- public DataTable SchemaTable;
+ internal DataTable schemaTable;
+ private readonly _SqlMetaData[] _metaDataArray;
#if NET
- public ReadOnlyCollection DbColumnSchema;
+ internal ReadOnlyCollection dbColumnSchema;
#endif
- private readonly _SqlMetaData[] _metaDataArray;
-
private int _hiddenColumnCount;
private int[] _visibleColumnMap;
- public _SqlMetaDataSet(int count)
+ internal _SqlMetaDataSet(int count)
{
_hiddenColumnCount = -1;
_metaDataArray = new _SqlMetaData[count];
@@ -325,13 +324,13 @@ public _SqlMetaDataSet(int count)
private _SqlMetaDataSet(_SqlMetaDataSet original)
{
- Id = original.Id;
+ id = original.id;
_hiddenColumnCount = original._hiddenColumnCount;
_visibleColumnMap = original._visibleColumnMap;
#if NET
- DbColumnSchema = original.DbColumnSchema;
+ dbColumnSchema = original.dbColumnSchema;
#else
- SchemaTable = original.SchemaTable;
+ schemaTable = original.schemaTable;
#endif
if (original._metaDataArray == null)
{
@@ -347,7 +346,7 @@ private _SqlMetaDataSet(_SqlMetaDataSet original)
}
}
- public int Length
+ internal int Length
{
get
{
@@ -355,7 +354,7 @@ public int Length
}
}
- public int VisibleColumnCount
+ internal int VisibleColumnCount
{
get
{
@@ -367,7 +366,7 @@ public int VisibleColumnCount
}
}
- public _SqlMetaData this[int index]
+ internal _SqlMetaData this[int index]
{
get
{
@@ -433,20 +432,20 @@ private void SetupHiddenColumns()
internal sealed class _SqlMetaDataSetCollection
{
private readonly List<_SqlMetaDataSet> _altMetaDataSetArray;
- public _SqlMetaDataSet MetaDataSet;
+ internal _SqlMetaDataSet metaDataSet;
- public _SqlMetaDataSetCollection()
+ internal _SqlMetaDataSetCollection()
{
_altMetaDataSetArray = new List<_SqlMetaDataSet>();
}
- public void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
+ internal void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
{
// If altmetadata with same id is found, override it rather than adding a new one
- int newId = altMetaDataSet.Id;
+ int newId = altMetaDataSet.id;
for (int i = 0; i < _altMetaDataSetArray.Count; i++)
{
- if (_altMetaDataSetArray[i].Id == newId)
+ if (_altMetaDataSetArray[i].id == newId)
{
// override the existing metadata with the same id
_altMetaDataSetArray[i] = altMetaDataSet;
@@ -458,11 +457,11 @@ public void SetAltMetaData(_SqlMetaDataSet altMetaDataSet)
_altMetaDataSetArray.Add(altMetaDataSet);
}
- public _SqlMetaDataSet GetAltMetaData(int id)
+ internal _SqlMetaDataSet GetAltMetaData(int id)
{
foreach (_SqlMetaDataSet altMetaDataSet in _altMetaDataSetArray)
{
- if (altMetaDataSet.Id == id)
+ if (altMetaDataSet.id == id)
{
return altMetaDataSet;
}
@@ -473,7 +472,7 @@ public _SqlMetaDataSet GetAltMetaData(int id)
public object Clone()
{
- _SqlMetaDataSetCollection result = new() { MetaDataSet = MetaDataSet?.Clone() };
+ _SqlMetaDataSetCollection result = new _SqlMetaDataSetCollection() { metaDataSet = metaDataSet?.Clone() };
foreach (_SqlMetaDataSet set in _altMetaDataSetArray)
{
@@ -493,19 +492,19 @@ private enum SqlMetaDataPrivFlags : byte
IsMultiValued = 1 << 2
}
- public SqlDbType Type; // SqlDbType enum value
- public byte TdsType; // underlying tds type
- public byte Precision = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
- public byte Scale = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
- private SqlMetaDataPrivFlags _flags;
- public int Length;
- public SqlCollation Collation;
- public int CodePage;
- public Encoding Encoding;
+ internal SqlDbType type; // SqlDbType enum value
+ internal byte tdsType; // underlying tds type
+ internal byte precision = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
+ internal byte scale = TdsEnums.UNKNOWN_PRECISION_SCALE; // give default of unknown (-1)
+ private SqlMetaDataPrivFlags flags;
+ internal int length;
+ internal SqlCollation collation;
+ internal int codePage;
+ internal Encoding encoding;
- public MetaType MetaType; // cached metaType
- public SqlMetaDataUdt Udt;
- public SqlMetaDataXmlSchemaCollection XmlSchemaCollection;
+ internal MetaType metaType; // cached metaType
+ public SqlMetaDataUdt udt;
+ public SqlMetaDataXmlSchemaCollection xmlSchemaCollection;
internal SqlMetaDataPriv()
{
@@ -525,46 +524,46 @@ public bool IsMultiValued
private bool HasFlag(SqlMetaDataPrivFlags flag)
{
- return (_flags & flag) != 0;
+ return (flags & flag) != 0;
}
private void Set(SqlMetaDataPrivFlags flag, bool value)
{
- _flags = value ? _flags | flag : _flags & ~flag;
+ flags = value ? flags | flag : flags & ~flag;
}
internal void CopyFrom(SqlMetaDataPriv original)
{
- Type = original.Type;
- TdsType = original.TdsType;
- Precision = original.Precision;
- Scale = original.Scale;
- Length = original.Length;
- Collation = original.Collation;
- CodePage = original.CodePage;
- Encoding = original.Encoding;
- MetaType = original.MetaType;
- _flags = original._flags;
+ this.type = original.type;
+ this.tdsType = original.tdsType;
+ this.precision = original.precision;
+ this.scale = original.scale;
+ this.length = original.length;
+ this.collation = original.collation;
+ this.codePage = original.codePage;
+ this.encoding = original.encoding;
+ this.metaType = original.metaType;
+ this.flags = original.flags;
- if (original.Udt != null)
+ if (original.udt != null)
{
- Udt = new SqlMetaDataUdt();
- Udt.CopyFrom(original.Udt);
+ udt = new SqlMetaDataUdt();
+ udt.CopyFrom(original.udt);
}
- if (original.XmlSchemaCollection != null)
+ if (original.xmlSchemaCollection != null)
{
- XmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
- XmlSchemaCollection.CopyFrom(original.XmlSchemaCollection);
+ xmlSchemaCollection = new SqlMetaDataXmlSchemaCollection();
+ xmlSchemaCollection.CopyFrom(original.xmlSchemaCollection);
}
}
}
internal sealed class SqlMetaDataXmlSchemaCollection
{
- public string Database;
- public string OwningSchema;
- public string Name;
+ internal string Database;
+ internal string OwningSchema;
+ internal string Name;
public void CopyFrom(SqlMetaDataXmlSchemaCollection original)
{
@@ -582,11 +581,11 @@ internal sealed class SqlMetaDataUdt
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
- public Type Type;
- public string DatabaseName;
- public string SchemaName;
- public string TypeName;
- public string AssemblyQualifiedName;
+ internal Type Type;
+ internal string DatabaseName;
+ internal string SchemaName;
+ internal string TypeName;
+ internal string AssemblyQualifiedName;
public void CopyFrom(SqlMetaDataUdt original)
{
@@ -603,77 +602,77 @@ public void CopyFrom(SqlMetaDataUdt original)
internal sealed class _SqlRPC
{
- public string RpcName;
- public ushort ProcId; // Used instead of name
- public ushort Options;
+ internal string rpcName;
+ internal ushort ProcID; // Used instead of name
+ internal ushort options;
- public SqlParameter[] SystemParams;
- public byte[] SystemParamOptions;
- public int SystemParamCount;
+ internal SqlParameter[] systemParams;
+ internal byte[] systemParamOptions;
+ internal int systemParamCount;
- public SqlParameterCollection UserParams;
- public long[] UserParamMap;
- public int UserParamCount;
+ internal SqlParameterCollection userParams;
+ internal long[] userParamMap;
+ internal int userParamCount;
- public int? RecordsAffected;
- public int CumulativeRecordsAffected;
+ internal int? recordsAffected;
+ internal int cumulativeRecordsAffected;
- public int ErrorsIndexStart;
- public int ErrorsIndexEnd;
- public SqlErrorCollection Errors;
+ internal int errorsIndexStart;
+ internal int errorsIndexEnd;
+ internal SqlErrorCollection errors;
- public int WarningsIndexStart;
- public int WarningsIndexEnd;
- public SqlErrorCollection Warnings;
+ internal int warningsIndexStart;
+ internal int warningsIndexEnd;
+ internal SqlErrorCollection warnings;
- public bool NeedsFetchParameterEncryptionMetadata;
+ internal bool needsFetchParameterEncryptionMetadata;
- public SqlBatchCommand BatchCommand;
+ internal SqlBatchCommand batchCommand;
- public string GetCommandTextOrRpcName()
+ internal string GetCommandTextOrRpcName()
{
- if (TdsEnums.RPC_PROCID_EXECUTESQL == ProcId)
+ if (TdsEnums.RPC_PROCID_EXECUTESQL == ProcID)
{
// Param 0 is the actual sql executing
- return (string)SystemParams[0].Value;
+ return (string)systemParams[0].Value;
}
else
{
- return RpcName;
+ return rpcName;
}
}
- public SqlParameter GetParameterByIndex(int index, out byte options)
+ internal SqlParameter GetParameterByIndex(int index, out byte options)
{
SqlParameter retval;
- if (index < SystemParamCount)
+ if (index < systemParamCount)
{
- retval = SystemParams[index];
- options = SystemParamOptions[index];
+ retval = systemParams[index];
+ options = systemParamOptions[index];
}
else
{
- long data = UserParamMap[index - SystemParamCount];
+ long data = userParamMap[index - systemParamCount];
int paramIndex = (int)(data & int.MaxValue);
options = (byte)((data >> 32) & 0xFF);
- retval = UserParams[paramIndex];
+ retval = userParams[paramIndex];
}
return retval;
}
}
- internal sealed partial class SqlReturnValue : SqlMetaDataPriv
+ internal sealed class SqlReturnValue : SqlMetaDataPriv
{
- public string Parameter;
- public readonly SqlBuffer Value;
+ internal string parameter;
+ internal readonly SqlBuffer value;
#if NETFRAMEWORK
- public ushort ParmIndex; //2005 or later only
+ internal ushort parmIndex; //2005 or later only
#endif
- public SqlReturnValue() : base()
+ internal SqlReturnValue() : base()
{
- Value = new SqlBuffer();
+ value = new SqlBuffer();
}
}
@@ -753,7 +752,7 @@ private void ParseMultipartName()
}
}
- public static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
+ internal static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
}
internal static class SslProtocolsHelper
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs
index 8feaa5f5fc..ae7d860a42 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/Utility.cs
@@ -29,9 +29,9 @@ public static class Utility
public static Type SqlCipherMetadata = systemData.GetType("Microsoft.Data.SqlClient.SqlCipherMetadata");
public static FieldInfo sqlTceCipherInfoEntryField = SqlCipherMetadata.GetField("_sqlTceCipherInfoEntry", BindingFlags.Instance | BindingFlags.NonPublic);
public static Type SqlTceCipherInfoEntry = systemData.GetType("Microsoft.Data.SqlClient.SqlTceCipherInfoEntry");
- public static MethodInfo SqlTceCipherInfoEntryAdd = SqlTceCipherInfoEntry.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public);
- public static ConstructorInfo SqlCipherMetadataConstructor = SqlCipherMetadata.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { SqlTceCipherInfoEntry, typeof(ushort), typeof(byte), typeof(string), typeof(byte), typeof(byte) }, null);
- public static ConstructorInfo SqlTceCipherInfoEntryConstructor = SqlTceCipherInfoEntry.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
+ public static MethodInfo SqlTceCipherInfoEntryAdd = SqlTceCipherInfoEntry.GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic);
+ public static ConstructorInfo SqlCipherMetadataConstructor = SqlCipherMetadata.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { SqlTceCipherInfoEntry, typeof(ushort), typeof(byte), typeof(string), typeof(byte), typeof(byte) }, null);
+ public static ConstructorInfo SqlTceCipherInfoEntryConstructor = SqlTceCipherInfoEntry.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
public static Type SqlSecurityUtil = systemData.GetType("Microsoft.Data.SqlClient.SqlSecurityUtility", throwOnError: true);
public static MethodInfo SqlSecurityUtilEncryptWithKey = SqlSecurityUtil.GetMethod("EncryptWithKey", BindingFlags.Static | BindingFlags.NonPublic);
public static MethodInfo SqlSecurityUtilDecryptWithKey = SqlSecurityUtil.GetMethod("DecryptWithKey", BindingFlags.Static | BindingFlags.NonPublic);
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs
index 6e22d25db5..26d2477b9b 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/FedAuthTokenHelper.cs
@@ -77,7 +77,7 @@ internal static string GetTokenHash(object authenticationContextValueObj)
byte[] tokenBytes = (byte[])authenticationContextValueObj.GetType().GetProperty("AccessToken", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(authenticationContextValueObj, null);
object sqlFedAuthTokenObj = sqlFedAuthTokenConstructorInfo.Invoke(new object[] { });
- FieldInfo accessTokenInfo = sqlFedAuthTokenObj.GetType().GetField("AccessToken", BindingFlags.NonPublic | BindingFlags.Instance);
+ FieldInfo accessTokenInfo = sqlFedAuthTokenObj.GetType().GetField("accessToken", BindingFlags.NonPublic | BindingFlags.Instance);
accessTokenInfo.SetValue(sqlFedAuthTokenObj, tokenBytes);
string tokenHash = (string)tokenHashInfo.Invoke(activeDirectoryAuthenticationTimeoutRetryHelperObj, new object[] { sqlFedAuthTokenObj });
From 9422905c16232955a387b45b49dc28a6bd41ba0b Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Sat, 24 Aug 2024 18:19:23 +0100
Subject: [PATCH 13/14] Code review feedback
Reverted sealing of several classes
---
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 1 +
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 22 +++++++++----------
.../Data/SqlClient/TdsParserHelperClasses.cs | 6 ++---
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
index a6b19e8f50..4cee4ff95c 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -8410,6 +8410,7 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
return len;
}
+
private void WriteLoginData(SqlLogin rec,
TdsEnums.FeatureExtension requestedFeatures,
SessionData recoverySessionData,
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
index eeeb457e7c..b1bd8f3a63 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
@@ -14,7 +14,7 @@ namespace Microsoft.Data.SqlClient
/// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
/// the store type, name,the key path and encryption algorithm.
///
- internal sealed class SqlEncryptionKeyInfo
+ internal class SqlEncryptionKeyInfo
{
internal byte[] encryptedKey; // the encrypted "column encryption key"
internal int databaseId;
@@ -32,7 +32,7 @@ internal sealed class SqlEncryptionKeyInfo
/// rotation scenario) We need to keep all these around until we can resolve the CEK
/// using the correct master key.
///
- internal sealed class SqlTceCipherInfoEntry
+ internal class SqlTceCipherInfoEntry
{
///
@@ -196,27 +196,27 @@ internal SqlTceCipherInfoEntry(int ordinal = 0)
/// may have been encrypted using multiple master keys (giving us multiple CEK values). All these values form one single
/// entry in this table.
///
- internal sealed class SqlTceCipherInfoTable
+ internal class SqlTceCipherInfoTable
{
- private readonly SqlTceCipherInfoEntry[] _keyList;
+ private readonly SqlTceCipherInfoEntry[] keyList;
internal SqlTceCipherInfoTable(int tabSize)
{
Debug.Assert(0 < tabSize, "Invalid Table Size");
- _keyList = new SqlTceCipherInfoEntry[tabSize];
+ keyList = new SqlTceCipherInfoEntry[tabSize];
}
internal SqlTceCipherInfoEntry this[int index]
{
get
{
- Debug.Assert(index < _keyList.Length, "Invalid index specified.");
- return _keyList[index];
+ Debug.Assert(index < keyList.Length, "Invalid index specified.");
+ return keyList[index];
}
set
{
- Debug.Assert(index < _keyList.Length, "Invalid index specified.");
- _keyList[index] = value;
+ Debug.Assert(index < keyList.Length, "Invalid index specified.");
+ keyList[index] = value;
}
}
@@ -224,7 +224,7 @@ internal int Size
{
get
{
- return _keyList.Length;
+ return keyList.Length;
}
}
}
@@ -243,7 +243,7 @@ internal _SqlMetaDataSet(int count, SqlTceCipherInfoTable cipherTable)
///
/// Represents Encryption related information of the cipher data.
///
- internal sealed class SqlCipherMetadata
+ internal class SqlCipherMetadata
{
///
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index ce4cd7d20c..c27264b8f9 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -75,7 +75,7 @@ internal enum TdsParserState
///
/// Class encapsulating the data to be sent to the server as part of Federated Authentication Feature Extension.
///
- internal sealed class FederatedAuthenticationFeatureExtensionData
+ internal class FederatedAuthenticationFeatureExtensionData
{
internal TdsEnums.FedAuthLibrary libraryType;
internal bool fedAuthRequiredPreLoginResponse;
@@ -83,7 +83,7 @@ internal sealed class FederatedAuthenticationFeatureExtensionData
internal byte[] accessToken;
}
- internal sealed class RoutingInfo
+ internal class RoutingInfo
{
internal byte Protocol { get; private set; }
internal ushort Port { get; private set; }
@@ -532,7 +532,7 @@ private void Set(SqlMetaDataPrivFlags flag, bool value)
flags = value ? flags | flag : flags & ~flag;
}
- internal void CopyFrom(SqlMetaDataPriv original)
+ internal virtual void CopyFrom(SqlMetaDataPriv original)
{
this.type = original.type;
this.tdsType = original.tdsType;
From e20154415fe3743446358f8834f4f14d09f556d8 Mon Sep 17 00:00:00 2001
From: Edward Neal <55035479+edwardneal@users.noreply.github.com>
Date: Fri, 4 Oct 2024 07:45:19 +0100
Subject: [PATCH 14/14] Responding to code review
---
.../src/Microsoft/Data/SqlClient/TdsParser.cs | 2 +-
.../SqlClient/AlwaysEncryptedHelperClasses.cs | 12 +--
.../Data/SqlClient/TdsParserHelperClasses.cs | 92 ++-----------------
3 files changed, 16 insertions(+), 90 deletions(-)
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
index fb0884bb36..758499f55f 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -1300,7 +1300,7 @@ private void EnableSsl(uint info, SqlConnectionEncryptOption encrypt, bool integ
ThrowExceptionAndWarning(_physicalStateObj);
}
- string warningMessage = SslProtocolsHelper.GetProtocolWarning(protocolVersion);
+ string warningMessage = ((System.Security.Authentication.SslProtocols)protocolVersion).GetProtocolWarning();
if (!string.IsNullOrEmpty(warningMessage))
{
if (!encrypt && LocalAppContextSwitches.SuppressInsecureTLSWarning)
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
index b1bd8f3a63..a574e6c366 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncryptedHelperClasses.cs
@@ -11,8 +11,8 @@ namespace Microsoft.Data.SqlClient
{
///
- /// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
- /// the store type, name,the key path and encryption algorithm.
+ /// Represents a single encrypted value for a CEK. It contains the encrypted CEK,
+ /// the store type, name,the key path and encryption algorithm.
///
internal class SqlEncryptionKeyInfo
{
@@ -27,10 +27,10 @@ internal class SqlEncryptionKeyInfo
}
///
- /// Encapsulates one entry in the CipherInfo table sent as part of Colmetadata.
+ /// Encapsulates one entry in the CipherInfo table sent as part of Colmetadata.
/// The same CEK is encrypted multiple times with different master keys (for master key
/// rotation scenario) We need to keep all these around until we can resolve the CEK
- /// using the correct master key.
+ /// using the correct master key.
///
internal class SqlTceCipherInfoEntry
{
@@ -192,9 +192,9 @@ internal SqlTceCipherInfoEntry(int ordinal = 0)
}
///
- /// Represents a table with various CEKs used in a resultset. Each entry corresponds to one (unique) CEK. The CEK
+ /// Represents a table with various CEKs used in a resultset. Each entry corresponds to one (unique) CEK. The CEK
/// may have been encrypted using multiple master keys (giving us multiple CEK values). All these values form one single
- /// entry in this table.
+ /// entry in this table.
///
internal class SqlTceCipherInfoTable
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
index c27264b8f9..a5355905d3 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs
@@ -305,7 +305,7 @@ internal sealed partial class _SqlMetaDataSet
internal DataTable schemaTable;
private readonly _SqlMetaData[] _metaDataArray;
-#if NET
+#if !NETFRAMEWORK
internal ReadOnlyCollection dbColumnSchema;
#endif
@@ -327,7 +327,7 @@ private _SqlMetaDataSet(_SqlMetaDataSet original)
id = original.id;
_hiddenColumnCount = original._hiddenColumnCount;
_visibleColumnMap = original._visibleColumnMap;
-#if NET
+#if !NETFRAMEWORK
dbColumnSchema = original.dbColumnSchema;
#else
schemaTable = original.schemaTable;
@@ -757,7 +757,6 @@ private void ParseMultipartName()
internal static class SslProtocolsHelper
{
-#if NET
private static string ToFriendlyName(this SslProtocols protocol)
{
string name;
@@ -798,7 +797,11 @@ private static string ToFriendlyName(this SslProtocols protocol)
}
else
{
+#if !NETFRAMEWORK
name = protocol.ToString();
+#else
+ throw new ArgumentException(StringsHelper.GetString(StringsHelper.net_invalid_enum, "NativeProtocols"), "NativeProtocols");
+#endif
}
return name;
@@ -822,90 +825,13 @@ public static string GetProtocolWarning(this SslProtocols protocol)
#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
#endif
{
+#if !NETFRAMEWORK
message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
- }
- return message;
- }
#else
- // protocol versions from native sni
- [Flags]
- private enum NativeProtocols
- {
- SP_PROT_SSL2_SERVER = 0x00000004,
- SP_PROT_SSL2_CLIENT = 0x00000008,
- SP_PROT_SSL3_SERVER = 0x00000010,
- SP_PROT_SSL3_CLIENT = 0x00000020,
- SP_PROT_TLS1_0_SERVER = 0x00000040,
- SP_PROT_TLS1_0_CLIENT = 0x00000080,
- SP_PROT_TLS1_1_SERVER = 0x00000100,
- SP_PROT_TLS1_1_CLIENT = 0x00000200,
- SP_PROT_TLS1_2_SERVER = 0x00000400,
- SP_PROT_TLS1_2_CLIENT = 0x00000800,
- SP_PROT_TLS1_3_SERVER = 0x00001000,
- SP_PROT_TLS1_3_CLIENT = 0x00002000,
- SP_PROT_SSL2 = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT,
- SP_PROT_SSL3 = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT,
- SP_PROT_TLS1_0 = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT,
- SP_PROT_TLS1_1 = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT,
- SP_PROT_TLS1_2 = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT,
- SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
- SP_PROT_NONE = 0x0
- }
-
- private static string ToFriendlyName(this NativeProtocols protocol)
- {
- string name;
-
- if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
- {
- name = "TLS 1.3";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
- {
- name = "TLS 1.2";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_SERVER))
- {
- name = "TLS 1.1";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_SERVER))
- {
- name = "TLS 1.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
- {
- name = "SSL 3.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || protocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
- {
- name = "SSL 2.0";
- }
- else if (protocol.HasFlag(NativeProtocols.SP_PROT_NONE))
- {
- name = "None";
- }
- else
- {
- throw new ArgumentException(StringsHelper.GetString(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
- }
- return name;
- }
-
- ///
- /// check the negotiated secure protocol if it's under TLS 1.2
- ///
- ///
- /// Localized warning message
- public static string GetProtocolWarning(uint protocol)
- {
- var nativeProtocol = (NativeProtocols)protocol;
- string message = string.Empty;
- if ((nativeProtocol & (NativeProtocols.SP_PROT_SSL2 | NativeProtocols.SP_PROT_SSL3 | NativeProtocols.SP_PROT_TLS1_1)) != NativeProtocols.SP_PROT_NONE)
- {
- message = StringsHelper.GetString(Strings.SEC_ProtocolWarning, nativeProtocol.ToFriendlyName());
+ message = StringsHelper.GetString(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
+#endif
}
return message;
}
-#endif
}
}