Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge common code bases for TdsParserStateObject.cs #1520

Merged
merged 20 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
22c25f5
Merging common fields, properties and types of TdsParserStateObject.
panoskj Feb 21, 2022
4ec17f6
Merging common type NullBitmap of TdsParserStateObject.
panoskj Feb 21, 2022
de83b8d
Merging a few methods of TdsParserStateObject.
panoskj Feb 21, 2022
d15a7d3
Merging constructor of TdsParserStateObject.
panoskj Feb 21, 2022
927e4a6
Merging some methods of TdsParserStateObject.
panoskj Feb 21, 2022
2c81d54
Merging ObjectID property of TdsParserStateObject.
panoskj Feb 21, 2022
72d8e54
Merge remote-tracking branch 'upstream/main' into MergeTdsParserState…
DavoudEshtehari Mar 15, 2022
417a6da
Merging some methods of TdsParserStateObject (note: ports part of #10…
panoskj Mar 18, 2022
b8eb31d
Merging some methods of TdsParserStateObject (note: uses some #if dir…
panoskj Mar 18, 2022
c145b8d
Merge branch 'main' into MergeTdsParserStateObject
panoskj Aug 26, 2022
ed279eb
Merge branch 'main' into MergeTdsParserStateObject
panoskj Oct 5, 2022
4e6ed9a
TdsParserStateObject: Fixed naming rules violations.
panoskj Oct 5, 2022
315acb1
TdsParserStateObject: Removed unnecessary assignments. Used discard t…
panoskj Oct 5, 2022
87f0cba
TdsParserStateObject: Simplified names.
panoskj Oct 5, 2022
d71028b
TdsParserStateObject: Simplified default expression.
panoskj Oct 5, 2022
3e05aeb
TdsParserStateObject: Removed unnecessary casts.
panoskj Oct 5, 2022
58ae136
TdsParserStateObject: Replaced var usages with explicit types.
panoskj Oct 5, 2022
5eb4a61
Apply suggestions from code review
DavoudEshtehari Nov 8, 2022
f75d911
Merge remote-tracking branch 'upstream/main' into MergeTdsParserState…
DavoudEshtehari Nov 8, 2022
0b4c345
Address comments
DavoudEshtehari Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParameterSetter.cs">
<Link>Microsoft\Data\SqlClient\TdsParameterSetter.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParserStateObject.cs">
<Link>Microsoft\Data\SqlClient\TdsParserStateObject.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParserStaticMethods.cs">
<Link>Microsoft\Data\SqlClient\TdsParserStaticMethods.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ internal EncryptionOptions EncryptionOptions
}
}

internal bool Is2005OrNewer => true;

internal bool Is2008OrNewer
{
get
Expand Down Expand Up @@ -1327,7 +1329,7 @@ internal void ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool calle
// report exception to pending async operation
// before OnConnectionClosed overrides the exception
// due to connection close notification through references
var taskSource = stateObj._networkPacketTaskSource;
TaskCompletionSource<object> taskSource = stateObj._networkPacketTaskSource;
if (taskSource != null)
{
taskSource.TrySetException(ADP.ExceptionWithStackTrace(exception));
Expand All @@ -1337,7 +1339,7 @@ internal void ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool calle
if (asyncClose)
{
// Wait until we have the parser lock, then try to close
var connHandler = _connHandler;
SqlInternalConnectionTds connHandler = _connHandler;
Action<Action> wrapCloseAction = closeAction =>
{
Task.Factory.StartNew(() =>
Expand Down Expand Up @@ -2607,7 +2609,7 @@ private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj,

while (tokenLength > processedLength)
{
var env = new SqlEnvChange();
SqlEnvChange env = new SqlEnvChange();
if (!stateObj.TryReadByte(out env._type))
{
return false;
Expand Down Expand Up @@ -3370,7 +3372,7 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
{
return false;
}
var labels = new List<Label>(numLabels);
List<Label> labels = new List<Label>(numLabels);
for (ushort i = 0; i < numLabels; i++)
{
if (!TryReadSensitivityLabel(stateObj, out string label, out string id))
Expand All @@ -3385,7 +3387,7 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
{
return false;
}
var informationTypes = new List<InformationType>(numInformationTypes);
List<InformationType> informationTypes = new List<InformationType>(numInformationTypes);
for (ushort i = 0; i < numInformationTypes; i++)
{
if (!TryReadSensitivityInformationType(stateObj, out string informationType, out string id))
Expand All @@ -3410,15 +3412,15 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
{
return false;
}
var columnSensitivities = new List<ColumnSensitivity>(numResultColumns);
List<ColumnSensitivity> columnSensitivities = new List<ColumnSensitivity>(numResultColumns);
for (ushort columnNum = 0; columnNum < numResultColumns; columnNum++)
{
// get sensitivity properties for all the different sources which were used in generating the column output
if (!stateObj.TryReadUInt16(out ushort numSources))
{
return false;
}
var sensitivityProperties = new List<SensitivityProperty>(numSources);
List<SensitivityProperty> sensitivityProperties = new List<SensitivityProperty>(numSources);
for (ushort sourceNum = 0; sourceNum < numSources; sourceNum++)
{
// get the label index and then lookup label to use for source
Expand Down Expand Up @@ -4429,7 +4431,7 @@ internal void DrainData(TdsParserStateObject stateObj)
SqlDataReader.SharedState sharedState = stateObj._readerState;
if (sharedState != null && sharedState._dataReady)
{
var metadata = stateObj._cleanupMetaData;
_SqlMetaDataSet metadata = stateObj._cleanupMetaData;
if (stateObj._partialHeaderBytesRead > 0)
{
if (!stateObj.TryProcessHeader())
Expand Down Expand Up @@ -7473,12 +7475,12 @@ private Task WriteEncodingChar(string s, int numChars, int offset, Encoding enco
else
{
#if NETFRAMEWORK || NETSTANDARD2_0
var charData = s.ToCharArray(offset, numChars);
var byteData = encoding.GetBytes(charData, 0, numChars);
char[] charData = s.ToCharArray(offset, numChars);
byte[] byteData = encoding.GetBytes(charData, 0, numChars);
Debug.Assert(byteData != null, "no data from encoding");
return stateObj.WriteByteArray(byteData, byteData.Length, 0, canAccumulate);
#else
var byteData = encoding.GetBytes(s, offset, numChars);
byte[] byteData = encoding.GetBytes(s, offset, numChars);
Debug.Assert(byteData != null, "no data from encoding");
return stateObj.WriteByteArray(byteData, byteData.Length, 0, canAccumulate);
#endif
Expand Down Expand Up @@ -9854,7 +9856,7 @@ private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefa

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

Expand Down
Loading