Commit b4bd2e03 authored by csharptest's avatar csharptest Committed by rogerk

Issue 84: warning CS0219: The variable `size' is assigned but its value is never used

parent 1e29e701
......@@ -360,7 +360,7 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine("public override void WriteTo(pb::ICodedOutputStream output) {");
writer.Indent();
// Make sure we've computed the serialized length, so that packed fields are generated correctly.
writer.WriteLine("int size = SerializedSize;");
writer.WriteLine("CalcSerializedSize();");
writer.WriteLine("string[] field_names = _{0}FieldNames;", NameHelpers.UnderscoresToCamelCase(ClassName));
if (Descriptor.Proto.ExtensionRangeList.Count > 0)
{
......@@ -412,6 +412,17 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.Indent();
writer.WriteLine("int size = memoizedSerializedSize;");
writer.WriteLine("if (size != -1) return size;");
writer.WriteLine("return CalcSerializedSize();");
writer.Outdent();
writer.WriteLine("}");
writer.Outdent();
writer.WriteLine("}");
writer.WriteLine();
writer.WriteLine("private int CalcSerializedSize() {");
writer.Indent();
writer.WriteLine("int size = memoizedSerializedSize;");
writer.WriteLine("if (size != -1) return size;");
writer.WriteLine();
writer.WriteLine("size = 0;");
foreach (FieldDescriptor field in Descriptor.Fields)
......@@ -438,9 +449,6 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine("return size;");
writer.Outdent();
writer.WriteLine("}");
writer.Outdent();
writer.WriteLine("}");
writer.WriteLine();
}
private void GenerateSerializeOneField(TextGenerator writer, FieldDescriptor fieldDescriptor)
......
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