You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/04/21 18:19:27 UTC

[avro] branch branch-1.11 updated: AVRO-3490 Updated to use throw expressions (#1644)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new 36126feb6 AVRO-3490 Updated to use throw expressions (#1644)
36126feb6 is described below

commit 36126feb661484f4c33e2091b9145b236a77e572
Author: Kyle Schoonover <ky...@minmaxcorp.com>
AuthorDate: Thu Apr 21 11:19:00 2022 -0700

    AVRO-3490 Updated to use throw expressions (#1644)
    
    * AVRO-3360 Updated XML documentation
    
    * Revert "AVRO-3360 Updated XML documentation"
    
    This reverts commit b8601c072a5083380d30b580804dd0908b8cf4cc.
    
    * AVRO-3490 Updated to use throw expressions
    
    * Additional expressions
    
    Co-authored-by: Kyle T. Schoonover <Ky...@nordstrom.com>
    (cherry picked from commit cf373f2926e3e8e87b6aefe731d991611e65c95c)
---
 lang/csharp/src/apache/main/Schema/ArraySchema.cs  |  3 +-
 lang/csharp/src/apache/main/Schema/Field.cs        | 33 ++++++++++++----------
 .../csharp/src/apache/main/Schema/LogicalSchema.cs |  3 +-
 lang/csharp/src/apache/main/Schema/MapSchema.cs    |  3 +-
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/lang/csharp/src/apache/main/Schema/ArraySchema.cs b/lang/csharp/src/apache/main/Schema/ArraySchema.cs
index 03a331289..7c4d8e1a9 100644
--- a/lang/csharp/src/apache/main/Schema/ArraySchema.cs
+++ b/lang/csharp/src/apache/main/Schema/ArraySchema.cs
@@ -66,8 +66,7 @@ namespace Avro
         private ArraySchema(Schema items, PropertyMap customAttributes)
             : base(Type.Array, customAttributes)
         {
-            if (null == items) throw new ArgumentNullException(nameof(items));
-            this.ItemSchema = items;
+            ItemSchema = items ?? throw new ArgumentNullException(nameof(items));
         }
 
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Schema/Field.cs b/lang/csharp/src/apache/main/Schema/Field.cs
index 08ea03305..0c3f7afca 100644
--- a/lang/csharp/src/apache/main/Schema/Field.cs
+++ b/lang/csharp/src/apache/main/Schema/Field.cs
@@ -138,12 +138,7 @@ namespace Avro
         }
 
         /// <summary>
-        /// A flag to indicate if reader schema has a field that is missing from writer schema and has a default value
-        /// This is set in CanRead() which is always be called before deserializing data
-        /// </summary>
-
-        /// <summary>
-        /// Constructor for the field class
+        /// Initializes a new instance of the <see cref="Field"/> class.
         /// </summary>
         /// <param name="schema">schema for the field type</param>
         /// <param name="name">name of the field</param>
@@ -153,21 +148,29 @@ namespace Avro
         /// <param name="defaultValue">field's default value if it exists</param>
         /// <param name="sortorder">sort order of the field</param>
         /// <param name="props">dictionary that provides access to custom properties</param>
+        /// <exception cref="ArgumentNullException">
+        /// name - name cannot be null.
+        /// or
+        /// type - type cannot be null.
+        /// </exception>
         internal Field(Schema schema, string name, IList<string> aliases, int pos, string doc,
                         JToken defaultValue, SortOrder sortorder, PropertyMap props)
         {
-            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "name cannot be null.");
-            if (null == schema) throw new ArgumentNullException("type", "type cannot be null.");
-            this.Schema = schema;
-            this.Name = name;
+            if (string.IsNullOrEmpty(name))
+            {
+                throw new ArgumentNullException(nameof(name), "name cannot be null.");
+            }
+
+            Schema = schema ?? throw new ArgumentNullException("type", "type cannot be null.");
+            Name = name;
 #pragma warning disable CS0618 // Type or member is obsolete
             this.aliases = aliases;
 #pragma warning restore CS0618 // Type or member is obsolete
-            this.Pos = pos;
-            this.Documentation = doc;
-            this.DefaultValue = defaultValue;
-            this.Ordering = sortorder;
-            this.Props = props;
+            Pos = pos;
+            Documentation = doc;
+            DefaultValue = defaultValue;
+            Ordering = sortorder;
+            Props = props;
         }
 
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Schema/LogicalSchema.cs b/lang/csharp/src/apache/main/Schema/LogicalSchema.cs
index 3c1928ee4..0f23bdf4d 100644
--- a/lang/csharp/src/apache/main/Schema/LogicalSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/LogicalSchema.cs
@@ -52,8 +52,7 @@ namespace Avro
 
         private LogicalSchema(Schema baseSchema, string logicalTypeName,  PropertyMap props) : base(Type.Logical, props)
         {
-            if (null == baseSchema) throw new ArgumentNullException(nameof(baseSchema));
-            BaseSchema = baseSchema;
+            BaseSchema = baseSchema ?? throw new ArgumentNullException(nameof(baseSchema));
             LogicalTypeName = logicalTypeName;
             LogicalType = LogicalTypeFactory.Instance.GetFromLogicalSchema(this);
         }
diff --git a/lang/csharp/src/apache/main/Schema/MapSchema.cs b/lang/csharp/src/apache/main/Schema/MapSchema.cs
index d9f4995ab..a1a6a4222 100644
--- a/lang/csharp/src/apache/main/Schema/MapSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/MapSchema.cs
@@ -73,8 +73,7 @@ namespace Avro
         private MapSchema(Schema valueSchema, PropertyMap cutsomProperties)
             : base(Type.Map, cutsomProperties)
         {
-            if (null == valueSchema) throw new ArgumentNullException(nameof(valueSchema), "valueSchema cannot be null.");
-            this.ValueSchema = valueSchema;
+            ValueSchema = valueSchema ?? throw new ArgumentNullException(nameof(valueSchema), "valueSchema cannot be null.");
         }
 
         /// <summary>