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

blachniet pushed a commit to branch branch-1.9
in repository https://gitbox.apache.org/repos/asf/avro.git

commit e24c2bf12c039bb8488462aa8b03a89e7e323a8f
Author: Brian Lachniet <[email protected]>
AuthorDate: Sat Aug 24 08:36:49 2019 -0400

    AVRO-2522: Handle record types with Nullable and IList in their names
    (#663)
    
    (cherry picked commit from 6bccc286c13d9af41cface30c92e39705a998de7)
---
 .../src/apache/main/Specific/ObjectCreator.cs      |  5 ++---
 .../src/apache/test/Specific/ObjectCreatorTests.cs | 22 +++++++++++++++++++++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs 
b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
index 00a7f36..b0cf9ef 100644
--- a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
+++ b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
@@ -138,9 +138,8 @@ namespace Avro.Specific
 
                 // Modify provided type to ensure it can be discovered.
                 // This is mainly for Generics, and Nullables.
-                name = name.Replace("Nullable", "Nullable`1");
-                name = name.Replace("IList", 
"System.Collections.Generic.IList`1");
-                name = name.Replace("<", "[");
+                name = name.Replace("Nullable<", "Nullable`1[");
+                name = name.Replace("IList<", 
"System.Collections.Generic.IList`1[");
                 name = name.Replace(">", "]");
 
                 // if entry assembly different from current assembly, try 
entry assembly first
diff --git a/lang/csharp/src/apache/test/Specific/ObjectCreatorTests.cs 
b/lang/csharp/src/apache/test/Specific/ObjectCreatorTests.cs
index e95c10a..f17ff55 100644
--- a/lang/csharp/src/apache/test/Specific/ObjectCreatorTests.cs
+++ b/lang/csharp/src/apache/test/Specific/ObjectCreatorTests.cs
@@ -18,9 +18,10 @@
 using Avro.Specific;
 using Avro.Test.File;
 using NUnit.Framework;
+using System;
 using System.Collections.Generic;
 
-namespace Avro.test.Specific
+namespace Avro.Test.Specific
 {
     [TestFixture()]
     public class ObjectCreatorTests
@@ -78,5 +79,24 @@ namespace Avro.test.Specific
             Assert.True(typeof(IDictionary<string, Foo>).IsAssignableFrom(
                 objectCreator.GetType("Foo", Schema.Type.Map)));
         }
+
+        [TestCase(typeof(MyNullableFoo), "MyNullableFoo",
+            TestName = "TestComplexGetTypes_NullableInName")]
+        [TestCase(typeof(MyIListFoo), "MyIListFoo",
+            TestName = "TestComplexGetTypes_IListInName")]
+        public void TestComplexGetTypes(Type expecteType, string name)
+        {
+            var objectCreator = new ObjectCreator();
+
+            Assert.AreEqual(expecteType, objectCreator.GetType(name, 
Schema.Type.Record));
+        }
+
+        private class MyNullableFoo
+        {
+        }
+
+        private class MyIListFoo
+        {
+        }
     }
 }

Reply via email to