Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
cac45313
Commit
cac45313
authored
Aug 08, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #694 from jskeet/groups
Fix groups handling in C#
parents
b76b76ba
6e16037c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
269 additions
and
348 deletions
+269
-348
Addressbook.cs
csharp/src/AddressBook/Addressbook.cs
+3
-12
Conformance.cs
csharp/src/Google.Protobuf.Conformance/Conformance.cs
+5
-20
CodedInputStreamTest.cs
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
+88
-0
GeneratedMessageTest.cs
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
+22
-0
MapUnittestProto3.cs
.../src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
+7
-28
UnittestImportProto3.cs
...c/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
+1
-4
UnittestImportPublicProto3.cs
...le.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs
+1
-4
UnittestIssues.cs
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
+10
-40
UnittestProto3.cs
csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
+0
-0
UnittestWellKnownTypes.cs
...Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
+4
-16
WrappersTest.cs
...p/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
+23
-0
CodedInputStream.cs
csharp/src/Google.Protobuf/CodedInputStream.cs
+42
-13
MapField.cs
csharp/src/Google.Protobuf/Collections/MapField.cs
+2
-3
FieldCodec.cs
csharp/src/Google.Protobuf/FieldCodec.cs
+4
-3
InvalidProtocolBufferException.cs
csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
+6
-0
MessageExtensions.cs
csharp/src/Google.Protobuf/MessageExtensions.cs
+3
-3
DescriptorProtoFile.cs
csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
+22
-88
Any.cs
csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
+1
-4
Api.cs
csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
+2
-8
Duration.cs
csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
+1
-4
Empty.cs
csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
+1
-4
FieldMask.cs
csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
+1
-4
SourceContext.cs
csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
+1
-4
Struct.cs
csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
+3
-12
Timestamp.cs
csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+1
-4
Type.cs
csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
+5
-20
Wrappers.cs
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
+9
-36
WireFormat.cs
csharp/src/Google.Protobuf/WireFormat.cs
+0
-10
csharp_message.cc
src/google/protobuf/compiler/csharp/csharp_message.cc
+1
-4
No files found.
csharp/src/AddressBook/Addressbook.cs
View file @
cac45313
...
...
@@ -189,10 +189,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -335,10 +332,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Number
=
input
.
ReadString
();
...
...
@@ -441,10 +435,7 @@ namespace Google.Protobuf.Examples.AddressBook {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
people_
.
AddEntriesFrom
(
input
,
_repeated_people_codec
);
...
...
csharp/src/Google.Protobuf.Conformance/Conformance.cs
View file @
cac45313
...
...
@@ -321,10 +321,7 @@ namespace Conformance {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
ProtobufPayload
=
input
.
ReadBytes
();
...
...
@@ -557,10 +554,7 @@ namespace Conformance {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
ParseError
=
input
.
ReadString
();
...
...
@@ -1829,10 +1823,7 @@ namespace Conformance {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
OptionalInt32
=
input
.
ReadInt32
();
...
...
@@ -2256,10 +2247,7 @@ namespace Conformance {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
A
=
input
.
ReadInt32
();
...
...
@@ -2373,10 +2361,7 @@ namespace Conformance {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
C
=
input
.
ReadInt32
();
...
...
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
View file @
cac45313
...
...
@@ -442,5 +442,92 @@ namespace Google.Protobuf
var
input
=
new
CodedInputStream
(
new
byte
[]
{
0
});
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
input
.
ReadTag
());
}
[
Test
]
public
void
SkipGroup
()
{
// Create an output stream with a group in:
// Field 1: string "field 1"
// Field 2: group containing:
// Field 1: fixed int32 value 100
// Field 2: string "ignore me"
// Field 3: nested group containing
// Field 1: fixed int64 value 1000
// Field 3: string "field 3"
var
stream
=
new
MemoryStream
();
var
output
=
new
CodedOutputStream
(
stream
);
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WriteString
(
"field 1"
);
// The outer group...
output
.
WriteTag
(
2
,
WireFormat
.
WireType
.
StartGroup
);
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
Fixed32
);
output
.
WriteFixed32
(
100
);
output
.
WriteTag
(
2
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WriteString
(
"ignore me"
);
// The nested group...
output
.
WriteTag
(
3
,
WireFormat
.
WireType
.
StartGroup
);
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
Fixed64
);
output
.
WriteFixed64
(
1000
);
// Note: Not sure the field number is relevant for end group...
output
.
WriteTag
(
3
,
WireFormat
.
WireType
.
EndGroup
);
// End the outer group
output
.
WriteTag
(
2
,
WireFormat
.
WireType
.
EndGroup
);
output
.
WriteTag
(
3
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WriteString
(
"field 3"
);
output
.
Flush
();
stream
.
Position
=
0
;
// Now act like a generated client
var
input
=
new
CodedInputStream
(
stream
);
Assert
.
AreEqual
(
WireFormat
.
MakeTag
(
1
,
WireFormat
.
WireType
.
LengthDelimited
),
input
.
ReadTag
());
Assert
.
AreEqual
(
"field 1"
,
input
.
ReadString
());
Assert
.
AreEqual
(
WireFormat
.
MakeTag
(
2
,
WireFormat
.
WireType
.
StartGroup
),
input
.
ReadTag
());
input
.
SkipLastField
();
// Should consume the whole group, including the nested one.
Assert
.
AreEqual
(
WireFormat
.
MakeTag
(
3
,
WireFormat
.
WireType
.
LengthDelimited
),
input
.
ReadTag
());
Assert
.
AreEqual
(
"field 3"
,
input
.
ReadString
());
}
[
Test
]
public
void
EndOfStreamReachedWhileSkippingGroup
()
{
var
stream
=
new
MemoryStream
();
var
output
=
new
CodedOutputStream
(
stream
);
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
StartGroup
);
output
.
WriteTag
(
2
,
WireFormat
.
WireType
.
StartGroup
);
output
.
WriteTag
(
2
,
WireFormat
.
WireType
.
EndGroup
);
output
.
Flush
();
stream
.
Position
=
0
;
// Now act like a generated client
var
input
=
new
CodedInputStream
(
stream
);
input
.
ReadTag
();
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
input
.
SkipLastField
());
}
[
Test
]
public
void
RecursionLimitAppliedWhileSkippingGroup
()
{
var
stream
=
new
MemoryStream
();
var
output
=
new
CodedOutputStream
(
stream
);
for
(
int
i
=
0
;
i
<
CodedInputStream
.
DefaultRecursionLimit
+
1
;
i
++)
{
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
StartGroup
);
}
for
(
int
i
=
0
;
i
<
CodedInputStream
.
DefaultRecursionLimit
+
1
;
i
++)
{
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
EndGroup
);
}
output
.
Flush
();
stream
.
Position
=
0
;
// Now act like a generated client
var
input
=
new
CodedInputStream
(
stream
);
Assert
.
AreEqual
(
WireFormat
.
MakeTag
(
1
,
WireFormat
.
WireType
.
StartGroup
),
input
.
ReadTag
());
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
input
.
SkipLastField
());
}
}
}
\ No newline at end of file
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
View file @
cac45313
...
...
@@ -629,5 +629,27 @@ namespace Google.Protobuf
var
data
=
new
byte
[]
{
130
,
3
,
1
};
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
TestAllTypes
.
Parser
.
ParseFrom
(
data
));
}
/// <summary>
/// Demonstrates current behaviour with an extraneous end group tag - see issue 688
/// for details; we may want to change this.
/// </summary>
[
Test
]
public
void
ExtraEndGroupSkipped
()
{
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
var
stream
=
new
MemoryStream
();
var
output
=
new
CodedOutputStream
(
stream
);
output
.
WriteTag
(
100
,
WireFormat
.
WireType
.
EndGroup
);
output
.
WriteTag
(
TestAllTypes
.
SingleFixed32FieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
output
.
WriteFixed32
(
123
);
output
.
Flush
();
stream
.
Position
=
0
;
var
parsed
=
TestAllTypes
.
Parser
.
ParseFrom
(
stream
);
Assert
.
AreEqual
(
new
TestAllTypes
{
SingleFixed32
=
123
},
parsed
);
}
}
}
csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
View file @
cac45313
...
...
@@ -476,10 +476,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
mapInt32Int32_
.
AddEntriesFrom
(
input
,
_map_mapInt32Int32_codec
);
...
...
@@ -648,10 +645,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
if
(
testMap_
==
null
)
{
...
...
@@ -748,10 +742,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
mapInt32Message_
.
AddEntriesFrom
(
input
,
_map_mapInt32Message_codec
);
...
...
@@ -859,10 +850,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
map1_
.
AddEntriesFrom
(
input
,
_map_map1_codec
);
...
...
@@ -1156,10 +1144,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
mapInt32Int32_
.
AddEntriesFrom
(
input
,
_map_mapInt32Int32_codec
);
...
...
@@ -1309,10 +1294,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
type_
.
AddEntriesFrom
(
input
,
_map_type_codec
);
...
...
@@ -1416,10 +1398,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
entry_
.
AddEntriesFrom
(
input
,
_map_entry_codec
);
...
...
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
View file @
cac45313
...
...
@@ -139,10 +139,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
D
=
input
.
ReadInt32
();
...
...
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs
View file @
cac45313
...
...
@@ -125,10 +125,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
E
=
input
.
ReadInt32
();
...
...
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
View file @
cac45313
...
...
@@ -142,10 +142,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
}
}
...
...
@@ -222,10 +219,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
}
}
...
...
@@ -302,10 +296,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
}
}
...
...
@@ -441,10 +432,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
value_
=
(
global
::
UnitTest
.
Issues
.
TestProtos
.
NegativeEnum
)
input
.
ReadEnum
();
...
...
@@ -534,10 +522,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
}
}
...
...
@@ -730,10 +715,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
PrimitiveValue
=
input
.
ReadInt32
();
...
...
@@ -860,10 +842,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Item
=
input
.
ReadInt32
();
...
...
@@ -987,10 +966,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Types_
=
input
.
ReadInt32
();
...
...
@@ -1075,10 +1051,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
}
}
...
...
@@ -1343,10 +1316,7 @@ namespace UnitTest.Issues.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
PlainString
=
input
.
ReadString
();
...
...
csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
View file @
cac45313
This diff is collapsed.
Click to expand it.
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
View file @
cac45313
...
...
@@ -679,10 +679,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
if
(
anyField_
==
null
)
{
...
...
@@ -1136,10 +1133,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
anyField_
.
AddEntriesFrom
(
input
,
_repeated_anyField_codec
);
...
...
@@ -1757,10 +1751,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
global
::
Google
.
Protobuf
.
WellKnownTypes
.
Any
subBuilder
=
new
global
::
Google
.
Protobuf
.
WellKnownTypes
.
Any
();
...
...
@@ -2205,10 +2196,7 @@ namespace Google.Protobuf.TestProtos {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
anyField_
.
AddEntriesFrom
(
input
,
_map_anyField_codec
);
...
...
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
View file @
cac45313
...
...
@@ -322,5 +322,28 @@ namespace Google.Protobuf.WellKnownTypes
// A normal implementation would have 0 now, as the explicit default would have been overwritten the 5.
Assert
.
AreEqual
(
5
,
message
.
Int32Field
);
}
[
Test
]
public
void
UnknownFieldInWrapper
()
{
var
stream
=
new
MemoryStream
();
var
output
=
new
CodedOutputStream
(
stream
);
var
wrapperTag
=
WireFormat
.
MakeTag
(
TestWellKnownTypes
.
Int32FieldFieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
var
unknownTag
=
WireFormat
.
MakeTag
(
15
,
WireFormat
.
WireType
.
Varint
);
var
valueTag
=
WireFormat
.
MakeTag
(
Int32Value
.
ValueFieldNumber
,
WireFormat
.
WireType
.
Varint
);
output
.
WriteTag
(
wrapperTag
);
output
.
WriteLength
(
4
);
// unknownTag + value 5 + valueType + value 6, each 1 byte
output
.
WriteTag
(
unknownTag
);
output
.
WriteInt32
((
int
)
valueTag
);
// Sneakily "pretend" it's a tag when it's really a value
output
.
WriteTag
(
valueTag
);
output
.
WriteInt32
(
6
);
output
.
Flush
();
stream
.
Position
=
0
;
var
message
=
TestWellKnownTypes
.
Parser
.
ParseFrom
(
stream
);
Assert
.
AreEqual
(
6
,
message
.
Int32Field
);
}
}
}
csharp/src/Google.Protobuf/CodedInputStream.cs
View file @
cac45313
...
...
@@ -236,17 +236,16 @@ namespace Google.Protobuf
#
region
Validation
/// <summary>
/// Verifies that the last call to ReadTag() returned the given tag value.
/// This is used to verify that a nested group ended with the correct
/// end tag.
/// Verifies that the last call to ReadTag() returned tag 0 - in other words,
/// we've reached the end of the stream when we expected to.
/// </summary>
/// <exception cref="InvalidProtocolBufferException">The
last
/// <exception cref="InvalidProtocolBufferException">The
/// tag read was not the one specified</exception>
internal
void
Check
LastTagWas
(
uint
value
)
internal
void
Check
ReadEndOfStreamTag
(
)
{
if
(
lastTag
!=
value
)
if
(
lastTag
!=
0
)
{
throw
InvalidProtocolBufferException
.
InvalidEndTag
();
throw
InvalidProtocolBufferException
.
MoreDataAvailable
();
}
}
#
endregion
...
...
@@ -275,6 +274,11 @@ namespace Google.Protobuf
/// <summary>
/// Reads a field tag, returning the tag of 0 for "end of stream".
/// </summary>
/// <remarks>
/// If this method returns 0, it doesn't necessarily mean the end of all
/// the data in this CodedInputStream; it may be the end of the logical stream
/// for an embedded message, for example.
/// </remarks>
/// <returns>The next field tag, or 0 for end of stream. (0 is never a valid tag.)</returns>
public
uint
ReadTag
()
{
...
...
@@ -329,22 +333,24 @@ namespace Google.Protobuf
}
/// <summary>
///
Consume
s the data for the field with the tag we've just read.
///
Skip
s 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
Consume
LastField
()
public
void
Skip
LastField
()
{
if
(
lastTag
==
0
)
{
throw
new
InvalidOperationException
(
"
Consume
LastField cannot be called at the end of a stream"
);
throw
new
InvalidOperationException
(
"
Skip
LastField cannot be called at the end of a stream"
);
}
switch
(
WireFormat
.
GetTagWireType
(
lastTag
))
{
case
WireFormat
.
WireType
.
StartGroup
:
SkipGroup
();
break
;
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"
)
;
//
Just ignore; there's no data following the tag
.
break
;
case
WireFormat
.
WireType
.
Fixed32
:
ReadFixed32
();
break
;
...
...
@@ -361,6 +367,29 @@ namespace Google.Protobuf
}
}
private
void
SkipGroup
()
{
// Note: Currently we expect this to be the way that groups are read. We could put the recursion
// depth changes into the ReadTag method instead, potentially...
recursionDepth
++;
if
(
recursionDepth
>=
recursionLimit
)
{
throw
InvalidProtocolBufferException
.
RecursionLimitExceeded
();
}
uint
tag
;
do
{
tag
=
ReadTag
();
if
(
tag
==
0
)
{
throw
InvalidProtocolBufferException
.
TruncatedMessage
();
}
// This recursion will allow us to handle nested groups.
SkipLastField
();
}
while
(
WireFormat
.
GetTagWireType
(
tag
)
!=
WireFormat
.
WireType
.
EndGroup
);
recursionDepth
--;
}
/// <summary>
/// Reads a double field from the stream.
/// </summary>
...
...
@@ -475,7 +504,7 @@ namespace Google.Protobuf
int
oldLimit
=
PushLimit
(
length
);
++
recursionDepth
;
builder
.
MergeFrom
(
this
);
Check
LastTagWas
(
0
);
Check
ReadEndOfStreamTag
(
);
// Check that we've read exactly as much data as expected.
if
(!
ReachedLimit
)
{
...
...
csharp/src/Google.Protobuf/Collections/MapField.cs
View file @
cac45313
...
...
@@ -637,10 +637,9 @@ namespace Google.Protobuf.Collections
{
Value
=
codec
.
valueCodec
.
Read
(
input
);
}
else
if
(
WireFormat
.
IsEndGroupTag
(
tag
))
else
{
// TODO(jonskeet): Do we need this? (Given that we don't support groups...)
return
;
input
.
SkipLastField
();
}
}
}
...
...
csharp/src/Google.Protobuf/FieldCodec.cs
View file @
cac45313
...
...
@@ -304,12 +304,13 @@ namespace Google.Protobuf
{
value
=
codec
.
Read
(
input
);
}
if
(
WireFormat
.
IsEndGroupTag
(
tag
))
else
{
break
;
input
.
SkipLastField
()
;
}
}
input
.
Check
LastTagWas
(
0
);
input
.
Check
ReadEndOfStreamTag
(
);
input
.
PopLimit
(
oldLimit
);
return
value
;
...
...
csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
View file @
cac45313
...
...
@@ -45,6 +45,12 @@ namespace Google.Protobuf
{
}
internal
static
InvalidProtocolBufferException
MoreDataAvailable
()
{
return
new
InvalidProtocolBufferException
(
"Completed reading a message while more data was available in the stream."
);
}
internal
static
InvalidProtocolBufferException
TruncatedMessage
()
{
return
new
InvalidProtocolBufferException
(
...
...
csharp/src/Google.Protobuf/MessageExtensions.cs
View file @
cac45313
...
...
@@ -50,7 +50,7 @@ namespace Google.Protobuf
Preconditions
.
CheckNotNull
(
data
,
"data"
);
CodedInputStream
input
=
new
CodedInputStream
(
data
);
message
.
MergeFrom
(
input
);
input
.
Check
LastTagWas
(
0
);
input
.
Check
ReadEndOfStreamTag
(
);
}
/// <summary>
...
...
@@ -64,7 +64,7 @@ namespace Google.Protobuf
Preconditions
.
CheckNotNull
(
data
,
"data"
);
CodedInputStream
input
=
data
.
CreateCodedInput
();
message
.
MergeFrom
(
input
);
input
.
Check
LastTagWas
(
0
);
input
.
Check
ReadEndOfStreamTag
(
);
}
/// <summary>
...
...
@@ -78,7 +78,7 @@ namespace Google.Protobuf
Preconditions
.
CheckNotNull
(
input
,
"input"
);
CodedInputStream
codedInput
=
new
CodedInputStream
(
input
);
message
.
MergeFrom
(
codedInput
);
codedInput
.
Check
LastTagWas
(
0
);
codedInput
.
Check
ReadEndOfStreamTag
(
);
}
/// <summary>
...
...
csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs
View file @
cac45313
...
...
@@ -242,10 +242,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
file_
.
AddEntriesFrom
(
input
,
_repeated_file_codec
);
...
...
@@ -539,10 +536,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -833,10 +827,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -1000,10 +991,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Start
=
input
.
ReadInt32
();
...
...
@@ -1131,10 +1119,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Start
=
input
.
ReadInt32
();
...
...
@@ -1424,10 +1409,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -1597,10 +1579,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -1741,10 +1720,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -1904,10 +1880,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -2059,10 +2032,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -2288,10 +2258,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -2716,10 +2683,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
JavaPackage
=
input
.
ReadString
();
...
...
@@ -2969,10 +2933,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
MessageSetWireFormat
=
input
.
ReadBool
();
...
...
@@ -3214,10 +3175,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
ctype_
=
(
global
::
Google
.
Protobuf
.
Reflection
.
FieldOptions
.
Types
.
CType
)
input
.
ReadEnum
();
...
...
@@ -3397,10 +3355,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
16
:
{
AllowAlias
=
input
.
ReadBool
();
...
...
@@ -3524,10 +3479,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Deprecated
=
input
.
ReadBool
();
...
...
@@ -3647,10 +3599,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
264
:
{
Deprecated
=
input
.
ReadBool
();
...
...
@@ -3770,10 +3719,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
264
:
{
Deprecated
=
input
.
ReadBool
();
...
...
@@ -4003,10 +3949,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
18
:
{
name_
.
AddEntriesFrom
(
input
,
_repeated_name_codec
);
...
...
@@ -4155,10 +4098,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
NamePart_
=
input
.
ReadString
();
...
...
@@ -4261,10 +4201,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
location_
.
AddEntriesFrom
(
input
,
_repeated_location_codec
);
...
...
@@ -4431,10 +4368,7 @@ namespace Google.Protobuf.Reflection {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
case
8
:
{
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
View file @
cac45313
...
...
@@ -150,10 +150,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
TypeUrl
=
input
.
ReadString
();
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
View file @
cac45313
...
...
@@ -213,10 +213,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -439,10 +436,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
View file @
cac45313
...
...
@@ -151,10 +151,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Seconds
=
input
.
ReadInt64
();
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
View file @
cac45313
...
...
@@ -106,10 +106,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
}
}
...
...
csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
View file @
cac45313
...
...
@@ -120,10 +120,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
paths_
.
AddEntriesFrom
(
input
,
_repeated_paths_codec
);
...
...
csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
View file @
cac45313
...
...
@@ -129,10 +129,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
FileName
=
input
.
ReadString
();
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
View file @
cac45313
...
...
@@ -139,10 +139,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
fields_
.
AddEntriesFrom
(
input
,
_map_fields_codec
);
...
...
@@ -392,10 +389,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
kind_
=
input
.
ReadEnum
();
...
...
@@ -520,10 +514,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
values_
.
AddEntriesFrom
(
input
,
_repeated_values_codec
);
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
View file @
cac45313
...
...
@@ -151,10 +151,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Seconds
=
input
.
ReadInt64
();
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
View file @
cac45313
...
...
@@ -226,10 +226,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -496,10 +493,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
kind_
=
(
global
::
Google
.
Protobuf
.
WellKnownTypes
.
Field
.
Types
.
Kind
)
input
.
ReadEnum
();
...
...
@@ -716,10 +710,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -872,10 +863,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
@@ -1010,10 +998,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Name
=
input
.
ReadString
();
...
...
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
View file @
cac45313
...
...
@@ -138,10 +138,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
9
:
{
Value
=
input
.
ReadDouble
();
...
...
@@ -243,10 +240,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
13
:
{
Value
=
input
.
ReadFloat
();
...
...
@@ -348,10 +342,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Value
=
input
.
ReadInt64
();
...
...
@@ -453,10 +444,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Value
=
input
.
ReadUInt64
();
...
...
@@ -558,10 +546,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Value
=
input
.
ReadInt32
();
...
...
@@ -663,10 +648,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Value
=
input
.
ReadUInt32
();
...
...
@@ -768,10 +750,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
8
:
{
Value
=
input
.
ReadBool
();
...
...
@@ -873,10 +852,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Value
=
input
.
ReadString
();
...
...
@@ -978,10 +954,7 @@ namespace Google.Protobuf.WellKnownTypes {
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
switch
(
tag
)
{
default
:
if
(
pb
::
WireFormat
.
IsEndGroupTag
(
tag
))
{
return
;
}
input
.
ConsumeLastField
();
input
.
SkipLastField
();
break
;
case
10
:
{
Value
=
input
.
ReadBytes
();
...
...
csharp/src/Google.Protobuf/WireFormat.cs
View file @
cac45313
...
...
@@ -98,16 +98,6 @@ namespace Google.Protobuf
return
(
WireType
)
(
tag
&
TagTypeMask
);
}
/// <summary>
/// Determines whether the given tag is an end group tag.
/// </summary>
/// <param name="tag">The tag to check.</param>
/// <returns><c>true</c> if the given tag is an end group tag; <c>false</c> otherwise.</returns>
public
static
bool
IsEndGroupTag
(
uint
tag
)
{
return
(
WireType
)
(
tag
&
TagTypeMask
)
==
WireType
.
EndGroup
;
}
/// <summary>
/// Given a tag value, determines the field number (the upper 29 bits).
/// </summary>
...
...
src/google/protobuf/compiler/csharp/csharp_message.cc
View file @
cac45313
...
...
@@ -423,10 +423,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
printer
->
Indent
();
printer
->
Print
(
"default:
\n
"
" if (pb::WireFormat.IsEndGroupTag(tag)) {
\n
"
" return;
\n
"
" }
\n
"
" input.ConsumeLastField();
\n
"
// We're not storing the data, but we still need to consume it.
" input.SkipLastField();
\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
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment