address review comments

pull/7576/head
Jan Tattermusch 5 years ago
parent a296413b5a
commit 8a2d5884bf
  1. 4
      csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
  2. 12
      csharp/src/Google.Protobuf/CodedOutputStream.cs
  3. 2
      csharp/src/Google.Protobuf/MessageExtensions.cs
  4. 6
      csharp/src/Google.Protobuf/WritingPrimitives.cs

@ -463,7 +463,7 @@ namespace Google.Protobuf
Assert.IsTrue(memoryStream.CanWrite);
using (var cos = new CodedOutputStream(memoryStream))
{
cos.WriteRawByte(0);
cos.WriteRawBytes(new byte[] {0});
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
}
Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
@ -477,7 +477,7 @@ namespace Google.Protobuf
Assert.IsTrue(memoryStream.CanWrite);
using (var cos = new CodedOutputStream(memoryStream, true))
{
cos.WriteRawByte(0);
cos.WriteRawBytes(new byte[] {0});
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
}
Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream

@ -517,18 +517,6 @@ namespace Google.Protobuf
WritingPrimitives.WriteRawLittleEndian64(ref span, ref state, value);
}
internal void WriteRawByte(byte value)
{
var span = new Span<byte>(buffer);
WritingPrimitives.WriteRawByte(ref span, ref state, value);
}
internal void WriteRawByte(uint value)
{
var span = new Span<byte>(buffer);
WritingPrimitives.WriteRawByte(ref span, ref state, value);
}
/// <summary>
/// Writes out an array of bytes.
/// </summary>

@ -151,6 +151,7 @@ namespace Google.Protobuf
/// </summary>
/// <param name="message">The message to write to the stream.</param>
/// <param name="output">The stream to write to.</param>
[SecuritySafeCritical]
public static void WriteTo(this IMessage message, IBufferWriter<byte> output)
{
ProtoPreconditions.CheckNotNull(message, nameof(message));
@ -170,6 +171,7 @@ namespace Google.Protobuf
/// </summary>
/// <param name="message">The message to write to the stream.</param>
/// <param name="output">The span to write to. Size must match size of the message exactly.</param>
[SecuritySafeCritical]
public static void WriteTo(this IMessage message, Span<byte> output)
{
ProtoPreconditions.CheckNotNull(message, nameof(message));

@ -391,12 +391,6 @@ namespace Google.Protobuf
buffer[state.position++] = value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteRawByte(ref Span<byte> buffer, ref WriterInternalState state, uint value)
{
WriteRawByte(ref buffer, ref state, (byte)value);
}
/// <summary>
/// Writes out an array of bytes.
/// </summary>

Loading…
Cancel
Save