diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-07-30 11:49:27 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-07-30 11:49:27 -0700 |
commit | bde01d532610543072de3fd9f5d40823e1f1d53f (patch) | |
tree | 6e09e402e5422bc5959ec1032a9fb5b83f14d1e8 /csharp/src/Google.Protobuf/Collections | |
parent | 7909b2edeb19affdf3f96a0b13a8098f28860c3c (diff) | |
parent | d18cc0845606c32e01e044ae5411c7053b1c73ec (diff) |
Merge pull request #660 from jskeet/throw-on-null
Throw on null for string/bytes single fields
Diffstat (limited to 'csharp/src/Google.Protobuf/Collections')
-rw-r--r-- | csharp/src/Google.Protobuf/Collections/MapField.cs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 9f460e1e..fc94fd5c 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -112,13 +112,13 @@ namespace Google.Protobuf.Collections public bool ContainsKey(TKey key) { - ThrowHelper.ThrowIfNull(key, "key"); + Preconditions.CheckNotNullUnconstrained(key, "key"); return map.ContainsKey(key); } public bool Remove(TKey key) { - ThrowHelper.ThrowIfNull(key, "key"); + Preconditions.CheckNotNullUnconstrained(key, "key"); LinkedListNode<KeyValuePair<TKey, TValue>> node; if (map.TryGetValue(key, out node)) { @@ -151,7 +151,7 @@ namespace Google.Protobuf.Collections { get { - ThrowHelper.ThrowIfNull(key, "key"); + Preconditions.CheckNotNullUnconstrained(key, "key"); TValue value; if (TryGetValue(key, out value)) { @@ -161,11 +161,11 @@ namespace Google.Protobuf.Collections } set { - ThrowHelper.ThrowIfNull(key, "key"); + Preconditions.CheckNotNullUnconstrained(key, "key"); // value == null check here is redundant, but avoids boxing. if (value == null && !allowNullValues) { - ThrowHelper.ThrowIfNull(value, "value"); + Preconditions.CheckNotNullUnconstrained(value, "value"); } LinkedListNode<KeyValuePair<TKey, TValue>> node; var pair = new KeyValuePair<TKey, TValue>(key, value); @@ -187,7 +187,7 @@ namespace Google.Protobuf.Collections public void Add(IDictionary<TKey, TValue> entries) { - ThrowHelper.ThrowIfNull(entries, "entries"); + Preconditions.CheckNotNull(entries, "entries"); foreach (var pair in entries) { Add(pair.Key, pair.Value); @@ -374,7 +374,7 @@ namespace Google.Protobuf.Collections void IDictionary.Remove(object key) { - ThrowHelper.ThrowIfNull(key, "key"); + Preconditions.CheckNotNull(key, "key"); if (!(key is TKey)) { return; @@ -403,7 +403,7 @@ namespace Google.Protobuf.Collections { get { - ThrowHelper.ThrowIfNull(key, "key"); + Preconditions.CheckNotNull(key, "key"); if (!(key is TKey)) { return null; |