You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "alexrosenfeld10 (via GitHub)" <gi...@apache.org> on 2023/06/16 14:41:36 UTC

[GitHub] [avro] alexrosenfeld10 commented on a diff in pull request #2292: Cross-file type resolution for C#

alexrosenfeld10 commented on code in PR #2292:
URL: https://github.com/apache/avro/pull/2292#discussion_r1232344622


##########
lang/csharp/src/apache/codegen/AvroGen.cs:
##########
@@ -201,5 +220,102 @@ static void Usage()
 
             return 0;
         }
+
+        static int GenSchema(List<string> infiles, string outdir, IEnumerable<KeyValuePair<string, string>> namespaceMapping)
+        {
+            try
+            {
+                var sn = new SchemaNames();
+                CodeGen codegen = new CodeGen();
+                var targetNs = new List<string>();
+
+                if (infiles.Count == 1)
+                {
+                    FileAttributes attr = System.IO.File.GetAttributes(infiles.First());
+                    if (attr.HasFlag(FileAttributes.Directory))
+                    {
+                        var dirInfo = new DirectoryInfo(infiles.First());
+                        infiles = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly)
+                                         .OrderBy(f => f.Name)
+                                         .Select(f => f.FullName)
+                                         .ToList();
+                    }
+                }
+
+                var toRetry = new List<string>();
+                foreach (var infile in infiles)
+                {
+                    FileAttributes attr = System.IO.File.GetAttributes(infile);
+                    if (attr.HasFlag(FileAttributes.Directory))
+                        continue;
+
+                    Console.WriteLine($"Loading Schema from: [{infile}]");
+                    string text = System.IO.File.ReadAllText(infile);
+
+                    //try

Review Comment:
   the "retries" system isn't fully built here. I'm working on this primarily from the C# code gen side of things, not from the `avrogen` CLI side of things. However, I and I'm sure @alfhv too) would like to see this finished before merging.



##########
lang/csharp/src/apache/main/Schema/Schema.cs:
##########
@@ -231,6 +233,70 @@ public static Schema Parse(string json)
             return Parse(json.Trim(), new SchemaNames(), null); // standalone schema, so no enclosing namespace
         }
 
+
+        /// <summary>
+        ///
+        /// </summary>
+        /// <param name="schemaJsons"></param>
+        /// <returns></returns>
+        /// <exception cref="SchemaParseException"></exception>
+        public static IDictionary<string, Schema> ParseAll(IEnumerable<string> schemaJsons)

Review Comment:
   This is the actual functionality.



##########
lang/csharp/src/apache/main/CodeGen/CodeGen.cs:
##########
@@ -1273,5 +1273,47 @@ private static string ReplaceMappedNamespacesInSchema(string input, IEnumerable<
                 return $@"""namespace""{m.Groups[1].Value}:{m.Groups[2].Value}""{ns}""";
             });
         }
+
+        public virtual void WriteTypes(string outputdir, List<string> targetNamespaces)

Review Comment:
   This was already merged in the previous PR, sorry for the noisy diff.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org