KyleSchoonover commented on a change in pull request #1438:
URL: https://github.com/apache/avro/pull/1438#discussion_r792066664



##########
File path: lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs
##########
@@ -82,7 +82,19 @@ public static PrimitiveSchema NewInstance(string type, 
PropertyMap props = null)
         /// <param name="encspace"></param>
         protected internal override void WriteJson(JsonTextWriter w, 
SchemaNames names, string encspace)
         {
-            w.WriteValue(Name);
+            if(this.Props != null && this.Props.Count > 0)
+            {
+                w.WriteStartObject();
+                w.WritePropertyName("type");
+                w.WriteValue(Name);
+                foreach(var prop in Props)
+                {
+                    w.WritePropertyName(prop.Key);
+                    w.WriteRawValue(prop.Value);
+                }
+                w.WriteEndObject();
+            }
+            else w.WriteValue(Name);

Review comment:
       Put else within brackets. Fixes styling related to SA1503

##########
File path: lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs
##########
@@ -82,7 +82,19 @@ public static PrimitiveSchema NewInstance(string type, 
PropertyMap props = null)
         /// <param name="encspace"></param>
         protected internal override void WriteJson(JsonTextWriter w, 
SchemaNames names, string encspace)
         {
-            w.WriteValue(Name);
+            if(this.Props != null && this.Props.Count > 0)

Review comment:
       shorthand for same check `if(this.Props?.Any() == true)`

##########
File path: lang/csharp/src/apache/main/Schema/Schema.cs
##########
@@ -202,8 +202,15 @@ internal static Schema ParseJson(JToken jtok, SchemaNames 
names, string encspace
                 }
                 else if (jtype.Type == JTokenType.Array)
                     return UnionSchema.NewInstance(jtype as JArray, props, 
names, encspace);
-                else if (jtype.Type == JTokenType.Object && null != 
jo["logicalType"]) // logical type based on a complex type
-                    return LogicalSchema.NewInstance(jtok, props, names, 
encspace);
+                else if (jtype.Type == JTokenType.Object)
+                {
+                    if (null != jo["logicalType"]) // logical type based on a 
complex type
+                        return LogicalSchema.NewInstance(jtok, props, names, 
encspace);

Review comment:
       Put within brackets. Fixes styling related to SA1503

##########
File path: lang/csharp/src/apache/main/Schema/Schema.cs
##########
@@ -202,8 +202,15 @@ internal static Schema ParseJson(JToken jtok, SchemaNames 
names, string encspace
                 }
                 else if (jtype.Type == JTokenType.Array)
                     return UnionSchema.NewInstance(jtype as JArray, props, 
names, encspace);
-                else if (jtype.Type == JTokenType.Object && null != 
jo["logicalType"]) // logical type based on a complex type
-                    return LogicalSchema.NewInstance(jtok, props, names, 
encspace);
+                else if (jtype.Type == JTokenType.Object)
+                {
+                    if (null != jo["logicalType"]) // logical type based on a 
complex type
+                        return LogicalSchema.NewInstance(jtok, props, names, 
encspace);
+
+                    var schema = ParseJson(jtype, names, encspace); // 
primitive schemas are allowed to have additional metadata properties
+                    if (schema is PrimitiveSchema)
+                        return schema;

Review comment:
       Put within brackets. Fixes styling related to SA1503




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to