Skip to content

Commit ca1a943

Browse files
authored
Align comments between netfx and netcore codebases (#2966)
1 parent 58c1347 commit ca1a943

File tree

2 files changed

+18
-56
lines changed

2 files changed

+18
-56
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections;
77
using System.Collections.ObjectModel;
8+
using System.ComponentModel;
89
using System.Data;
910
using System.Data.Common;
1011
using System.Data.SqlTypes;
@@ -917,7 +918,7 @@ public override void Close()
917918
{
918919
if (_stateObj != null)
919920
{ // reader not closed while we waited for the lock
920-
// TryCloseInternal will clear out the snapshot when it is done
921+
// TryCloseInternal will clear out the snapshot when it is done
921922
if (_snapshot != null)
922923
{
923924
#if DEBUG
@@ -2045,6 +2046,7 @@ override public TextReader GetTextReader(int i)
20452046
}
20462047

20472048
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetChar/*' />
2049+
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
20482050
override public char GetChar(int i)
20492051
{
20502052
throw ADP.NotSupported();
@@ -3020,7 +3022,7 @@ private T GetFieldValueFromSqlBufferInternal<T>(SqlBuffer data, _SqlMetaData met
30203022
// Stream is only for Binary, Image, VarBinary, Udt, Xml and Timestamp(RowVersion) types
30213023
MetaType metaType = metaData.metaType;
30223024
if (
3023-
(!metaType.IsBinType || metaType.SqlDbType == SqlDbType.Timestamp) &&
3025+
(!metaType.IsBinType || metaType.SqlDbType == SqlDbType.Timestamp) &&
30243026
metaType.SqlDbType != SqlDbType.Variant
30253027
)
30263028
{
@@ -4360,7 +4362,7 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn
43604362
// simply rip the order token off the wire
43614363
if (b == TdsEnums.SQLORDER)
43624364
{
4363-
// same logic as SetAltMetaDataSet
4365+
// same logic as SetAltMetaDataSet
43644366
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out _);
43654367
if (result != TdsOperationStatus.Done)
43664368
{
@@ -5381,7 +5383,7 @@ internal void CompletePendingReadWithFailure(int errorCode, bool resetForcePendi
53815383
}
53825384

53835385
#endif
5384-
5386+
53855387
internal abstract class SqlDataReaderBaseAsyncCallContext<T> : AAsyncBaseCallContext<SqlDataReader, T>
53865388
{
53875389
internal static readonly Action<Task<T>, object> s_completeCallback = CompleteAsyncCallCallback;

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ internal class SharedState
7676
private static int s_objectTypeCount; // EventSource Counter
7777
internal readonly int ObjectID = Interlocked.Increment(ref s_objectTypeCount);
7878

79-
// context
80-
// undone: we may still want to do this...it's nice to pass in an lpvoid (essentially) and just have the reader keep the state
81-
// private object _context = null; // this is never looked at by the stream object. It is used by upper layers who wish
82-
// to remain stateless
8379

8480
// metadata (no explicit table, use 'Table')
8581
private MultiPartTableName[] _tableNames = null;
@@ -353,7 +349,7 @@ internal virtual SmiExtendedMetaData[] GetInternalSmiMetaData()
353349
}
354350
else if (SqlDbType.Udt == colMetaData.type)
355351
{
356-
Connection.CheckGetExtendedUDTInfo(colMetaData, true); // SQLBUDT #370593 ensure that colMetaData.udtType is set
352+
Connection.CheckGetExtendedUDTInfo(colMetaData, true); // Ensure that colMetaData.udtType is set
357353

358354
typeSpecificNamePart1 = colMetaData.udt?.DatabaseName;
359355
typeSpecificNamePart2 = colMetaData.udt?.SchemaName;
@@ -500,9 +496,6 @@ internal void Bind(TdsParserStateObject stateObj)
500496
_defaultLCID = _parser.DefaultLCID;
501497
}
502498

503-
// Fills in a schema table with meta data information. This function should only really be called by
504-
// UNDONE: need a way to refresh the table with more information as more data comes online for browse info like
505-
// table names and key information
506499
#if !NETFRAMEWORK
507500
[SuppressMessage("ReflectionAnalysis", "IL2111",
508501
Justification = "System.Type.TypeInitializer would not be used in dataType and providerSpecificDataType columns.")]
@@ -1193,7 +1186,7 @@ private TdsOperationStatus TryCloseInternal(bool closeReader)
11931186
CleanupAfterAsyncInvocationInternal(stateObj);
11941187
}
11951188

1196-
// SQLBUDT #284712 - Note the order here is extremely important:
1189+
// Note the order here is extremely important:
11971190
//
11981191
// (1) First, we remove the reader from the reference collection
11991192
// to prevent it from being forced closed by the parser if
@@ -1271,6 +1264,7 @@ private TdsOperationStatus TryCloseInternal(bool closeReader)
12711264
}
12721265
throw;
12731266
}
1267+
// DO NOT USE stateObj after this point - it has been returned to the TdsParser's session pool and potentially handed out to another thread
12741268

12751269
// do not retry here
12761270
result = TrySetMetaData(null, false);
@@ -1657,7 +1651,7 @@ override public int GetOrdinal(string name)
16571651
CheckMetaDataIsReady();
16581652
_fieldNameLookup = new FieldNameLookup(this, _defaultLCID);
16591653
}
1660-
return _fieldNameLookup.GetOrdinal(name); // MDAC 71470
1654+
return _fieldNameLookup.GetOrdinal(name);
16611655
}
16621656
finally
16631657
{
@@ -2344,7 +2338,7 @@ override public TextReader GetTextReader(int i)
23442338
}
23452339

23462340
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetChar/*' />
2347-
[EditorBrowsableAttribute(EditorBrowsableState.Never)] // MDAC 69508
2341+
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
23482342
override public char GetChar(int i)
23492343
{
23502344
throw ADP.NotSupported();
@@ -2423,7 +2417,6 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
24232417
}
24242418
catch (Exception ex)
24252419
{
2426-
// Dev11 Bug #315513: Exception type breaking change from 4.0 RTM when calling GetChars on null xml
24272420
// We need to wrap all exceptions inside a TargetInvocationException to simulate calling CreateSqlReader via MethodInfo.Invoke
24282421
if (ADP.IsCatchableExceptionType(ex))
24292422
{
@@ -2504,7 +2497,6 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn
25042497
}
25052498
catch (Exception e)
25062499
{
2507-
// UNDONE - should not be catching all exceptions!!!
25082500
if (!ADP.IsCatchableExceptionType(e))
25092501
{
25102502
throw;
@@ -2895,7 +2887,6 @@ virtual public SqlSingle GetSqlSingle(int i)
28952887
}
28962888

28972889
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetSqlString/*' />
2898-
// UNDONE: need non-unicode SqlString support
28992890
virtual public SqlString GetSqlString(int i)
29002891
{
29012892
ReadColumn(i);
@@ -2985,8 +2976,6 @@ private object GetSqlValueInternal(int i)
29852976
// Always make sure to take reference copies of anything set to null in TryCloseInternal()
29862977
private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaData)
29872978
{
2988-
// Dev11 Bug #336820, Dev10 Bug #479607 (SqlClient: IsDBNull always returns false for timestamp datatype)
2989-
// Due to a bug in TdsParser.GetNullSqlValue, Timestamps' IsNull is not correctly set - so we need to bypass the following check
29902979
Debug.Assert(!data.IsEmpty || data.IsNull || metaData.type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
29912980

29922981
// Convert 2008 types to string
@@ -3177,8 +3166,6 @@ private object GetValueInternal(int i)
31773166
// Always make sure to take reference copies of anything set to null in TryCloseInternal()
31783167
private object GetValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData metaData)
31793168
{
3180-
// Dev11 Bug #336820, Dev10 Bug #479607 (SqlClient: IsDBNull always returns false for timestamp datatype)
3181-
// Due to a bug in TdsParser.GetNullSqlValue, Timestamps' IsNull is not correctly set - so we need to bypass the following check
31823169
Debug.Assert(!data.IsEmpty || data.IsNull || metaData.type == SqlDbType.Timestamp, "Data has been read, but the buffer is empty");
31833170

31843171
if (_typeSystem <= SqlConnectionString.TypeSystem.SQLServer2005 && metaData.Is2008DateTimeType)
@@ -3503,7 +3490,7 @@ override public int GetValues(object[] values)
35033490
_data[i].Clear();
35043491
if (fieldIndex > i && fieldIndex > 0)
35053492
{
3506-
// if we jumped an index forward because of a hidden column see if the buffer before the
3493+
// if we jumped an index forward because of a hidden column see if the buffer before the
35073494
// current one was populated by the seek forward and clear it if it was
35083495
_data[fieldIndex - 1].Clear();
35093496
}
@@ -3595,10 +3582,6 @@ private TdsOperationStatus TryHasMoreResults(out bool moreResults)
35953582
// always happens if there is a row following an altrow
35963583
moreResults = true;
35973584
return TdsOperationStatus.Done;
3598-
3599-
// VSTFDEVDIV 926281: DONEINPROC case is missing here; we have decided to reject this bug as it would result in breaking change
3600-
// from VS2008 RTM/SP1 and Dev10 RTM. See the bug for more details.
3601-
// case TdsEnums.DONEINPROC:
36023585
case TdsEnums.SQLDONE:
36033586
Debug.Assert(_altRowStatus == ALTROWSTATUS.Done || _altRowStatus == ALTROWSTATUS.Null, "invalid AltRowStatus");
36043587
_altRowStatus = ALTROWSTATUS.Null;
@@ -3628,8 +3611,6 @@ private TdsOperationStatus TryHasMoreResults(out bool moreResults)
36283611
return TdsOperationStatus.Done;
36293612
}
36303613

3631-
// Dev11 Bug 316483: Stuck at SqlDataReader::TryHasMoreResults using MARS
3632-
// http://vstfdevdiv:8080/web/wi.aspx?pcguid=22f9acc9-569a-41ff-b6ac-fac1b6370209&id=316483
36333614
// TryRun() will immediately return if the TdsParser is closed/broken, causing us to enter an infinite loop
36343615
// Instead, we will throw a closed connection exception
36353616
if (_parser.State == TdsParserState.Broken || _parser.State == TdsParserState.Closed)
@@ -3674,19 +3655,6 @@ private TdsOperationStatus TryHasMoreRows(out bool moreRows)
36743655
if (_stateObj.HasPendingData)
36753656
{
36763657
// Consume error's, info's, done's on HasMoreRows, so user obtains error on Read.
3677-
// Previous bug where Read() would return false with error on the wire in the case
3678-
// of metadata and error immediately following. See MDAC 78285 and 75225.
3679-
3680-
// BUGBUG - currently in V1 the if (_parser.PendingData) does not
3681-
// exist, so under certain conditions HasMoreRows can timeout. However,
3682-
// this should only occur when executing as SqlBatch and returning a reader.
3683-
// Updated - SQL Bug: 20001249
3684-
// Modifed while loop and added parsedDoneToken, to revert a regression from everettfs.
3685-
// "Error Exceptions" are now only thown in read when a error occures in the exception, otherwise the exception will be thrown on the call to get the next result set.
3686-
// resultset.
3687-
3688-
// process any done, doneproc and doneinproc token streams and
3689-
// any order, error or info token preceeding the first done, doneproc or doneinproc token stream
36903658
byte b;
36913659
TdsOperationStatus result = _stateObj.TryPeekByte(out b);
36923660
if (result != TdsOperationStatus.Done)
@@ -3713,8 +3681,6 @@ private TdsOperationStatus TryHasMoreRows(out bool moreRows)
37133681
ParsedDoneToken = true;
37143682
}
37153683

3716-
// Dev11 Bug 316483: Stuck at SqlDataReader::TryHasMoreResults when using MARS
3717-
// http://vstfdevdiv:8080/web/wi.aspx?pcguid=22f9acc9-569a-41ff-b6ac-fac1b6370209&id=316483
37183684
// TryRun() will immediately return if the TdsParser is closed/broken, causing us to enter an infinite loop
37193685
// Instead, we will throw a closed connection exception
37203686
if (_parser.State == TdsParserState.Broken || _parser.State == TdsParserState.Closed)
@@ -4895,25 +4861,19 @@ internal TdsOperationStatus TrySetMetaData(_SqlMetaDataSet metaData, bool moreIn
48954861

48964862
if (_parser != null)
48974863
{ // There is a valid case where parser is null
4898-
// Peek, and if row token present, set _hasRows true since there is a
4899-
// row in the result
4864+
// Peek, and if row token present, set _hasRows true since there is a
4865+
// row in the result
49004866
byte b;
49014867
TdsOperationStatus result = _stateObj.TryPeekByte(out b);
49024868
if (result != TdsOperationStatus.Done)
49034869
{
49044870
return result;
49054871
}
49064872

4907-
// UNDONE - should we be consuming tokens here??? Maybe we should be calling HasMoreRows?
4908-
// Would that have other side effects?
4909-
49104873
// simply rip the order token off the wire
49114874
if (b == TdsEnums.SQLORDER)
4912-
{
4875+
{
49134876
// same logic as SetAltMetaDataSet
4914-
// Devnote: That's not the right place to process TDS
4915-
// Can this result in Reentrance to Run?
4916-
49174877
result = _parser.TryRun(RunBehavior.ReturnImmediately, null, null, null, _stateObj, out _);
49184878
if (result != TdsOperationStatus.Done)
49194879
{
@@ -5151,7 +5111,7 @@ private static Task<bool> NextResultAsyncExecute(Task task, object state)
51515111

51525112
if (context.Reader.TryNextResult(out bool more) == TdsOperationStatus.Done)
51535113
{
5154-
// completed
5114+
// completed
51555115
return more ? ADP.TrueTask : ADP.FalseTask;
51565116
}
51575117

@@ -5573,7 +5533,7 @@ private static Task<bool> ReadAsyncExecute(Task task, object state)
55735533
// If there are no more rows, or this is Sequential Access, then we are done
55745534
if (!hasMoreData || (reader._commandBehavior & CommandBehavior.SequentialAccess) == CommandBehavior.SequentialAccess)
55755535
{
5576-
// completed
5536+
// completed
55775537
return hasMoreData ? ADP.TrueTask : ADP.FalseTask;
55785538
}
55795539
else
@@ -5590,7 +5550,7 @@ private static Task<bool> ReadAsyncExecute(Task task, object state)
55905550
TdsOperationStatus result = reader.TryReadColumn(reader._metaData.Length - 1, true);
55915551
if (result == TdsOperationStatus.Done)
55925552
{
5593-
// completed
5553+
// completed
55945554
return ADP.TrueTask;
55955555
}
55965556
}

0 commit comments

Comments
 (0)