Commit 79cf8a8b authored by Sydney Acksman's avatar Sydney Acksman

Fix readability in FieldCodec.ForMessage/Group factories

parent 3237ad39
......@@ -402,8 +402,15 @@ namespace Google.Protobuf
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser) where T : class, IMessage<T>
{
return new FieldCodec<T>(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; },
(output, value) => output.WriteMessage(value), (CodedInputStream i, ref T v) =>
return new FieldCodec<T>(
input =>
{
T message = parser.CreateTemplate();
input.ReadMessage(message);
return message;
},
(output, value) => output.WriteMessage(value),
(CodedInputStream i, ref T v) =>
{
if (v == null)
{
......@@ -427,7 +434,8 @@ namespace Google.Protobuf
v.MergeFrom(v2);
}
return true;
}, message => CodedOutputStream.ComputeMessageSize(message), tag);
},
message => CodedOutputStream.ComputeMessageSize(message), tag);
}
/// <summary>
......@@ -439,8 +447,16 @@ namespace Google.Protobuf
/// <returns>A codec for given tag</returns>
public static FieldCodec<T> ForGroup<T>(uint startTag, uint endTag, MessageParser<T> parser) where T : class, IMessage<T>
{
return new FieldCodec<T>(input => { T message = parser.CreateTemplate(); input.ReadGroup(message); return message; },
(output, value) => output.WriteGroup(value), (CodedInputStream i, ref T v) => {
return new FieldCodec<T>(
input =>
{
T message = parser.CreateTemplate();
input.ReadGroup(message);
return message;
},
(output, value) => output.WriteGroup(value),
(CodedInputStream i, ref T v) =>
{
if (v == null)
{
v = parser.CreateTemplate();
......@@ -463,7 +479,8 @@ namespace Google.Protobuf
v.MergeFrom(v2);
}
return true;
}, message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag);
},
message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag);
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment