OLD | NEW |
1 #region Copyright notice and license | 1 #region Copyright notice and license |
2 // Protocol Buffers - Google's data interchange format | 2 // Protocol Buffers - Google's data interchange format |
3 // Copyright 2008 Google Inc. All rights reserved. | 3 // Copyright 2008 Google Inc. All rights reserved. |
4 // https://developers.google.com/protocol-buffers/ | 4 // https://developers.google.com/protocol-buffers/ |
5 // | 5 // |
6 // Redistribution and use in source and binary forms, with or without | 6 // Redistribution and use in source and binary forms, with or without |
7 // modification, are permitted provided that the following conditions are | 7 // modification, are permitted provided that the following conditions are |
8 // met: | 8 // met: |
9 // | 9 // |
10 // * Redistributions of source code must retain the above copyright | 10 // * Redistributions of source code must retain the above copyright |
(...skipping 17 matching lines...) Expand all Loading... |
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 #endregion | 31 #endregion |
32 | 32 |
33 using System; | 33 using System; |
34 | 34 |
35 namespace Google.Protobuf | 35 namespace Google.Protobuf |
36 { | 36 { |
37 /// <summary> | 37 /// <summary> |
38 /// Helper methods for throwing exceptions | 38 /// Helper methods for throwing exceptions when preconditions are not met. |
39 /// </summary> | 39 /// </summary> |
40 public static class Preconditions | 40 /// <remarks> |
| 41 /// This class is used internally and by generated code; it is not particula
rly |
| 42 /// expected to be used from application code, although nothing prevents it |
| 43 /// from being used that way. |
| 44 /// </remarks> |
| 45 public static class ProtoPreconditions |
41 { | 46 { |
42 /// <summary> | 47 /// <summary> |
43 /// Throws an ArgumentNullException if the given value is null, otherwis
e | 48 /// Throws an ArgumentNullException if the given value is null, otherwis
e |
44 /// return the value to the caller. | 49 /// return the value to the caller. |
45 /// </summary> | 50 /// </summary> |
46 public static T CheckNotNull<T>(T value, string name) where T : class | 51 public static T CheckNotNull<T>(T value, string name) where T : class |
47 { | 52 { |
48 if (value == null) | 53 if (value == null) |
49 { | 54 { |
50 throw new ArgumentNullException(name); | 55 throw new ArgumentNullException(name); |
(...skipping 14 matching lines...) Expand all Loading... |
65 internal static T CheckNotNullUnconstrained<T>(T value, string name) | 70 internal static T CheckNotNullUnconstrained<T>(T value, string name) |
66 { | 71 { |
67 if (value == null) | 72 if (value == null) |
68 { | 73 { |
69 throw new ArgumentNullException(name); | 74 throw new ArgumentNullException(name); |
70 } | 75 } |
71 return value; | 76 return value; |
72 } | 77 } |
73 } | 78 } |
74 } | 79 } |
OLD | NEW |