diff --git a/lang/csharp/src/apache/main/Schema/ArraySchema.cs b/lang/csharp/src/apache/main/Schema/ArraySchema.cs index 03a331289aa..7c4d8e1a9c8 100644 --- a/lang/csharp/src/apache/main/Schema/ArraySchema.cs +++ b/lang/csharp/src/apache/main/Schema/ArraySchema.cs @@ -66,8 +66,7 @@ public static ArraySchema Create(Schema items, PropertyMap customAttributes = nu 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)); } /// diff --git a/lang/csharp/src/apache/main/Schema/Field.cs b/lang/csharp/src/apache/main/Schema/Field.cs index 08ea03305d7..0c3f7afcaee 100644 --- a/lang/csharp/src/apache/main/Schema/Field.cs +++ b/lang/csharp/src/apache/main/Schema/Field.cs @@ -138,12 +138,7 @@ internal Field ChangePosition(int newPosition) } /// - /// 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 - /// - - /// - /// Constructor for the field class + /// Initializes a new instance of the class. /// /// schema for the field type /// name of the field @@ -153,21 +148,29 @@ internal Field ChangePosition(int newPosition) /// field's default value if it exists /// sort order of the field /// dictionary that provides access to custom properties + /// + /// name - name cannot be null. + /// or + /// type - type cannot be null. + /// internal Field(Schema schema, string name, IList 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; } /// diff --git a/lang/csharp/src/apache/main/Schema/LogicalSchema.cs b/lang/csharp/src/apache/main/Schema/LogicalSchema.cs index 3c1928ee47f..0f23bdf4dfe 100644 --- a/lang/csharp/src/apache/main/Schema/LogicalSchema.cs +++ b/lang/csharp/src/apache/main/Schema/LogicalSchema.cs @@ -52,8 +52,7 @@ internal static LogicalSchema NewInstance(JToken jtok, PropertyMap props, Schema 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 d9f4995abf6..a1a6a4222b9 100644 --- a/lang/csharp/src/apache/main/Schema/MapSchema.cs +++ b/lang/csharp/src/apache/main/Schema/MapSchema.cs @@ -73,8 +73,7 @@ internal static MapSchema NewInstance(JToken jtok, PropertyMap props, SchemaName 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."); } ///