diff --git a/src/protobuf.Text/TextFormatter.cs b/src/protobuf.Text/TextFormatter.cs index 5fa34a1..64d7d89 100644 --- a/src/protobuf.Text/TextFormatter.cs +++ b/src/protobuf.Text/TextFormatter.cs @@ -278,7 +278,7 @@ private void WriteSingleField(TextWriter writer, FieldDescriptor field, object v private void WriteRepeatedField(TextWriter writer, FieldDescriptor field, object value) { - if(settings.FormatRepeatedValueOnSingleLine && (value as IList)[0].GetType().IsValueType) + if(settings.FormatRepeatedValueOnSingleLine && (value as IList).Count > 0 && (value as IList)[0].GetType().IsValueType) { writer.Write(field.Name); writer.Write(NameValueSeparator);