Skip to content

Commit e316a68

Browse files
authored
Merge common code bases for TdsParserStateObject.cs (#1520)
1 parent 1bb1890 commit e316a68

File tree

7 files changed

+1238
-2188
lines changed

7 files changed

+1238
-2188
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@
466466
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParameterSetter.cs">
467467
<Link>Microsoft\Data\SqlClient\TdsParameterSetter.cs</Link>
468468
</Compile>
469+
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParserStateObject.cs">
470+
<Link>Microsoft\Data\SqlClient\TdsParserStateObject.cs</Link>
471+
</Compile>
469472
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParserStaticMethods.cs">
470473
<Link>Microsoft\Data\SqlClient\TdsParserStaticMethods.cs</Link>
471474
</Compile>

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

+14-12
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ internal EncryptionOptions EncryptionOptions
259259
}
260260
}
261261

262+
internal bool Is2005OrNewer => true;
263+
262264
internal bool Is2008OrNewer
263265
{
264266
get
@@ -1327,7 +1329,7 @@ internal void ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool calle
13271329
// report exception to pending async operation
13281330
// before OnConnectionClosed overrides the exception
13291331
// due to connection close notification through references
1330-
var taskSource = stateObj._networkPacketTaskSource;
1332+
TaskCompletionSource<object> taskSource = stateObj._networkPacketTaskSource;
13311333
if (taskSource != null)
13321334
{
13331335
taskSource.TrySetException(ADP.ExceptionWithStackTrace(exception));
@@ -1337,7 +1339,7 @@ internal void ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool calle
13371339
if (asyncClose)
13381340
{
13391341
// Wait until we have the parser lock, then try to close
1340-
var connHandler = _connHandler;
1342+
SqlInternalConnectionTds connHandler = _connHandler;
13411343
Action<Action> wrapCloseAction = closeAction =>
13421344
{
13431345
Task.Factory.StartNew(() =>
@@ -2607,7 +2609,7 @@ private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj,
26072609

26082610
while (tokenLength > processedLength)
26092611
{
2610-
var env = new SqlEnvChange();
2612+
SqlEnvChange env = new SqlEnvChange();
26112613
if (!stateObj.TryReadByte(out env._type))
26122614
{
26132615
return false;
@@ -3370,7 +3372,7 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
33703372
{
33713373
return false;
33723374
}
3373-
var labels = new List<Label>(numLabels);
3375+
List<Label> labels = new List<Label>(numLabels);
33743376
for (ushort i = 0; i < numLabels; i++)
33753377
{
33763378
if (!TryReadSensitivityLabel(stateObj, out string label, out string id))
@@ -3385,7 +3387,7 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
33853387
{
33863388
return false;
33873389
}
3388-
var informationTypes = new List<InformationType>(numInformationTypes);
3390+
List<InformationType> informationTypes = new List<InformationType>(numInformationTypes);
33893391
for (ushort i = 0; i < numInformationTypes; i++)
33903392
{
33913393
if (!TryReadSensitivityInformationType(stateObj, out string informationType, out string id))
@@ -3410,15 +3412,15 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
34103412
{
34113413
return false;
34123414
}
3413-
var columnSensitivities = new List<ColumnSensitivity>(numResultColumns);
3415+
List<ColumnSensitivity> columnSensitivities = new List<ColumnSensitivity>(numResultColumns);
34143416
for (ushort columnNum = 0; columnNum < numResultColumns; columnNum++)
34153417
{
34163418
// get sensitivity properties for all the different sources which were used in generating the column output
34173419
if (!stateObj.TryReadUInt16(out ushort numSources))
34183420
{
34193421
return false;
34203422
}
3421-
var sensitivityProperties = new List<SensitivityProperty>(numSources);
3423+
List<SensitivityProperty> sensitivityProperties = new List<SensitivityProperty>(numSources);
34223424
for (ushort sourceNum = 0; sourceNum < numSources; sourceNum++)
34233425
{
34243426
// get the label index and then lookup label to use for source
@@ -4429,7 +4431,7 @@ internal void DrainData(TdsParserStateObject stateObj)
44294431
SqlDataReader.SharedState sharedState = stateObj._readerState;
44304432
if (sharedState != null && sharedState._dataReady)
44314433
{
4432-
var metadata = stateObj._cleanupMetaData;
4434+
_SqlMetaDataSet metadata = stateObj._cleanupMetaData;
44334435
if (stateObj._partialHeaderBytesRead > 0)
44344436
{
44354437
if (!stateObj.TryProcessHeader())
@@ -7473,12 +7475,12 @@ private Task WriteEncodingChar(string s, int numChars, int offset, Encoding enco
74737475
else
74747476
{
74757477
#if NETFRAMEWORK || NETSTANDARD2_0
7476-
var charData = s.ToCharArray(offset, numChars);
7477-
var byteData = encoding.GetBytes(charData, 0, numChars);
7478+
char[] charData = s.ToCharArray(offset, numChars);
7479+
byte[] byteData = encoding.GetBytes(charData, 0, numChars);
74787480
Debug.Assert(byteData != null, "no data from encoding");
74797481
return stateObj.WriteByteArray(byteData, byteData.Length, 0, canAccumulate);
74807482
#else
7481-
var byteData = encoding.GetBytes(s, offset, numChars);
7483+
byte[] byteData = encoding.GetBytes(s, offset, numChars);
74827484
Debug.Assert(byteData != null, "no data from encoding");
74837485
return stateObj.WriteByteArray(byteData, byteData.Length, 0, canAccumulate);
74847486
#endif
@@ -9854,7 +9856,7 @@ private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefa
98549856

98559857
if (advancedTraceIsOn)
98569858
{
9857-
var sendDefaultValue = sendDefault ? 1 : 0;
9859+
int sendDefaultValue = sendDefault ? 1 : 0;
98589860
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.TdsParser.WriteSmiParameter|ADV> {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3));
98599861
}
98609862

0 commit comments

Comments
 (0)