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/02/02 07:24:55 UTC

[avro] branch master updated: AVRO-3347 Update addNamespace to AddNamespace (#1497)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b29ff55  AVRO-3347 Update addNamespace to AddNamespace (#1497)
b29ff55 is described below

commit b29ff557ffca53121dbc378d5c0873a06171dc60
Author: Kyle Schoonover <ky...@minmaxcorp.com>
AuthorDate: Tue Feb 1 23:24:47 2022 -0800

    AVRO-3347 Update addNamespace to AddNamespace (#1497)
    
    * AVRO-3347 Update addNamespace to AddNamespace
    
    * Make messaging more descriptive
    
    Co-authored-by: Kyle T. Schoonover <Ky...@nordstrom.com>
---
 lang/csharp/src/apache/main/CodeGen/CodeGen.cs | 31 +++++++++++++++++---------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
index 137695c..7a0b358 100644
--- a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
+++ b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
@@ -120,19 +120,16 @@ namespace Avro
         /// Code Namespace.
         /// </returns>
         /// <exception cref="System.ArgumentNullException">name - name cannot be null.</exception>
-        protected virtual CodeNamespace addNamespace(string name)
+        protected virtual CodeNamespace AddNamespace(string name)
         {
             if (string.IsNullOrEmpty(name))
             {
                 throw new ArgumentNullException(nameof(name), "name cannot be null.");
             }
 
-            CodeNamespace ns = null;
-
-            if (!NamespaceLookup.TryGetValue(name, out ns))
+            if (!NamespaceLookup.TryGetValue(name, out CodeNamespace ns))
             {
-                string csharpNamespace;
-                ns = NamespaceMapping.TryGetValue(name, out csharpNamespace)
+                ns = NamespaceMapping.TryGetValue(name, out string csharpNamespace)
                     ? new CodeNamespace(csharpNamespace)
                     : new CodeNamespace(CodeGenUtil.Instance.Mangle(name));
 
@@ -149,6 +146,20 @@ namespace Avro
         }
 
         /// <summary>
+        /// Adds a namespace object for the given name into the dictionary if it doesn't exist yet.
+        /// </summary>
+        /// <param name="name">name of namespace.</param>
+        /// <returns>
+        /// Code Namespace.
+        /// </returns>
+        /// <exception cref="System.ArgumentNullException">name - name cannot be null.</exception>
+        [Obsolete("This method will be deprecated in a future release. Please change call to AddNamespace(string name).")]
+        protected virtual CodeNamespace addNamespace(string name)
+        {
+            return AddNamespace(name);
+        }
+
+        /// <summary>
         /// Generates code for the given protocol and schema objects.
         /// </summary>
         /// <returns>
@@ -405,7 +416,7 @@ namespace Avro
                 throw new CodeGenException("Namespace required for enum schema " + fixedSchema.Name);
             }
 
-            CodeNamespace codens = addNamespace(nspace);
+            CodeNamespace codens = AddNamespace(nspace);
             codens.Types.Add(ctd);
         }
 
@@ -454,7 +465,7 @@ namespace Avro
                 throw new CodeGenException("Namespace required for enum schema " + enumschema.Name);
             }
 
-            CodeNamespace codens = addNamespace(nspace);
+            CodeNamespace codens = AddNamespace(nspace);
 
             codens.Types.Add(ctd);
         }
@@ -542,7 +553,7 @@ namespace Avro
                 throw new CodeGenException("Namespace required for enum schema " + nspace);
             }
 
-            CodeNamespace codens = addNamespace(nspace);
+            CodeNamespace codens = AddNamespace(nspace);
 
             codens.Types.Add(ctd);
 
@@ -836,7 +847,7 @@ namespace Avro
                 throw new CodeGenException("Namespace required for record schema " + recordSchema.Name);
             }
 
-            CodeNamespace codens = addNamespace(nspace);
+            CodeNamespace codens = AddNamespace(nspace);
 
             codens.Types.Add(ctd);