File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Dahomey.Cbor/Serialization/Converters Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -142,5 +142,15 @@ public void WriteArray()
142142 } ;
143143 Helper . TestWrite ( array , hexBuffer ) ;
144144 }
145+
146+ [ Fact ]
147+ public void WriteEmptyArray ( )
148+ {
149+ const string hexBuffer = "80" ;
150+
151+ CborArray array = new CborArray ( ) ;
152+
153+ Helper . TestWrite ( array , hexBuffer ) ;
154+ }
145155 }
146156}
Original file line number Diff line number Diff line change @@ -191,8 +191,13 @@ int ICborArrayWriter<ArrayWriterContext>.GetArraySize(ref ArrayWriterContext con
191191
192192 bool ICborArrayWriter < ArrayWriterContext > . WriteArrayItem ( ref CborWriter writer , ref ArrayWriterContext context )
193193 {
194- Write ( ref writer , context . array [ context . index ++ ] ) ;
195- return context . index < context . array . Count ;
194+ if ( context . array . Count > 0 )
195+ {
196+ Write ( ref writer , context . array [ context . index ++ ] ) ;
197+ return context . index < context . array . Count ;
198+ }
199+
200+ return false ;
196201 }
197202
198203 CborObject ? ICborConverter < CborObject ? > . Read ( ref CborReader reader )
You can’t perform that action at this time.
0 commit comments