public void ReadInvalidUtf8() { MemoryStream ms = new MemoryStream(); CodedOutputStream output = CodedOutputStream.CreateInstance(ms); uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); output.WriteRawVarint32(tag); output.WriteRawVarint32(1); output.WriteRawBytes(new byte[] { 0x80 }); output.Flush(); ms.Position = 0; CodedInputStream input = CodedInputStream.CreateInstance(ms); uint testtag; string ignored; Assert.IsTrue(input.ReadTag(out testtag, out ignored)); Assert.AreEqual(tag, testtag); string text = null; input.ReadString(ref text); Assert.AreEqual('\ufffd', text[0]); }