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
b053b921
Commit
b053b921
authored
Jul 01, 2016
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement RepeatedField.AddRange.
This fixes issue #1730.
parent
d9334ea8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
RepeatedFieldTest.cs
...src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
+10
-0
RepeatedField.cs
csharp/src/Google.Protobuf/Collections/RepeatedField.cs
+13
-1
No files found.
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
View file @
b053b921
...
...
@@ -74,6 +74,16 @@ namespace Google.Protobuf.Collections
Assert
.
AreEqual
(
"bar"
,
list
[
1
]);
}
[
Test
]
public
void
AddRange
()
{
var
list
=
new
RepeatedField
<
string
>();
list
.
AddRange
(
new
[]
{
"foo"
,
"bar"
});
Assert
.
AreEqual
(
2
,
list
.
Count
);
Assert
.
AreEqual
(
"foo"
,
list
[
0
]);
Assert
.
AreEqual
(
"bar"
,
list
[
1
]);
}
[
Test
]
public
void
Add_RepeatedField
()
{
...
...
csharp/src/Google.Protobuf/Collections/RepeatedField.cs
View file @
b053b921
...
...
@@ -307,7 +307,7 @@ namespace Google.Protobuf.Collections
/// Adds all of the specified values into this collection.
/// </summary>
/// <param name="values">The values to add to this collection.</param>
public
void
Add
(
IEnumerable
<
T
>
values
)
public
void
Add
Range
(
IEnumerable
<
T
>
values
)
{
ProtoPreconditions
.
CheckNotNull
(
values
,
nameof
(
values
));
// TODO: Check for ICollection and get the Count, to optimize?
...
...
@@ -317,6 +317,18 @@ namespace Google.Protobuf.Collections
}
}
/// <summary>
/// Adds all of the specified values into this collection. This method is present to
/// allow repeated fields to be constructed from queries within collection initializers.
/// Within non-collection-initializer code, consider using the equivalent <see cref="AddRange"/>
/// method instead for clarity.
/// </summary>
/// <param name="values">The values to add to this collection.</param>
public
void
Add
(
IEnumerable
<
T
>
values
)
{
AddRange
(
values
);
}
/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
...
...
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