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
bd29f868
Commit
bd29f868
authored
Feb 06, 2017
by
Jon Skeet
Committed by
Jon Skeet
Feb 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CopyTo argument validation
Fixes #2669.
parent
39756643
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
MapFieldTest.cs
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
+16
-0
MapField.cs
csharp/src/Google.Protobuf/Collections/MapField.cs
+2
-2
No files found.
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
View file @
bd29f868
...
...
@@ -498,6 +498,14 @@ namespace Google.Protobuf.Collections
Assert
.
Throws
<
ArgumentNullException
>(()
=>
keys
.
Contains
(
null
));
}
[
Test
]
public
void
KeysCopyTo
()
{
var
map
=
new
MapField
<
string
,
string
>
{
{
"foo"
,
"bar"
},
{
"x"
,
"y"
}
};
var
keys
=
map
.
Keys
.
ToArray
();
// Uses CopyTo internally
CollectionAssert
.
AreEquivalent
(
new
[]
{
"foo"
,
"x"
},
keys
);
}
[
Test
]
public
void
ValuesContains
()
{
...
...
@@ -510,6 +518,14 @@ namespace Google.Protobuf.Collections
Assert
.
IsFalse
(
values
.
Contains
(
null
));
}
[
Test
]
public
void
ValuesCopyTo
()
{
var
map
=
new
MapField
<
string
,
string
>
{
{
"foo"
,
"bar"
},
{
"x"
,
"y"
}
};
var
values
=
map
.
Values
.
ToArray
();
// Uses CopyTo internally
CollectionAssert
.
AreEquivalent
(
new
[]
{
"bar"
,
"y"
},
values
);
}
[
Test
]
public
void
ToString_StringToString
()
{
...
...
csharp/src/Google.Protobuf/Collections/MapField.cs
View file @
bd29f868
...
...
@@ -715,7 +715,7 @@ namespace Google.Protobuf.Collections
{
throw
new
ArgumentOutOfRangeException
(
nameof
(
arrayIndex
));
}
if
(
arrayIndex
+
Count
>=
array
.
Length
)
if
(
arrayIndex
+
Count
>
array
.
Length
)
{
throw
new
ArgumentException
(
"Not enough space in the array"
,
nameof
(
array
));
}
...
...
@@ -746,7 +746,7 @@ namespace Google.Protobuf.Collections
{
throw
new
ArgumentOutOfRangeException
(
nameof
(
index
));
}
if
(
index
+
Count
>
=
array
.
Length
)
if
(
index
+
Count
>
array
.
Length
)
{
throw
new
ArgumentException
(
"Not enough space in the array"
,
nameof
(
array
));
}
...
...
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