@@ -61,7 +61,7 @@ public AggregateEnumerator(scoped in RespReader reader)
6161 /// </summary>
6262 public bool MoveNext ( RespPrefix prefix )
6363 {
64- bool result = MoveNext ( ) ;
64+ bool result = MoveNextRaw ( ) ;
6565 if ( result )
6666 {
6767 Value . MoveNext ( prefix ) ;
@@ -75,24 +75,46 @@ public bool MoveNext(RespPrefix prefix)
7575 /// <typeparam name="T">The type of data represented by this reader.</typeparam>
7676 public bool MoveNext < T > ( RespPrefix prefix , RespAttributeReader < T > respAttributeReader , ref T attributes )
7777 {
78- bool result = MoveNext ( respAttributeReader , ref attributes ) ;
78+ bool result = MoveNextRaw ( respAttributeReader , ref attributes ) ;
7979 if ( result )
8080 {
8181 Value . MoveNext ( prefix ) ;
8282 }
8383 return result ;
8484 }
8585
86- /// <inheritdoc cref="IEnumerator.MoveNext()"/>>
87- public bool MoveNext ( )
86+ /// <summary>
87+ /// Move to the next child and leave the reader *ahead of* the first element,
88+ /// allowing us to read attribute data.
89+ /// </summary>
90+ /// <remarks>If you are not consuming attribute data, <see cref="MoveNext()"/> is preferred.</remarks>
91+ public bool MoveNextRaw ( )
8892 {
8993 object ? attributes = null ;
9094 return MoveNextCore ( null , ref attributes ) ;
9195 }
9296
93- /// <inheritdoc cref="IEnumerator.MoveNext()"/>>
94- /// <typeparam name="T">The type of data represented by this reader.</typeparam>
95- public bool MoveNext < T > ( RespAttributeReader < T > respAttributeReader , ref T attributes )
97+ /// <summary>
98+ /// Move to the next child and move into the first element (skipping attributes etc), leaving it ready to consume.
99+ /// </summary>
100+ public bool MoveNext ( )
101+ {
102+ object ? attributes = null ;
103+ if ( MoveNextCore ( null , ref attributes ) )
104+ {
105+ Value . MoveNext ( ) ;
106+ return true ;
107+ }
108+ return false ;
109+ }
110+
111+ /// <summary>
112+ /// Move to the next child (capturing attribute data) and leave the reader *ahead of* the first element,
113+ /// allowing us to also read attribute data of the child.
114+ /// </summary>
115+ /// <typeparam name="T">The type of attribute data represented by this reader.</typeparam>
116+ /// <remarks>If you are not consuming attribute data, <see cref="MoveNext()"/> is preferred.</remarks>
117+ public bool MoveNextRaw < T > ( RespAttributeReader < T > respAttributeReader , ref T attributes )
96118 => MoveNextCore < T > ( respAttributeReader , ref attributes ) ;
97119
98120 /// <inheritdoc cref="IEnumerator.MoveNext()"/>>
@@ -146,14 +168,16 @@ private bool MoveNextCore<T>(RespAttributeReader<T>? attributeReader, ref T attr
146168 /// used to update a tree reader, to get to the next data after the aggregate.</param>
147169 public void MovePast ( out RespReader reader )
148170 {
149- while ( MoveNext ( ) ) { }
171+ while ( MoveNextRaw ( ) ) { }
150172 reader = _reader ;
151173 }
152174
175+ /// <summary>
176+ /// Moves to the next element, and moves into that element (skipping attributes etc), leaving it ready to consume.
177+ /// </summary>
153178 public void DemandNext ( )
154179 {
155180 if ( ! MoveNext ( ) ) ThrowEof ( ) ;
156- Value . MoveNext ( ) ; // skip any attributes etc
157181 }
158182
159183 public T ReadOne < T > ( Projection < T > projection )
@@ -166,9 +190,7 @@ public void FillAll<T>(scoped Span<T> target, Projection<T> projection)
166190 {
167191 for ( int i = 0 ; i < target . Length ; i ++ )
168192 {
169- if ( ! MoveNext ( ) ) ThrowEof ( ) ;
170-
171- Value . MoveNext ( ) ; // skip any attributes etc
193+ DemandNext ( ) ;
172194 target [ i ] = projection ( ref Value ) ;
173195 }
174196 }
@@ -181,14 +203,12 @@ public void FillAll<TFirst, TSecond, TResult>(
181203 {
182204 for ( int i = 0 ; i < target . Length ; i ++ )
183205 {
184- if ( ! MoveNext ( ) ) ThrowEof ( ) ;
206+ DemandNext ( ) ;
185207
186- Value . MoveNext ( ) ; // skip any attributes etc
187208 var x = first ( ref Value ) ;
188209
189- if ( ! MoveNext ( ) ) ThrowEof ( ) ;
210+ DemandNext ( ) ;
190211
191- Value . MoveNext ( ) ; // skip any attributes etc
192212 var y = second ( ref Value ) ;
193213 target [ i ] = combine ( x , y ) ;
194214 }
0 commit comments