test are almost passing
This commit is contained in:
parent
125e4ad267
commit
ea1d55927d
@ -294,8 +294,7 @@ namespace Google.Protobuf
|
|||||||
WriteContext.Initialize(ref span, ref state, out WriteContext ctx);
|
WriteContext.Initialize(ref span, ref state, out WriteContext ctx);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO: fix fix fix
|
WritingPrimitivesMessages.WriteRawMessage(ref ctx, value);
|
||||||
WritingPrimitivesMessages.WriteMessage(ref ctx, value);
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -44,43 +44,35 @@ namespace Google.Protobuf
|
|||||||
internal static class WritingPrimitivesMessages
|
internal static class WritingPrimitivesMessages
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes a message, without a tag, to the stream.
|
/// Writes a message, without a tag.
|
||||||
/// The data is length-prefixed.
|
/// The data is length-prefixed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void WriteMessage(ref WriteContext ctx, IMessage value)
|
public static void WriteMessage(ref WriteContext ctx, IMessage value)
|
||||||
{
|
{
|
||||||
WritingPrimitives.WriteLength(ref ctx.buffer, ref ctx.state, value.CalculateSize());
|
WritingPrimitives.WriteLength(ref ctx.buffer, ref ctx.state, value.CalculateSize());
|
||||||
WriteInternal(ref ctx, value);
|
WriteRawMessage(ref ctx, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes a group, without a tag, to the stream.
|
/// Writes a group, without a tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void WriteGroup(ref WriteContext ctx, IMessage value)
|
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)
|
/// <summary>
|
||||||
|
/// Writes a message, without a tag.
|
||||||
|
/// Message will be written without a length prefix.
|
||||||
|
/// </summary>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static void WriteRawMessage(ref WriteContext ctx, IMessage message)
|
||||||
{
|
{
|
||||||
if (message is IBufferMessage bufferMessage)
|
if (message is IBufferMessage bufferMessage)
|
||||||
{
|
{
|
||||||
// TODO: actually invoke the InternalWriteTo method!!!!
|
bufferMessage.InternalWriteTo(ref ctx);
|
||||||
//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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user