aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers/GeneratedBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ProtocolBuffers/GeneratedBuilder.cs')
-rw-r--r--src/ProtocolBuffers/GeneratedBuilder.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ProtocolBuffers/GeneratedBuilder.cs b/src/ProtocolBuffers/GeneratedBuilder.cs
index 90767929..c678d66f 100644
--- a/src/ProtocolBuffers/GeneratedBuilder.cs
+++ b/src/ProtocolBuffers/GeneratedBuilder.cs
@@ -78,7 +78,13 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// Adds all of the specified values to the given collection.
/// </summary>
+ /// <exception cref="ArgumentNullException">Any element of the list is null</exception>
protected void AddRange<T>(IEnumerable<T> source, IList<T> destination) {
+ ThrowHelper.ThrowIfNull(source);
+ // We only need to check this for nullable types.
+ if (default(T) == null) {
+ ThrowHelper.ThrowIfAnyNull(source);
+ }
List<T> list = destination as List<T>;
if (list != null) {
list.AddRange(source);