Browse Source

fix WriteString bug

Jan Tattermusch 5 years ago
parent
commit
5742a64eea
1 changed files with 2 additions and 1 deletions
  1. 2 1
      csharp/src/Google.Protobuf/WritingPrimitives.cs

+ 2 - 1
csharp/src/Google.Protobuf/WritingPrimitives.cs

@@ -165,6 +165,7 @@ namespace Google.Protobuf
                     {
                         buffer[state.position + i] = (byte)value[i];
                     }
+                    state.position += length;
                 }
                 else
                 {
@@ -173,8 +174,8 @@ namespace Google.Protobuf
                     WriteRawBytes(ref buffer, ref state, bytes);
                     // TODO: we need to write to a span...
                     //Utf8Encoding.GetBytes(value, 0, value.Length, buffer, state.position);
+                    //state.position += length;
                 }
-                state.position += length;
             }
             else
             {