From 68380f0f6681c72a5d4ab5e69abc9670e9d99838 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 30 Jul 2015 13:03:45 +0100 Subject: Rename ThrowHelper to Preconditions and make it public - we'll want to use it from the generated code soon. Additionally, change it to return the value passed, and make it generic with a class constraint. A separate method doesn't have the class constraint, for more unusual scenarios. --- csharp/src/Google.Protobuf/Collections/MapField.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'csharp/src/Google.Protobuf/Collections') 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> 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> node; var pair = new KeyValuePair(key, value); @@ -187,7 +187,7 @@ namespace Google.Protobuf.Collections public void Add(IDictionary 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; -- cgit v1.2.3