fix a bunch of bugs

pull/7576/head
Jan Tattermusch 5 years ago
parent d0e08f546d
commit 5fc49bdd5a
  1. 2
      csharp/src/Google.Protobuf/CodedOutputStream.cs
  2. 2
      csharp/src/Google.Protobuf/WriteBufferHelper.cs
  3. 14
      csharp/src/Google.Protobuf/WritingPrimitivesMessages.cs

@ -33,6 +33,7 @@
using Google.Protobuf.Collections;
using System;
using System.IO;
using System.Security;
using System.Text;
namespace Google.Protobuf
@ -304,7 +305,6 @@ namespace Google.Protobuf
public void WriteBytes(ByteString value)
{
var span = new Span<byte>(buffer);
WritingPrimitives.WriteLength(ref span, ref state, value.Length);
WritingPrimitives.WriteBytes(ref span, ref state, value);
}

@ -47,7 +47,7 @@ namespace Google.Protobuf
private IBufferWriter<byte> bufferWriter;
private CodedOutputStream codedOutputStream;
public CodedOutputStream CodedOutputStream => CodedOutputStream;
public CodedOutputStream CodedOutputStream => codedOutputStream;
/// <summary>
/// Initialize an instance with a coded output stream.

@ -67,8 +67,20 @@ namespace Google.Protobuf
{
if (message is IBufferMessage bufferMessage)
{
// TODO: actually invoke the method
// TODO: actually invoke the InternalWriteTo method!!!!
//bufferMessage.InternalWriteTo(ref ctx);
// TODO: get rid of this code!
ctx.CopyStateTo(ctx.state.CodedOutputStream);
try
{
// fallback parse using the CodedOutputStream that started current serialization tree
message.WriteTo(ctx.state.CodedOutputStream);
}
finally
{
ctx.LoadStateFrom(ctx.state.CodedOutputStream);
}
}
else
{

Loading…
Cancel
Save