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
bf4f6c54
Commit
bf4f6c54
authored
May 06, 2019
by
Sydney Acksman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make extension reflection helper use GetOrRegisterExtension
parent
9163a6f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
FieldAccessTest.cs
...rp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
+14
-0
ReflectionUtil.cs
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
+1
-1
No files found.
csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
View file @
bf4f6c54
...
...
@@ -97,6 +97,20 @@ namespace Google.Protobuf.Reflection
Assert
.
AreEqual
(
message
.
GetExtension
(
OptionalBoolExtension
),
Proto2
.
TestAllExtensions
.
Descriptor
.
FindFieldByNumber
(
OptionalBoolExtension
.
FieldNumber
).
Accessor
.
GetValue
(
message
));
}
[
Test
]
public
void
GetRepeatedExtensionValue
()
{
// check to make sure repeated accessor uses GetOrRegister
var
message
=
new
Proto2
.
TestAllExtensions
();
Assert
.
IsNull
(
message
.
GetExtension
(
RepeatedBoolExtension
));
Assert
.
IsNotNull
(
Proto2
.
TestAllExtensions
.
Descriptor
.
FindFieldByNumber
(
RepeatedBoolExtension
.
FieldNumber
).
Accessor
.
GetValue
(
message
));
Assert
.
IsNotNull
(
message
.
GetExtension
(
RepeatedBoolExtension
));
message
.
ClearExtension
(
RepeatedBoolExtension
);
Assert
.
IsNull
(
message
.
GetExtension
(
RepeatedBoolExtension
));
}
[
Test
]
public
void
Clear
()
{
...
...
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
View file @
bf4f6c54
...
...
@@ -230,7 +230,7 @@ namespace Google.Protobuf.Reflection
}
else
if
(
extension
is
RepeatedExtension
<
T1
,
T3
>)
{
return
extensionMessage
.
GetExtension
(
extension
as
RepeatedExtension
<
T1
,
T3
>);
return
extensionMessage
.
Get
OrRegister
Extension
(
extension
as
RepeatedExtension
<
T1
,
T3
>);
}
else
{
...
...
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