From 79cf8a8baeef406fba615580e5d06fc44389ee4f Mon Sep 17 00:00:00 2001 From: Sydney Acksman Date: Sun, 21 Jul 2019 06:13:59 -0500 Subject: [PATCH] Fix readability in FieldCodec.ForMessage/Group factories --- csharp/src/Google.Protobuf/FieldCodec.cs | 29 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs index 4beb998f6b..ebd00b7022 100644 --- a/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -402,8 +402,15 @@ namespace Google.Protobuf /// A codec for the given tag. public static FieldCodec ForMessage(uint tag, MessageParser parser) where T : class, IMessage { - return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; }, - (output, value) => output.WriteMessage(value), (CodedInputStream i, ref T v) => + return new FieldCodec( + 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); } /// @@ -439,8 +447,16 @@ namespace Google.Protobuf /// A codec for given tag public static FieldCodec ForGroup(uint startTag, uint endTag, MessageParser parser) where T : class, IMessage { - return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadGroup(message); return message; }, - (output, value) => output.WriteGroup(value), (CodedInputStream i, ref T v) => { + return new FieldCodec( + 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); } ///