TdsParserStateObject methods should be clear about their target
- Dominant language
- C#
- Stars
- 989
- Forks
- 340
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 72
Description
Reading though `ReadSniError` there is code like this:
```csharp
private void ReadSniError(TdsParserStateObject stateObj, uint error)
{
if (TdsEnums.SNI_WAIT_TIMEOUT == error)
{
...
if (IsTimeoutStateExpired)
{ // This is now our second timeout - time to give up.
fail = true;
}
else
{
stateObj.SetTimeoutStateStopped();
Debug.Assert(_parser.Connection != null, "SqlConnectionInternalTds handler can not be null at this point.");
AddError(new SqlError(TdsEnums.TIMEOUT_EXPIRED, (byte)0x00, TdsEnums.MIN_ERROR_CLASS, _parser.Server, _parser.Connection.TimeoutErrorInternal.GetErrorMessage(), "", 0, TdsEnums.SNI_WAIT_TIMEOUT));
```
where the IsTimeoutStateExpired is called on the `this` reference but the timeout is stopped on stateObj parameter. Similarly _parser is called on `this' not the state object parameter. The function should either be static and always call methods on the parameter passed in or it should be instance and not require the stateObj parameter.
Any other methods on TdsParserStateObject should be identified and changed inthe same way so that it is clear which stateObject they are operating on. The equivalence of this == stateObj is never checked only assumed.
Contributor guide
Assessment
This issue has not been assessed yet.