diff --git a/csharp/src/Google.Protobuf/CodedOutputStream.cs b/csharp/src/Google.Protobuf/CodedOutputStream.cs
index 3384a3577..b4c90454f 100644
--- a/csharp/src/Google.Protobuf/CodedOutputStream.cs
+++ b/csharp/src/Google.Protobuf/CodedOutputStream.cs
@@ -294,8 +294,7 @@ namespace Google.Protobuf
WriteContext.Initialize(ref span, ref state, out WriteContext ctx);
try
{
- // TODO: fix fix fix
- WritingPrimitivesMessages.WriteMessage(ref ctx, value);
+ WritingPrimitivesMessages.WriteRawMessage(ref ctx, value);
}
finally
{
diff --git a/csharp/src/Google.Protobuf/WritingPrimitivesMessages.cs b/csharp/src/Google.Protobuf/WritingPrimitivesMessages.cs
index cc48fe63a..cd2d43791 100644
--- a/csharp/src/Google.Protobuf/WritingPrimitivesMessages.cs
+++ b/csharp/src/Google.Protobuf/WritingPrimitivesMessages.cs
@@ -44,43 +44,35 @@ namespace Google.Protobuf
internal static class WritingPrimitivesMessages
{
///
- /// Writes a message, without a tag, to the stream.
+ /// Writes a message, without a tag.
/// The data is length-prefixed.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteMessage(ref WriteContext ctx, IMessage value)
{
WritingPrimitives.WriteLength(ref ctx.buffer, ref ctx.state, value.CalculateSize());
- WriteInternal(ref ctx, value);
+ WriteRawMessage(ref ctx, value);
}
///
- /// Writes a group, without a tag, to the stream.
+ /// Writes a group, without a tag.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteGroup(ref WriteContext ctx, IMessage value)
{
- WriteInternal(ref ctx, value);
+ WriteRawMessage(ref ctx, value);
}
- private static void WriteInternal(ref WriteContext ctx, IMessage message)
+ ///
+ /// Writes a message, without a tag.
+ /// Message will be written without a length prefix.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void WriteRawMessage(ref WriteContext ctx, IMessage message)
{
if (message is IBufferMessage bufferMessage)
{
- // 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);
- }
+ bufferMessage.InternalWriteTo(ref ctx);
}
else
{