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
333d200a
Commit
333d200a
authored
Apr 14, 2015
by
Jan Tattermusch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integrate CalcSerializedSize() fix from protobuf-csharp-port issue 84
parent
7cc05ecb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
csharp_message.cc
src/google/protobuf/compiler/csharp/csharp_message.cc
+12
-4
No files found.
src/google/protobuf/compiler/csharp/csharp_message.cc
View file @
333d200a
...
...
@@ -378,7 +378,7 @@ void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) {
"public override void WriteTo(pb::ICodedOutputStream output) {"
);
writer
->
Indent
();
// Make sure we've computed the serialized length, so that packed fields are generated correctly.
writer
->
WriteLine
(
"
int size = SerializedSize
;"
);
writer
->
WriteLine
(
"
CalcSerializedSize()
;"
);
writer
->
WriteLine
(
"string[] field_names = _$0$FieldNames;"
,
UnderscoresToCamelCase
(
class_name
(),
false
));
if
(
descriptor_
->
extension_range_count
())
{
...
...
@@ -421,6 +421,17 @@ void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) {
writer
->
Indent
();
writer
->
WriteLine
(
"int size = memoizedSerializedSize;"
);
writer
->
WriteLine
(
"if (size != -1) return size;"
);
writer
->
WriteLine
(
"return CalcSerializedSize();"
);
writer
->
Outdent
();
writer
->
WriteLine
(
"}"
);
writer
->
Outdent
();
writer
->
WriteLine
(
"}"
);
writer
->
WriteLine
();
writer
->
WriteLine
(
"private int CalcSerializedSize() {"
);
writer
->
Indent
();
writer
->
WriteLine
(
"int size = memoizedSerializedSize;"
);
writer
->
WriteLine
(
"if (size != -1) return size;"
);
writer
->
WriteLine
();
writer
->
WriteLine
(
"size = 0;"
);
for
(
int
i
=
0
;
i
<
descriptor_
->
field_count
();
i
++
)
{
...
...
@@ -443,9 +454,6 @@ void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) {
writer
->
WriteLine
(
"return size;"
);
writer
->
Outdent
();
writer
->
WriteLine
(
"}"
);
writer
->
Outdent
();
writer
->
WriteLine
(
"}"
);
writer
->
WriteLine
();
}
void
MessageGenerator
::
GenerateSerializeOneField
(
...
...
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