From e14a5c8fe67719315694ee0b8d355734fe587ef0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 8 Jun 2020 16:23:33 +0200 Subject: [PATCH] address a few TODOs --- csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs | 9 ++++++++- csharp/src/Google.Protobuf/MessageExtensions.cs | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs b/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs index 5ed60918ba..fb83ff4e73 100644 --- a/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs +++ b/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs @@ -121,7 +121,14 @@ namespace Google.Protobuf message.WriteTo(singleSpan); Assert.AreEqual(bytes, singleSpan.ToArray()); - // TODO: also test different chunk sizes for IBufferWriter + // test for different IBufferWriter.GetSpan() segment sizes + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + var segmentedBufferWriter = new ArrayBufferWriter(); + segmentedBufferWriter.MaxGrowBy = blockSize; + message.WriteTo(segmentedBufferWriter); + Assert.AreEqual(bytes, bufferWriter.WrittenSpan.ToArray()); + } } } } \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs index 98d0f64c9f..36a9df7286 100644 --- a/csharp/src/Google.Protobuf/MessageExtensions.cs +++ b/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -160,8 +160,6 @@ namespace Google.Protobuf WriteContext.Initialize(output, out WriteContext ctx); WritingPrimitivesMessages.WriteRawMessage(ref ctx, message); ctx.Flush(); - - // TODO: handling errors when IBufferWriter is used? } ///