From 7762f163a4150772be9a0eae3a285ff9b1eb3246 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 4 Feb 2016 06:51:54 +0000 Subject: Rename Preconditions to ProtoPreconditions (Generated code changes in next commit.) --- Makefile.am | 2 +- csharp/src/Google.Protobuf/CodedInputStream.cs | 6 +- csharp/src/Google.Protobuf/Collections/MapField.cs | 16 ++--- csharp/src/Google.Protobuf/Google.Protobuf.csproj | 2 +- csharp/src/Google.Protobuf/JsonFormatter.cs | 6 +- csharp/src/Google.Protobuf/JsonParser.cs | 14 ++-- csharp/src/Google.Protobuf/MessageExtensions.cs | 28 ++++---- csharp/src/Google.Protobuf/MessageParser.cs | 8 +-- csharp/src/Google.Protobuf/Preconditions.cs | 74 -------------------- csharp/src/Google.Protobuf/ProtoPreconditions.cs | 79 ++++++++++++++++++++++ .../src/Google.Protobuf/Reflection/Descriptor.cs | 54 +++++++-------- .../src/Google.Protobuf/Reflection/TypeRegistry.cs | 4 +- .../Google.Protobuf/WellKnownTypes/AnyPartial.cs | 2 +- .../WellKnownTypes/DurationPartial.cs | 10 +-- .../WellKnownTypes/TimestampPartial.cs | 12 ++-- .../Google.Protobuf/WellKnownTypes/ValuePartial.cs | 6 +- .../compiler/csharp/csharp_primitive_field.cc | 4 +- 17 files changed, 166 insertions(+), 161 deletions(-) delete mode 100644 csharp/src/Google.Protobuf/Preconditions.cs create mode 100644 csharp/src/Google.Protobuf/ProtoPreconditions.cs diff --git a/Makefile.am b/Makefile.am index c7267e02..fbd27fc5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -133,7 +133,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/LimitedInputStream.cs \ csharp/src/Google.Protobuf/MessageExtensions.cs \ csharp/src/Google.Protobuf/MessageParser.cs \ - csharp/src/Google.Protobuf/Preconditions.cs \ + csharp/src/Google.Protobuf/ProtoPreconditions.cs \ csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs \ csharp/src/Google.Protobuf/Reflection/Descriptor.cs \ csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs \ diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs index 65d0e710..91bed8e3 100644 --- a/csharp/src/Google.Protobuf/CodedInputStream.cs +++ b/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -115,7 +115,7 @@ namespace Google.Protobuf /// /// Creates a new CodedInputStream reading data from the given byte array. /// - public CodedInputStream(byte[] buffer) : this(null, Preconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length) + public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length) { } @@ -123,7 +123,7 @@ namespace Google.Protobuf /// Creates a new CodedInputStream that reads from the given byte array slice. /// public CodedInputStream(byte[] buffer, int offset, int length) - : this(null, Preconditions.CheckNotNull(buffer, "buffer"), offset, offset + length) + : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length) { if (offset < 0 || offset > buffer.Length) { @@ -140,7 +140,7 @@ namespace Google.Protobuf /// public CodedInputStream(Stream input) : this(input, new byte[BufferSize], 0, 0) { - Preconditions.CheckNotNull(input, "input"); + ProtoPreconditions.CheckNotNull(input, "input"); } /// diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 04754ae3..90a5ff1a 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -123,7 +123,7 @@ namespace Google.Protobuf.Collections /// true if the map contains the given key; false otherwise. public bool ContainsKey(TKey key) { - Preconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); return map.ContainsKey(key); } @@ -140,7 +140,7 @@ namespace Google.Protobuf.Collections /// true if the map contained the given key before the entry was removed; false otherwise. public bool Remove(TKey key) { - Preconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); LinkedListNode> node; if (map.TryGetValue(key, out node)) { @@ -188,7 +188,7 @@ namespace Google.Protobuf.Collections { get { - Preconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); TValue value; if (TryGetValue(key, out value)) { @@ -198,11 +198,11 @@ namespace Google.Protobuf.Collections } set { - Preconditions.CheckNotNullUnconstrained(key, "key"); + ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); // value == null check here is redundant, but avoids boxing. if (value == null) { - Preconditions.CheckNotNullUnconstrained(value, "value"); + ProtoPreconditions.CheckNotNullUnconstrained(value, "value"); } LinkedListNode> node; var pair = new KeyValuePair(key, value); @@ -234,7 +234,7 @@ namespace Google.Protobuf.Collections /// The entries to add to the map. public void Add(IDictionary entries) { - Preconditions.CheckNotNull(entries, "entries"); + ProtoPreconditions.CheckNotNull(entries, "entries"); foreach (var pair in entries) { Add(pair.Key, pair.Value); @@ -501,7 +501,7 @@ namespace Google.Protobuf.Collections void IDictionary.Remove(object key) { - Preconditions.CheckNotNull(key, "key"); + ProtoPreconditions.CheckNotNull(key, "key"); if (!(key is TKey)) { return; @@ -530,7 +530,7 @@ namespace Google.Protobuf.Collections { get { - Preconditions.CheckNotNull(key, "key"); + ProtoPreconditions.CheckNotNull(key, "key"); if (!(key is TKey)) { return null; diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 326b6d31..45ef8c63 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -123,7 +123,7 @@ - + diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs index 17495747..60f61fc8 100644 --- a/csharp/src/Google.Protobuf/JsonFormatter.cs +++ b/csharp/src/Google.Protobuf/JsonFormatter.cs @@ -141,7 +141,7 @@ namespace Google.Protobuf /// The formatted message. public string Format(IMessage message) { - Preconditions.CheckNotNull(message, nameof(message)); + ProtoPreconditions.CheckNotNull(message, nameof(message)); StringBuilder builder = new StringBuilder(); if (message.Descriptor.IsWellKnownType) { @@ -173,7 +173,7 @@ namespace Google.Protobuf /// The diagnostic-only JSON representation of the message public static string ToDiagnosticString(IMessage message) { - Preconditions.CheckNotNull(message, nameof(message)); + ProtoPreconditions.CheckNotNull(message, nameof(message)); return diagnosticFormatter.Format(message); } @@ -858,7 +858,7 @@ namespace Google.Protobuf public Settings(bool formatDefaultValues, TypeRegistry typeRegistry) { FormatDefaultValues = formatDefaultValues; - TypeRegistry = Preconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); + TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); } } } diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index c07b16ea..80d3013d 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -374,7 +374,7 @@ namespace Google.Protobuf /// The JSON does not represent a Protocol Buffers message correctly public T Parse(string json) where T : IMessage, new() { - Preconditions.CheckNotNull(json, nameof(json)); + ProtoPreconditions.CheckNotNull(json, nameof(json)); return Parse(new StringReader(json)); } @@ -387,7 +387,7 @@ namespace Google.Protobuf /// The JSON does not represent a Protocol Buffers message correctly public T Parse(TextReader jsonReader) where T : IMessage, new() { - Preconditions.CheckNotNull(jsonReader, nameof(jsonReader)); + ProtoPreconditions.CheckNotNull(jsonReader, nameof(jsonReader)); T message = new T(); Merge(message, jsonReader); return message; @@ -402,8 +402,8 @@ namespace Google.Protobuf /// The JSON does not represent a Protocol Buffers message correctly public IMessage Parse(string json, MessageDescriptor descriptor) { - Preconditions.CheckNotNull(json, nameof(json)); - Preconditions.CheckNotNull(descriptor, nameof(descriptor)); + ProtoPreconditions.CheckNotNull(json, nameof(json)); + ProtoPreconditions.CheckNotNull(descriptor, nameof(descriptor)); return Parse(new StringReader(json), descriptor); } @@ -416,8 +416,8 @@ namespace Google.Protobuf /// The JSON does not represent a Protocol Buffers message correctly public IMessage Parse(TextReader jsonReader, MessageDescriptor descriptor) { - Preconditions.CheckNotNull(jsonReader, nameof(jsonReader)); - Preconditions.CheckNotNull(descriptor, nameof(descriptor)); + ProtoPreconditions.CheckNotNull(jsonReader, nameof(jsonReader)); + ProtoPreconditions.CheckNotNull(descriptor, nameof(descriptor)); IMessage message = descriptor.Parser.CreateTemplate(); Merge(message, jsonReader); return message; @@ -1011,7 +1011,7 @@ namespace Google.Protobuf public Settings(int recursionLimit, TypeRegistry typeRegistry) { RecursionLimit = recursionLimit; - TypeRegistry = Preconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); + TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); } } } diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs index d2d057c0..047156c3 100644 --- a/csharp/src/Google.Protobuf/MessageExtensions.cs +++ b/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -46,8 +46,8 @@ namespace Google.Protobuf /// The data to merge, which must be protobuf-encoded binary data. public static void MergeFrom(this IMessage message, byte[] data) { - Preconditions.CheckNotNull(message, "message"); - Preconditions.CheckNotNull(data, "data"); + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(data, "data"); CodedInputStream input = new CodedInputStream(data); message.MergeFrom(input); input.CheckReadEndOfStreamTag(); @@ -60,8 +60,8 @@ namespace Google.Protobuf /// The data to merge, which must be protobuf-encoded binary data. public static void MergeFrom(this IMessage message, ByteString data) { - Preconditions.CheckNotNull(message, "message"); - Preconditions.CheckNotNull(data, "data"); + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(data, "data"); CodedInputStream input = data.CreateCodedInput(); message.MergeFrom(input); input.CheckReadEndOfStreamTag(); @@ -74,8 +74,8 @@ namespace Google.Protobuf /// Stream containing the data to merge, which must be protobuf-encoded binary data. public static void MergeFrom(this IMessage message, Stream input) { - Preconditions.CheckNotNull(message, "message"); - Preconditions.CheckNotNull(input, "input"); + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(input, "input"); CodedInputStream codedInput = new CodedInputStream(input); message.MergeFrom(codedInput); codedInput.CheckReadEndOfStreamTag(); @@ -92,8 +92,8 @@ namespace Google.Protobuf /// Stream containing the data to merge, which must be protobuf-encoded binary data. public static void MergeDelimitedFrom(this IMessage message, Stream input) { - Preconditions.CheckNotNull(message, "message"); - Preconditions.CheckNotNull(input, "input"); + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(input, "input"); int size = (int) CodedInputStream.ReadRawVarint32(input); Stream limitedStream = new LimitedInputStream(input, size); message.MergeFrom(limitedStream); @@ -106,7 +106,7 @@ namespace Google.Protobuf /// The message data as a byte array. public static byte[] ToByteArray(this IMessage message) { - Preconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(message, "message"); byte[] result = new byte[message.CalculateSize()]; CodedOutputStream output = new CodedOutputStream(result); message.WriteTo(output); @@ -121,8 +121,8 @@ namespace Google.Protobuf /// The stream to write to. public static void WriteTo(this IMessage message, Stream output) { - Preconditions.CheckNotNull(message, "message"); - Preconditions.CheckNotNull(output, "output"); + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(output, "output"); CodedOutputStream codedOutput = new CodedOutputStream(output); message.WriteTo(codedOutput); codedOutput.Flush(); @@ -135,8 +135,8 @@ namespace Google.Protobuf /// The output stream to write to. public static void WriteDelimitedTo(this IMessage message, Stream output) { - Preconditions.CheckNotNull(message, "message"); - Preconditions.CheckNotNull(output, "output"); + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(output, "output"); CodedOutputStream codedOutput = new CodedOutputStream(output); codedOutput.WriteRawVarint32((uint)message.CalculateSize()); message.WriteTo(codedOutput); @@ -150,7 +150,7 @@ namespace Google.Protobuf /// The message data as a byte string. public static ByteString ToByteString(this IMessage message) { - Preconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(message, "message"); return ByteString.AttachBytes(message.ToByteArray()); } } diff --git a/csharp/src/Google.Protobuf/MessageParser.cs b/csharp/src/Google.Protobuf/MessageParser.cs index 81be3c2a..8889638b 100644 --- a/csharp/src/Google.Protobuf/MessageParser.cs +++ b/csharp/src/Google.Protobuf/MessageParser.cs @@ -64,7 +64,7 @@ namespace Google.Protobuf /// The newly parsed message. public IMessage ParseFrom(byte[] data) { - Preconditions.CheckNotNull(data, "data"); + ProtoPreconditions.CheckNotNull(data, "data"); IMessage message = factory(); message.MergeFrom(data); return message; @@ -77,7 +77,7 @@ namespace Google.Protobuf /// The parsed message. public IMessage ParseFrom(ByteString data) { - Preconditions.CheckNotNull(data, "data"); + ProtoPreconditions.CheckNotNull(data, "data"); IMessage message = factory(); message.MergeFrom(data); return message; @@ -191,7 +191,7 @@ namespace Google.Protobuf /// The newly parsed message. public new T ParseFrom(byte[] data) { - Preconditions.CheckNotNull(data, "data"); + ProtoPreconditions.CheckNotNull(data, "data"); T message = factory(); message.MergeFrom(data); return message; @@ -204,7 +204,7 @@ namespace Google.Protobuf /// The parsed message. public new T ParseFrom(ByteString data) { - Preconditions.CheckNotNull(data, "data"); + ProtoPreconditions.CheckNotNull(data, "data"); T message = factory(); message.MergeFrom(data); return message; diff --git a/csharp/src/Google.Protobuf/Preconditions.cs b/csharp/src/Google.Protobuf/Preconditions.cs deleted file mode 100644 index 2db35ff6..00000000 --- a/csharp/src/Google.Protobuf/Preconditions.cs +++ /dev/null @@ -1,74 +0,0 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; - -namespace Google.Protobuf -{ - /// - /// Helper methods for throwing exceptions - /// - public static class Preconditions - { - /// - /// Throws an ArgumentNullException if the given value is null, otherwise - /// return the value to the caller. - /// - public static T CheckNotNull(T value, string name) where T : class - { - if (value == null) - { - throw new ArgumentNullException(name); - } - return value; - } - - /// - /// Throws an ArgumentNullException if the given value is null, otherwise - /// return the value to the caller. - /// - /// - /// This is equivalent to but without the type parameter - /// constraint. In most cases, the constraint is useful to prevent you from calling CheckNotNull - /// with a value type - but it gets in the way if either you want to use it with a nullable - /// value type, or you want to use it with an unconstrained type parameter. - /// - internal static T CheckNotNullUnconstrained(T value, string name) - { - if (value == null) - { - throw new ArgumentNullException(name); - } - return value; - } - } -} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ProtoPreconditions.cs b/csharp/src/Google.Protobuf/ProtoPreconditions.cs new file mode 100644 index 00000000..abaeb9b4 --- /dev/null +++ b/csharp/src/Google.Protobuf/ProtoPreconditions.cs @@ -0,0 +1,79 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf +{ + /// + /// Helper methods for throwing exceptions when preconditions are not met. + /// + /// + /// This class is used internally and by generated code; it is not particularly + /// expected to be used from application code, although nothing prevents it + /// from being used that way. + /// + public static class ProtoPreconditions + { + /// + /// Throws an ArgumentNullException if the given value is null, otherwise + /// return the value to the caller. + /// + public static T CheckNotNull(T value, string name) where T : class + { + if (value == null) + { + throw new ArgumentNullException(name); + } + return value; + } + + /// + /// Throws an ArgumentNullException if the given value is null, otherwise + /// return the value to the caller. + /// + /// + /// This is equivalent to but without the type parameter + /// constraint. In most cases, the constraint is useful to prevent you from calling CheckNotNull + /// with a value type - but it gets in the way if either you want to use it with a nullable + /// value type, or you want to use it with an unconstrained type parameter. + /// + internal static T CheckNotNullUnconstrained(T value, string name) + { + if (value == null) + { + throw new ArgumentNullException(name); + } + return value; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index aac7994d..9680b5fd 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -317,7 +317,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -330,7 +330,7 @@ namespace Google.Protobuf.Reflection { public string Package { get { return package_; } set { - package_ = pb::Preconditions.CheckNotNull(value, "value"); + package_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -446,7 +446,7 @@ namespace Google.Protobuf.Reflection { public string Syntax { get { return syntax_; } set { - syntax_ = pb::Preconditions.CheckNotNull(value, "value"); + syntax_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -702,7 +702,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1275,7 +1275,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1326,7 +1326,7 @@ namespace Google.Protobuf.Reflection { public string TypeName { get { return typeName_; } set { - typeName_ = pb::Preconditions.CheckNotNull(value, "value"); + typeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1340,7 +1340,7 @@ namespace Google.Protobuf.Reflection { public string Extendee { get { return extendee_; } set { - extendee_ = pb::Preconditions.CheckNotNull(value, "value"); + extendee_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1357,7 +1357,7 @@ namespace Google.Protobuf.Reflection { public string DefaultValue { get { return defaultValue_; } set { - defaultValue_ = pb::Preconditions.CheckNotNull(value, "value"); + defaultValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1387,7 +1387,7 @@ namespace Google.Protobuf.Reflection { public string JsonName { get { return jsonName_; } set { - jsonName_ = pb::Preconditions.CheckNotNull(value, "value"); + jsonName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1720,7 +1720,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1828,7 +1828,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -1986,7 +1986,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2152,7 +2152,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2313,7 +2313,7 @@ namespace Google.Protobuf.Reflection { public string Name { get { return name_; } set { - name_ = pb::Preconditions.CheckNotNull(value, "value"); + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2327,7 +2327,7 @@ namespace Google.Protobuf.Reflection { public string InputType { get { return inputType_; } set { - inputType_ = pb::Preconditions.CheckNotNull(value, "value"); + inputType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2337,7 +2337,7 @@ namespace Google.Protobuf.Reflection { public string OutputType { get { return outputType_; } set { - outputType_ = pb::Preconditions.CheckNotNull(value, "value"); + outputType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2583,7 +2583,7 @@ namespace Google.Protobuf.Reflection { public string JavaPackage { get { return javaPackage_; } set { - javaPackage_ = pb::Preconditions.CheckNotNull(value, "value"); + javaPackage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2600,7 +2600,7 @@ namespace Google.Protobuf.Reflection { public string JavaOuterClassname { get { return javaOuterClassname_; } set { - javaOuterClassname_ = pb::Preconditions.CheckNotNull(value, "value"); + javaOuterClassname_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2687,7 +2687,7 @@ namespace Google.Protobuf.Reflection { public string GoPackage { get { return goPackage_; } set { - goPackage_ = pb::Preconditions.CheckNotNull(value, "value"); + goPackage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2773,7 +2773,7 @@ namespace Google.Protobuf.Reflection { public string ObjcClassPrefix { get { return objcClassPrefix_; } set { - objcClassPrefix_ = pb::Preconditions.CheckNotNull(value, "value"); + objcClassPrefix_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -2786,7 +2786,7 @@ namespace Google.Protobuf.Reflection { public string CsharpNamespace { get { return csharpNamespace_; } set { - csharpNamespace_ = pb::Preconditions.CheckNotNull(value, "value"); + csharpNamespace_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -4369,7 +4369,7 @@ namespace Google.Protobuf.Reflection { public string IdentifierValue { get { return identifierValue_; } set { - identifierValue_ = pb::Preconditions.CheckNotNull(value, "value"); + identifierValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -4409,7 +4409,7 @@ namespace Google.Protobuf.Reflection { public pb::ByteString StringValue { get { return stringValue_; } set { - stringValue_ = pb::Preconditions.CheckNotNull(value, "value"); + stringValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -4419,7 +4419,7 @@ namespace Google.Protobuf.Reflection { public string AggregateValue { get { return aggregateValue_; } set { - aggregateValue_ = pb::Preconditions.CheckNotNull(value, "value"); + aggregateValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -4621,7 +4621,7 @@ namespace Google.Protobuf.Reflection { public string NamePart_ { get { return namePart_; } set { - namePart_ = pb::Preconditions.CheckNotNull(value, "value"); + namePart_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -5004,7 +5004,7 @@ namespace Google.Protobuf.Reflection { public string LeadingComments { get { return leadingComments_; } set { - leadingComments_ = pb::Preconditions.CheckNotNull(value, "value"); + leadingComments_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } @@ -5014,7 +5014,7 @@ namespace Google.Protobuf.Reflection { public string TrailingComments { get { return trailingComments_; } set { - trailingComments_ = pb::Preconditions.CheckNotNull(value, "value"); + trailingComments_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } diff --git a/csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs b/csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs index 31d5a30f..e94e3e6c 100644 --- a/csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs +++ b/csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs @@ -91,7 +91,7 @@ namespace Google.Protobuf.Reflection /// A type registry for the given files. public static TypeRegistry FromFiles(IEnumerable fileDescriptors) { - Preconditions.CheckNotNull(fileDescriptors, nameof(fileDescriptors)); + ProtoPreconditions.CheckNotNull(fileDescriptors, nameof(fileDescriptors)); var builder = new Builder(); foreach (var file in fileDescriptors) { @@ -128,7 +128,7 @@ namespace Google.Protobuf.Reflection /// A type registry for the given files. public static TypeRegistry FromMessages(IEnumerable messageDescriptors) { - Preconditions.CheckNotNull(messageDescriptors, nameof(messageDescriptors)); + ProtoPreconditions.CheckNotNull(messageDescriptors, nameof(messageDescriptors)); return FromFiles(messageDescriptors.Select(md => md.File)); } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs index 082f7432..9d43856e 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs @@ -72,7 +72,7 @@ namespace Google.Protobuf.WellKnownTypes /// An Any message with the content and type URL of . public static Any Pack(IMessage message) { - Preconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(message, "message"); return new Any { TypeUrl = GetTypeUrl(message.Descriptor), Value = message.ToByteString() }; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs index e5247e90..f164bfd1 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs @@ -118,7 +118,7 @@ namespace Google.Protobuf.WellKnownTypes /// The negated value of this duration. public static Duration operator -(Duration value) { - Preconditions.CheckNotNull(value, "value"); + ProtoPreconditions.CheckNotNull(value, "value"); checked { return Normalize(-value.Seconds, -value.Nanos); @@ -133,8 +133,8 @@ namespace Google.Protobuf.WellKnownTypes /// public static Duration operator +(Duration lhs, Duration rhs) { - Preconditions.CheckNotNull(lhs, "lhs"); - Preconditions.CheckNotNull(rhs, "rhs"); + ProtoPreconditions.CheckNotNull(lhs, "lhs"); + ProtoPreconditions.CheckNotNull(rhs, "rhs"); checked { return Normalize(lhs.Seconds + rhs.Seconds, lhs.Nanos + rhs.Nanos); @@ -149,8 +149,8 @@ namespace Google.Protobuf.WellKnownTypes /// The difference between the two specified durations. public static Duration operator -(Duration lhs, Duration rhs) { - Preconditions.CheckNotNull(lhs, "lhs"); - Preconditions.CheckNotNull(rhs, "rhs"); + ProtoPreconditions.CheckNotNull(lhs, "lhs"); + ProtoPreconditions.CheckNotNull(rhs, "rhs"); checked { return Normalize(lhs.Seconds - rhs.Seconds, lhs.Nanos - rhs.Nanos); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs index 86998e27..aa403473 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs @@ -59,8 +59,8 @@ namespace Google.Protobuf.WellKnownTypes /// The difference between the two specified timestamps. public static Duration operator -(Timestamp lhs, Timestamp rhs) { - Preconditions.CheckNotNull(lhs, "lhs"); - Preconditions.CheckNotNull(rhs, "rhs"); + ProtoPreconditions.CheckNotNull(lhs, "lhs"); + ProtoPreconditions.CheckNotNull(rhs, "rhs"); checked { return Duration.Normalize(lhs.Seconds - rhs.Seconds, lhs.Nanos - rhs.Nanos); @@ -75,8 +75,8 @@ namespace Google.Protobuf.WellKnownTypes /// The result of adding the duration to the timestamp. public static Timestamp operator +(Timestamp lhs, Duration rhs) { - Preconditions.CheckNotNull(lhs, "lhs"); - Preconditions.CheckNotNull(rhs, "rhs"); + ProtoPreconditions.CheckNotNull(lhs, "lhs"); + ProtoPreconditions.CheckNotNull(rhs, "rhs"); checked { return Normalize(lhs.Seconds + rhs.Seconds, lhs.Nanos + rhs.Nanos); @@ -91,8 +91,8 @@ namespace Google.Protobuf.WellKnownTypes /// The result of subtracting the duration from the timestamp. public static Timestamp operator -(Timestamp lhs, Duration rhs) { - Preconditions.CheckNotNull(lhs, "lhs"); - Preconditions.CheckNotNull(rhs, "rhs"); + ProtoPreconditions.CheckNotNull(lhs, "lhs"); + ProtoPreconditions.CheckNotNull(rhs, "rhs"); checked { return Normalize(lhs.Seconds - rhs.Seconds, lhs.Nanos - rhs.Nanos); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs index b4b6c05e..d34b560d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs @@ -41,7 +41,7 @@ namespace Google.Protobuf.WellKnownTypes /// A newly-created Value message with the given value. public static Value ForString(string value) { - Preconditions.CheckNotNull(value, "value"); + ProtoPreconditions.CheckNotNull(value, "value"); return new Value { StringValue = value }; } @@ -81,7 +81,7 @@ namespace Google.Protobuf.WellKnownTypes /// A newly-created Value message an initial list value. public static Value ForList(params Value[] values) { - Preconditions.CheckNotNull(values, "values"); + ProtoPreconditions.CheckNotNull(values, "values"); return new Value { ListValue = new ListValue { Values = { values } } }; } @@ -92,7 +92,7 @@ namespace Google.Protobuf.WellKnownTypes /// A newly-created Value message an initial struct value. public static Value ForStruct(Struct value) { - Preconditions.CheckNotNull(value, "value"); + ProtoPreconditions.CheckNotNull(value, "value"); return new Value { StructValue = value }; } } diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 76d5b247..60afd892 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -83,7 +83,7 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { } else { printer->Print( variables_, - " $name$_ = pb::Preconditions.CheckNotNull(value, \"value\");\n"); + " $name$_ = pb::ProtoPreconditions.CheckNotNull(value, \"value\");\n"); } printer->Print( " }\n" @@ -186,7 +186,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { } else { printer->Print( variables_, - " $oneof_name$_ = pb::Preconditions.CheckNotNull(value, \"value\");\n"); + " $oneof_name$_ = pb::ProtoPreconditions.CheckNotNull(value, \"value\");\n"); } printer->Print( variables_, -- cgit v1.2.3