Commit 60794032 authored by Jon Skeet's avatar Jon Skeet

Merge pull request #689 from jskeet/fix-eof

C# conformance tests
parents d77d70d2 c13a612d
......@@ -40,7 +40,7 @@ $(protoc_outputs): protoc_middleman
BUILT_SOURCES = $(protoc_outputs)
CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java
CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java conformance-csharp
MAINTAINERCLEANFILES = \
Makefile.in
......@@ -55,6 +55,15 @@ conformance-java: javac_middleman
@echo 'java -classpath .:../java/target/classes ConformanceJava "$$@"' >> conformance-java
@chmod +x conformance-java
# Currently the conformance code is alongside the rest of the C#
# source, as it's easier to maintain there. We assume we've already
# built that, so we just need a script to run it.
conformance-csharp:
@echo "Writing shortcut script conformance-csharp..."
@echo '#! /bin/sh' > conformance-csharp
@echo 'mono ../csharp/src/Google.Protobuf.Conformance/bin/Release/Google.Protobuf.Conformance.exe "$$@"' >> conformance-csharp
@chmod +x conformance-csharp
# Targets for actually running tests.
test_cpp: protoc_middleman conformance-test-runner conformance-cpp
./conformance-test-runner --failure_list failure_list_cpp.txt ./conformance-cpp
......@@ -62,5 +71,8 @@ test_cpp: protoc_middleman conformance-test-runner conformance-cpp
test_java: protoc_middleman conformance-test-runner conformance-java
./conformance-test-runner ./conformance-java
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
./conformance-test-runner --failure_list failure_list_csharp.txt ./conformance-csharp
test_ruby: protoc_middleman conformance-test-runner
RUBYLIB=../ruby/lib:. ./conformance-test-runner --failure_list failure_list_ruby.txt ./conformance_ruby.rb
......@@ -5,6 +5,8 @@ src/AddressBook/bin
src/AddressBook/obj
src/Google.Protobuf/bin/
src/Google.Protobuf/obj/
src/Google.Protobuf.Conformance/bin/
src/Google.Protobuf.Conformance/obj/
src/Google.Protobuf.Test/bin/
src/Google.Protobuf.Test/obj/
src/Google.Protobuf.JsonDump/bin/
......
......@@ -68,3 +68,6 @@ $PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos
# AddressBook sample protos
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
examples/addressbook.proto
$PROTOC -Iconformance --csharp_out=csharp/src/Google.Protobuf.Conformance \
conformance/conformance.proto
......@@ -194,6 +194,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -341,6 +342,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Number = input.ReadString();
......@@ -448,6 +450,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
people_.AddEntriesFrom(input, _repeated_people_codec);
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0607D1B8-80D6-4B35-9857-1263C1B32B94}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Google.Protobuf.Conformance</RootNamespace>
<AssemblyName>Google.Protobuf.Conformance</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Conformance.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
<Project>{6908bdce-d925-43f3-94ac-a531e6df2591}</Project>
<Name>Google.Protobuf</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using Conformance;
using System;
using System.IO;
namespace Google.Protobuf.Conformance
{
/// <summary>
/// Conformance tests. The test runner will provide JSON or proto data on stdin,
/// and this program will produce its output on stdout.
/// </summary>
class Program
{
private static void Main(string[] args)
{
// This way we get the binary streams instead of readers/writers.
var input = new BinaryReader(Console.OpenStandardInput());
var output = new BinaryWriter(Console.OpenStandardOutput());
int count = 0;
while (RunTest(input, output))
{
count++;
}
Console.Error.WriteLine("Received EOF after {0} tests", count);
}
private static bool RunTest(BinaryReader input, BinaryWriter output)
{
int? size = ReadInt32(input);
if (size == null)
{
return false;
}
byte[] inputData = input.ReadBytes(size.Value);
if (inputData.Length != size.Value)
{
throw new EndOfStreamException("Read " + inputData.Length + " bytes of data when expecting " + size);
}
ConformanceRequest request = ConformanceRequest.Parser.ParseFrom(inputData);
ConformanceResponse response = PerformRequest(request);
byte[] outputData = response.ToByteArray();
output.Write(outputData.Length);
output.Write(outputData);
// Ready for another test...
return true;
}
private static ConformanceResponse PerformRequest(ConformanceRequest request)
{
TestAllTypes message;
switch (request.PayloadCase)
{
case ConformanceRequest.PayloadOneofCase.JsonPayload:
return new ConformanceResponse { Skipped = "JSON parsing not implemented in C# yet" };
case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
try
{
message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload);
}
catch (InvalidProtocolBufferException e)
{
return new ConformanceResponse { ParseError = e.Message };
}
break;
default:
throw new Exception("Unsupported request payload: " + request.PayloadCase);
}
switch (request.RequestedOutputFormat)
{
case global::Conformance.WireFormat.JSON:
return new ConformanceResponse { JsonPayload = JsonFormatter.Default.Format(message) };
case global::Conformance.WireFormat.PROTOBUF:
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
default:
throw new Exception("Unsupported request output format: " + request.PayloadCase);
}
}
private static int? ReadInt32(BinaryReader input)
{
byte[] bytes = input.ReadBytes(4);
if (bytes.Length == 0)
{
// Cleanly reached the end of the stream
return null;
}
if (bytes.Length != 4)
{
throw new EndOfStreamException("Read " + bytes.Length + " bytes of size when expecting 4");
}
return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
}
}
}
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using System.Reflection;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Google.Protobuf.Conformance")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Google.Protobuf.Conformance")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
......@@ -36,6 +36,8 @@ using Google.Protobuf.TestProtos;
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Google.Protobuf.WellKnownTypes;
namespace Google.Protobuf
{
......@@ -257,7 +259,7 @@ namespace Google.Protobuf
output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
var nestedMessage = new ForeignMessage { C = 20 };
// Size of the entry (tag, size written by WriteMessage, data written by WriteMessage)
output.WriteRawVarint32((uint)(nestedMessage.CalculateSize() + 3));
output.WriteLength(2 + nestedMessage.CalculateSize());
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
output.WriteMessage(nestedMessage);
output.Flush();
......@@ -281,7 +283,7 @@ namespace Google.Protobuf
// Each field can be represented in a single byte, with a single byte tag.
// Total message size: 6 bytes.
output.WriteRawVarint32(6);
output.WriteLength(6);
output.WriteTag(1, WireFormat.WireType.Varint);
output.WriteInt32(key);
output.WriteTag(2, WireFormat.WireType.Varint);
......@@ -307,7 +309,7 @@ namespace Google.Protobuf
// Each field can be represented in a single byte, with a single byte tag.
// Total message size: 4 bytes.
output.WriteRawVarint32(4);
output.WriteLength(4);
output.WriteTag(2, WireFormat.WireType.Varint);
output.WriteInt32(value);
output.WriteTag(1, WireFormat.WireType.Varint);
......@@ -333,7 +335,7 @@ namespace Google.Protobuf
var key1 = 10;
var value1 = 20;
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteRawVarint32(4);
output.WriteLength(4);
output.WriteTag(1, WireFormat.WireType.Varint);
output.WriteInt32(key1);
output.WriteTag(2, WireFormat.WireType.Varint);
......@@ -343,7 +345,7 @@ namespace Google.Protobuf
var key2 = "a";
var value2 = "b";
output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteRawVarint32(6); // 3 bytes per entry: tag, size, character
output.WriteLength(6); // 3 bytes per entry: tag, size, character
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
output.WriteString(key2);
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
......@@ -353,7 +355,7 @@ namespace Google.Protobuf
var key3 = 15;
var value3 = 25;
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteRawVarint32(4);
output.WriteLength(4);
output.WriteTag(1, WireFormat.WireType.Varint);
output.WriteInt32(key3);
output.WriteTag(2, WireFormat.WireType.Varint);
......@@ -381,7 +383,7 @@ namespace Google.Protobuf
// First entry
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteRawVarint32(4);
output.WriteLength(4);
output.WriteTag(1, WireFormat.WireType.Varint);
output.WriteInt32(key);
output.WriteTag(2, WireFormat.WireType.Varint);
......@@ -389,7 +391,7 @@ namespace Google.Protobuf
// Second entry - same key, different value
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteRawVarint32(4);
output.WriteLength(4);
output.WriteTag(1, WireFormat.WireType.Varint);
output.WriteInt32(key);
output.WriteTag(2, WireFormat.WireType.Varint);
......@@ -590,5 +592,42 @@ namespace Google.Protobuf
Assert.AreEqual(message, message2);
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
}
[Test]
public void IgnoreUnknownFields_RealDataStillRead()
{
var message = SampleMessages.CreateFullTestAllTypes();
var stream = new MemoryStream();
var output = new CodedOutputStream(stream);
var unusedFieldNumber = 23456;
Assert.IsFalse(TestAllTypes.Descriptor.Fields.InDeclarationOrder().Select(x => x.FieldNumber).Contains(unusedFieldNumber));
output.WriteTag(unusedFieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteString("ignore me");
message.WriteTo(output);
output.Flush();
stream.Position = 0;
var parsed = TestAllTypes.Parser.ParseFrom(stream);
Assert.AreEqual(message, parsed);
}
[Test]
public void IgnoreUnknownFields_AllTypes()
{
// Simple way of ensuring we can skip all kinds of fields.
var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
var empty = Empty.Parser.ParseFrom(data);
Assert.AreEqual(new Empty(), empty);
}
// This was originally seen as a conformance test failure.
[Test]
public void TruncatedMessageFieldThrows()
{
// 130, 3 is the message tag
// 1 is the data length - but there's no data.
var data = new byte[] { 130, 3, 1 };
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(data));
}
}
}
......@@ -481,6 +481,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
......@@ -654,6 +655,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (testMap_ == null) {
......@@ -755,6 +757,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec);
......@@ -867,6 +870,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
map1_.AddEntriesFrom(input, _map_map1_codec);
......@@ -1165,6 +1169,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
......@@ -1319,6 +1324,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
type_.AddEntriesFrom(input, _map_type_codec);
......@@ -1427,6 +1433,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
entry_.AddEntriesFrom(input, _map_entry_codec);
......
......@@ -144,6 +144,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
D = input.ReadInt32();
......
......@@ -130,6 +130,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
E = input.ReadInt32();
......
......@@ -147,6 +147,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -228,6 +229,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -309,6 +311,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -449,6 +452,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum();
......@@ -543,6 +547,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -740,6 +745,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
PrimitiveValue = input.ReadInt32();
......@@ -871,6 +877,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Item = input.ReadInt32();
......@@ -999,6 +1006,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Types_ = input.ReadInt32();
......@@ -1088,6 +1096,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -1357,6 +1366,7 @@ namespace UnitTest.Issues.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
PlainString = input.ReadString();
......
......@@ -1216,6 +1216,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
SingleInt32 = input.ReadInt32();
......@@ -1552,6 +1553,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Bb = input.ReadInt32();
......@@ -1705,6 +1707,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (child_ == null) {
......@@ -1826,6 +1829,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
DeprecatedInt32 = input.ReadInt32();
......@@ -1932,6 +1936,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
C = input.ReadInt32();
......@@ -2016,6 +2021,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -2121,6 +2127,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (foreignNested_ == null) {
......@@ -2252,6 +2259,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
A = input.ReadInt32();
......@@ -2387,6 +2395,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (a_ == null) {
......@@ -2503,6 +2512,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (bb_ == null) {
......@@ -2637,6 +2647,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (a_ == null) {
......@@ -2875,6 +2886,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
PrimitiveField = input.ReadInt32();
......@@ -3083,6 +3095,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
MyInt = input.ReadInt64();
......@@ -3227,6 +3240,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Bb = input.ReadInt32();
......@@ -3342,6 +3356,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
sparseEnum_ = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum();
......@@ -3448,6 +3463,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Data = input.ReadString();
......@@ -3546,6 +3562,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
data_.AddEntriesFrom(input, _repeated_data_codec);
......@@ -3652,6 +3669,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Data = input.ReadBytes();
......@@ -3758,6 +3776,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Data = input.ReadBytes();
......@@ -3864,6 +3883,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Data = input.ReadInt32();
......@@ -3970,6 +3990,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Data = input.ReadUInt32();
......@@ -4076,6 +4097,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Data = input.ReadInt64();
......@@ -4182,6 +4204,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Data = input.ReadUInt64();
......@@ -4288,6 +4311,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Data = input.ReadBool();
......@@ -4467,6 +4491,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
FooInt = input.ReadInt32();
......@@ -4760,6 +4785,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 722:
case 720: {
......@@ -5106,6 +5132,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 722:
case 720: {
......@@ -5340,6 +5367,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 98:
case 101: {
......@@ -5472,6 +5500,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
A = input.ReadString();
......@@ -5556,6 +5585,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -5636,6 +5666,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -5716,6 +5747,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -5796,6 +5828,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -5876,6 +5909,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......@@ -5956,6 +5990,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......
......@@ -684,6 +684,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
if (anyField_ == null) {
......@@ -1142,6 +1143,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
anyField_.AddEntriesFrom(input, _repeated_anyField_codec);
......@@ -1764,6 +1766,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any();
......@@ -2213,6 +2216,7 @@ namespace Google.Protobuf.TestProtos {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
anyField_.AddEntriesFrom(input, _map_anyField_codec);
......
......@@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{D7282E99-2DC3-405B-946F-177DB2FD2AE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.csproj", "{0607D1B8-80D6-4B35-9857-1263C1B32B94}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -41,6 +43,12 @@ Global
{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.Build.0 = Release|Any CPU
{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
{D7282E99-2DC3-405B-946F-177DB2FD2AE2}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0607D1B8-80D6-4B35-9857-1263C1B32B94}.Release|Any CPU.Build.0 = Release|Any CPU
{0607D1B8-80D6-4B35-9857-1263C1B32B94}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
{0607D1B8-80D6-4B35-9857-1263C1B32B94}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -54,13 +54,37 @@ namespace Google.Protobuf
/// </remarks>
public sealed class CodedInputStream
{
/// <summary>
/// Buffer of data read from the stream or provided at construction time.
/// </summary>
private readonly byte[] buffer;
/// <summary>
/// The number of valid bytes in the buffer.
/// </summary>
private int bufferSize;
private int bufferSizeAfterLimit = 0;
/// <summary>
/// The position within the current buffer (i.e. the next byte to read)
/// </summary>
private int bufferPos = 0;
/// <summary>
/// The stream to read further input from, or null if the byte array buffer was provided
/// directly on construction, with no further data available.
/// </summary>
private readonly Stream input;
/// <summary>
/// The last tag we read. 0 indicates we've read to the end of the stream
/// (or haven't read anything yet).
/// </summary>
private uint lastTag = 0;
/// <summary>
/// The next tag, used to store the value read by PeekTag.
/// </summary>
private uint nextTag = 0;
private bool hasNextTag = false;
......@@ -308,6 +332,39 @@ namespace Google.Protobuf
return true;
}
/// <summary>
/// Consumes the data for the field with the tag we've just read.
/// This should be called directly after <see cref="ReadTag"/>, when
/// the caller wishes to skip an unknown field.
/// </summary>
public void ConsumeLastField()
{
if (lastTag == 0)
{
throw new InvalidOperationException("ConsumeLastField cannot be called at the end of a stream");
}
switch (WireFormat.GetTagWireType(lastTag))
{
case WireFormat.WireType.StartGroup:
case WireFormat.WireType.EndGroup:
// TODO: Work out how to skip them instead? See issue 688.
throw new InvalidProtocolBufferException("Group tags not supported by proto3 C# implementation");
case WireFormat.WireType.Fixed32:
ReadFixed32();
break;
case WireFormat.WireType.Fixed64:
ReadFixed64();
break;
case WireFormat.WireType.LengthDelimited:
var length = ReadLength();
SkipRawBytes(length);
break;
case WireFormat.WireType.Varint:
ReadRawVarint32();
break;
}
}
/// <summary>
/// Reads a double field from the stream.
/// </summary>
......@@ -423,6 +480,11 @@ namespace Google.Protobuf
++recursionDepth;
builder.MergeFrom(this);
CheckLastTagWas(0);
// Check that we've read exactly as much data as expected.
if (!ReachedLimit)
{
throw InvalidProtocolBufferException.TruncatedMessage();
}
--recursionDepth;
PopLimit(oldLimit);
}
......
......@@ -247,6 +247,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
file_.AddEntriesFrom(input, _repeated_file_codec);
......@@ -545,6 +546,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -840,6 +842,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -1008,6 +1011,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Start = input.ReadInt32();
......@@ -1140,6 +1144,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Start = input.ReadInt32();
......@@ -1434,6 +1439,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -1608,6 +1614,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -1753,6 +1760,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -1917,6 +1925,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -2073,6 +2082,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -2303,6 +2313,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -2732,6 +2743,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
JavaPackage = input.ReadString();
......@@ -2986,6 +2998,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
MessageSetWireFormat = input.ReadBool();
......@@ -3232,6 +3245,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
ctype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum();
......@@ -3416,6 +3430,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 16: {
AllowAlias = input.ReadBool();
......@@ -3544,6 +3559,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Deprecated = input.ReadBool();
......@@ -3668,6 +3684,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 264: {
Deprecated = input.ReadBool();
......@@ -3792,6 +3809,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 264: {
Deprecated = input.ReadBool();
......@@ -4026,6 +4044,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 18: {
name_.AddEntriesFrom(input, _repeated_name_codec);
......@@ -4179,6 +4198,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
NamePart_ = input.ReadString();
......@@ -4286,6 +4306,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
location_.AddEntriesFrom(input, _repeated_location_codec);
......@@ -4457,6 +4478,7 @@ namespace Google.Protobuf.Reflection {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10:
case 8: {
......
......@@ -155,6 +155,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
TypeUrl = input.ReadString();
......
......@@ -218,6 +218,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -445,6 +446,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......
......@@ -156,6 +156,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Seconds = input.ReadInt64();
......
......@@ -111,6 +111,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
}
}
......
......@@ -125,6 +125,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
paths_.AddEntriesFrom(input, _repeated_paths_codec);
......
......@@ -134,6 +134,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
FileName = input.ReadString();
......
......@@ -144,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
fields_.AddEntriesFrom(input, _map_fields_codec);
......@@ -398,6 +399,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
kind_ = input.ReadEnum();
......@@ -527,6 +529,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
values_.AddEntriesFrom(input, _repeated_values_codec);
......
......@@ -156,6 +156,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Seconds = input.ReadInt64();
......
......@@ -231,6 +231,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -502,6 +503,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
kind_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum();
......@@ -723,6 +725,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -880,6 +883,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......@@ -1019,6 +1023,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Name = input.ReadString();
......
......@@ -143,6 +143,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 9: {
Value = input.ReadDouble();
......@@ -249,6 +250,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 13: {
Value = input.ReadFloat();
......@@ -355,6 +357,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Value = input.ReadInt64();
......@@ -461,6 +464,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Value = input.ReadUInt64();
......@@ -567,6 +571,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Value = input.ReadInt32();
......@@ -673,6 +678,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Value = input.ReadUInt32();
......@@ -779,6 +785,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 8: {
Value = input.ReadBool();
......@@ -885,6 +892,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Value = input.ReadString();
......@@ -991,6 +999,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (pb::WireFormat.IsEndGroupTag(tag)) {
return;
}
input.ConsumeLastField();
break;
case 10: {
Value = input.ReadBytes();
......
......@@ -428,7 +428,8 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
" if (pb::WireFormat.IsEndGroupTag(tag)) {\n"
" return;\n"
" }\n"
" break;\n"); // Note: we're ignoring unknown fields here.
" input.ConsumeLastField();\n" // We're not storing the data, but we still need to consume it.
" break;\n");
for (int i = 0; i < fields_by_number().size(); i++) {
const FieldDescriptor* field = fields_by_number()[i];
internal::WireFormatLite::WireType wt =
......
......@@ -29,6 +29,11 @@ build_cpp_distcheck() {
}
build_csharp() {
# Just for the conformance tests. We don't currently
# need to really build protoc, but it's simplest to keep with the
# conventions of the other builds.
internal_build_cpp
# Install latest version of Mono
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
......@@ -39,6 +44,7 @@ build_csharp() {
(cd csharp/src; mono ../../nuget.exe restore)
csharp/buildall.sh
cd conformance && make test_csharp && cd ..
}
use_java() {
......
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