Skip to content
Permalink
Browse files

Fix conformance test failures for Google.Protobuf

  • Loading branch information
ObsidianMinor committed Nov 19, 2019
1 parent 3cae867 commit e2e70a8a421fb52d0f17a54d6476df0b8a7d2c83
Showing with 26 additions and 32 deletions.
  1. +0 −31 conformance/failure_list_csharp.txt
  2. +26 −1 csharp/src/Google.Protobuf/CodedInputStream.cs
@@ -1,33 +1,2 @@
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.BOOL[4].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.BOOL[6].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.BOOL[4].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.BOOL[6].ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.BOOL[4].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.BOOL[6].ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.BOOL.JsonOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[4].JsonOutput
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[4].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[6].JsonOutput
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[6].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
@@ -577,7 +577,32 @@ public uint ReadFixed32()
/// </summary>
public bool ReadBool()
{
return ReadRawVarint32() != 0;
int result = 0; // can't do AND on bytes, it gets implicitly upcasted to int
byte index = 0;
if (bufferPos < bufferSize) // check if we have at least one byte for the most likely case of a one byte 1 or 0
{
result = buffer[bufferPos++];
if (result < 128)
{
return result != 0;
}
result &= 0x7f;
index++;
}

do
{
byte b = ReadRawByte();
result |= b & 0x7F; // OR all bytes together since we don't care about the actual value, just whether is more than zero
if (b < 0x80)
{
return result != 0;
}
index++;
}
while (index < 10);

throw InvalidProtocolBufferException.MalformedVarint();
}

/// <summary>

0 comments on commit e2e70a8

Please sign in to comment.
You can’t perform that action at this time.