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
20bfd9bf
Commit
20bfd9bf
authored
Oct 23, 2008
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in GeneratedBuilder.MergeFrom
parent
b8c2fc57
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
7 deletions
+37
-7
unittest_optimize_for.proto
protos/google/protobuf/unittest_optimize_for.proto
+1
-0
GeneratedMessageTest.cs
src/ProtocolBuffers.Test/GeneratedMessageTest.cs
+24
-0
UnitTestOptimizeForProtoFile.cs
...olBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
+11
-6
GeneratedBuilder.cs
src/ProtocolBuffers/GeneratedBuilder.cs
+1
-1
No files found.
protos/google/protobuf/unittest_optimize_for.proto
View file @
20bfd9bf
...
...
@@ -55,6 +55,7 @@ message TestOptimizedForSize {
extend
TestOptimizedForSize
{
optional
int32
test_extension
=
1234
;
optional
TestRequiredOptimizedForSize
test_extension2
=
1235
;
}
}
...
...
src/ProtocolBuffers.Test/GeneratedMessageTest.cs
View file @
20bfd9bf
...
...
@@ -287,5 +287,29 @@ namespace Google.ProtocolBuffers {
).
BuildPartial
();
Assert
.
IsTrue
(
message
.
IsInitialized
);
}
[
Test
]
public
void
TestOptimizedForSizeMergeUsesAllFieldsFromTarget
()
{
TestOptimizedForSize
withFieldSet
=
new
TestOptimizedForSize
.
Builder
{
I
=
10
}.
Build
();
TestOptimizedForSize
.
Builder
builder
=
new
TestOptimizedForSize
.
Builder
();
builder
.
MergeFrom
(
withFieldSet
);
TestOptimizedForSize
built
=
builder
.
Build
();
Assert
.
AreEqual
(
10
,
built
.
I
);
}
[
Test
]
public
void
UninitializedExtensionInOptimizedForSizeMakesMessageUninitialized
()
{
TestOptimizedForSize
.
Builder
builder
=
new
TestOptimizedForSize
.
Builder
();
builder
.
SetExtension
(
TestOptimizedForSize
.
TestExtension2
,
new
TestRequiredOptimizedForSize
.
Builder
().
BuildPartial
());
Assert
.
IsFalse
(
builder
.
IsInitialized
);
Assert
.
IsFalse
(
builder
.
BuildPartial
().
IsInitialized
);
builder
=
new
TestOptimizedForSize
.
Builder
();
builder
.
SetExtension
(
TestOptimizedForSize
.
TestExtension2
,
new
TestRequiredOptimizedForSize
.
Builder
{
X
=
10
}.
BuildPartial
());
Assert
.
IsTrue
(
builder
.
IsInitialized
);
Assert
.
IsTrue
(
builder
.
BuildPartial
().
IsInitialized
);
}
}
}
src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
View file @
20bfd9bf
...
...
@@ -17,15 +17,18 @@ namespace Google.ProtocolBuffers.TestProtos {
"Citnb29nbGUvcHJvdG9idWYvdW5pdHRlc3Rfb3B0aW1pemVfZm9yLnByb3Rv"
+
"EhFwcm90b2J1Zl91bml0dGVzdBokZ29vZ2xlL3Byb3RvYnVmL2NzaGFycF9v"
+
"cHRpb25zLnByb3RvGiBnb29nbGUvcHJvdG9idWYvZGVzY3JpcHRvci5wcm90"
+
"bxoeZ29vZ2xlL3Byb3RvYnVmL3VuaXR0ZXN0LnByb3RvIp
4B
ChRUZXN0T3B0"
+
"bxoeZ29vZ2xlL3Byb3RvYnVmL3VuaXR0ZXN0LnByb3RvIp
IC
ChRUZXN0T3B0"
+
"aW1pemVkRm9yU2l6ZRIJCgFpGAEgASgFEi4KA21zZxgTIAEoCzIhLnByb3Rv"
+
"YnVmX3VuaXR0ZXN0LkZvcmVpZ25NZXNzYWdlKgkI6AcQgICAgAIyQAoOdGVz"
+
"dF9leHRlbnNpb24SJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0T3B0aW1pemVk"
+
"Rm9yU2l6ZRjSCSABKAUiKQocVGVzdFJlcXVpcmVkT3B0aW1pemVkRm9yU2l6"
+
"ZRIJCgF4GAEgAigFIloKHFRlc3RPcHRpb25hbE9wdGltaXplZEZvclNpemUS"
+
"OgoBbxgBIAEoCzIvLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RSZXF1aXJlZE9w"
+
"dGltaXplZEZvclNpemVCR0gCguIJIUdvb2dsZS5Qcm90b2NvbEJ1ZmZlcnMu"
+
"VGVzdFByb3Rvc4riCRxVbml0VGVzdE9wdGltaXplRm9yUHJvdG9GaWxl"
),
"Rm9yU2l6ZRjSCSABKAUycgoPdGVzdF9leHRlbnNpb24yEicucHJvdG9idWZf"
+
"dW5pdHRlc3QuVGVzdE9wdGltaXplZEZvclNpemUY0wkgASgLMi8ucHJvdG9i"
+
"dWZfdW5pdHRlc3QuVGVzdFJlcXVpcmVkT3B0aW1pemVkRm9yU2l6ZSIpChxU"
+
"ZXN0UmVxdWlyZWRPcHRpbWl6ZWRGb3JTaXplEgkKAXgYASACKAUiWgocVGVz"
+
"dE9wdGlvbmFsT3B0aW1pemVkRm9yU2l6ZRI6CgFvGAEgASgLMi8ucHJvdG9i"
+
"dWZfdW5pdHRlc3QuVGVzdFJlcXVpcmVkT3B0aW1pemVkRm9yU2l6ZUJHSAKC"
+
"4gkhR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9ziuIJHFVuaXRU"
+
"ZXN0T3B0aW1pemVGb3JQcm90b0ZpbGU="
),
new
pbd
::
FileDescriptor
[]
{
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
CSharpOptions
.
Descriptor
,
global
::
Google
.
ProtocolBuffers
.
DescriptorProtos
.
DescriptorProtoFile
.
Descriptor
,
...
...
@@ -76,6 +79,8 @@ namespace Google.ProtocolBuffers.TestProtos {
public
static
readonly
pb
::
GeneratedExtensionBase
<
int
>
TestExtension
=
pb
::
GeneratedSingleExtension
<
int
>.
CreateInstance
(
Descriptor
.
Extensions
[
0
]);
public
static
readonly
pb
::
GeneratedExtensionBase
<
global
::
Google
.
ProtocolBuffers
.
TestProtos
.
TestRequiredOptimizedForSize
>
TestExtension2
=
pb
::
GeneratedSingleExtension
<
global
::
Google
.
ProtocolBuffers
.
TestProtos
.
TestRequiredOptimizedForSize
>.
CreateInstance
(
Descriptor
.
Extensions
[
1
]);
private
bool
hasI
;
private
int
i_
=
0
;
public
bool
HasI
{
...
...
src/ProtocolBuffers/GeneratedBuilder.cs
View file @
20bfd9bf
...
...
@@ -113,7 +113,7 @@ namespace Google.ProtocolBuffers {
throw
new
ArgumentException
(
"Message type mismatch"
);
}
foreach
(
KeyValuePair
<
FieldDescriptor
,
object
>
entry
in
AllFields
)
{
foreach
(
KeyValuePair
<
FieldDescriptor
,
object
>
entry
in
other
.
AllFields
)
{
FieldDescriptor
field
=
entry
.
Key
;
if
(
field
.
IsRepeated
)
{
// Concatenate repeated fields
...
...
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