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



##########
File path: lang/csharp/src/apache/main/Schema/UnionSchema.cs
##########
@@ -161,5 +164,17 @@ public override int GetHashCode()
             result += getHashCode(Props);
             return result;
         }
+
+        private void VerifyChildSchemas(List<Schema> schemas)
+        {
+            if (schemas.Any(schema => schema.Tag == Type.Union))
+                throw new ArgumentException("Unions may not immediately 
contain other unions", nameof(schemas));
+
+            var groupedByFullNames = schemas.GroupBy(schema => 
schema.Fullname);
+            IGrouping<string, Schema> duplicateType = 
groupedByFullNames.FirstOrDefault(x => x.Count() > 1);
+
+            if (duplicateType != null)

Review comment:
       ```
   IGrouping<string, Schema> duplicateType = schemas.GroupBy(schema => 
schema.Fullname).FirstOrDefault(x => x.Count() > 1);
   
               if (duplicateType != null)
               {
                   throw new ArgumentException($"Duplicate type in union: 
{duplicateType.Key}");
               }
   ```




-- 
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