[ 
https://issues.apache.org/jira/browse/AVRO-3434?focusedWorklogId=787715&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787715
 ]

ASF GitHub Bot logged work on AVRO-3434:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Jul/22 00:45
            Start Date: 05/Jul/22 00:45
    Worklog Time Spent: 10m 
      Work Description: KhrystynaPopadyuk commented on code in PR #1718:
URL: https://github.com/apache/avro/pull/1718#discussion_r913309136


##########
lang/csharp/src/apache/test/Reflect/TestLogicalSchema.cs:
##########
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+using Avro.IO;
+using Avro.Reflect;
+using NUnit.Framework;
+
+namespace Avro.test.Reflect
+{
+    public class TestLogicalSchema
+    {
+        [TestCase]
+        public void WriteAndReadObjectsWithLogicalSchemaFields_WithNullValues()
+        {
+            //Arrange
+            var obj = new TestObject
+            {
+                AvroDecimalNullableProperty = null,
+                AvroDecimalProperty = 13.42m,
+                GuidNullableProperty = null,
+                GuidProperty = Guid.NewGuid(),
+                DateNullableProperty = null,
+                DateProperty = new DateTime(2022, 05, 26, 14, 57, 24, 123),
+                DateTimeMicrosecondNullableProperty = null,
+                DateTimeMicrosecondProperty = DateTime.UtcNow,
+                DateTimeMillisecondNullableProperty = null,
+                DateTimeMillisecondProperty = DateTime.UtcNow,
+                TimeSpanMicrosecondNullableProperty = null,
+                TimeSpanMicrosecondProperty = new TimeSpan(23, 59, 59),
+                TimeSpanMillisecondNullableProperty = null,
+                TimeSpanMillisecondProperty = new TimeSpan(23, 59, 59),
+            };
+
+            var schema = Schema.Parse(SchemaJson);
+            var writer = new ReflectWriter<TestObject>(schema);
+            var reader = new ReflectReader<TestObject>(schema, schema);
+            var writeStream = new MemoryStream();
+            var writeBinaryEncoder = new BinaryEncoder(writeStream);
+
+            //Act
+            writer.Write(obj, writeBinaryEncoder);
+            var data = writeStream.ToArray();
+
+            var readStream = new MemoryStream(data);
+            var result = reader.Read(null, new BinaryDecoder(readStream));
+
+            //Assert
+            Assert.NotNull(result);
+            Assert.AreEqual(obj.AvroDecimalNullableProperty, 
result.AvroDecimalNullableProperty);
+            Assert.AreEqual(obj.AvroDecimalProperty, 
result.AvroDecimalProperty);
+            Assert.AreEqual(obj.GuidNullableProperty, 
result.GuidNullableProperty);
+            Assert.AreEqual(obj.GuidProperty, result.GuidProperty);
+            Assert.IsNull(obj.DateNullableProperty);
+            Assert.AreEqual(obj.DateProperty.Date, result.DateProperty);
+            Assert.AreEqual(obj.DateTimeMicrosecondNullableProperty, 
obj.DateTimeMicrosecondNullableProperty);
+            Assert.AreEqual(obj.DateTimeMicrosecondProperty, 
obj.DateTimeMicrosecondProperty);

Review Comment:
   Done





Issue Time Tracking
-------------------

    Worklog Id:     (was: 787715)
    Time Spent: 1h 10m  (was: 1h)

> .NET/#C: Support LogicalSchema for ReflectReader/Writer
> -------------------------------------------------------
>
>                 Key: AVRO-3434
>                 URL: https://issues.apache.org/jira/browse/AVRO-3434
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: csharp
>            Reporter: Khrystyna Popadyuk
>            Assignee: Khrystyna Popadyuk
>            Priority: Blocker
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Hi,
> I am working on a .NET/C# project that uses Kafka with Avro 
> serialization/deserialization in an event streaming platform.
> .NET Apache.Avro nuget package contains two different set of classes for 
> serialization/deserialization:   - SpecificReader, SpecificWriter   - 
> ReflectReader, ReflectWriter. We have chosen ReflectReader/Writer 
> ([https://avro.apache.org/docs/current/api/csharp/html/md_src_apache_main_Reflect_README.html])
>  so we can use POCO classes to represent a message.
> I noticed that ReflectReader/Writer does not support LogicalSchema. There are 
> default converters and Avro field attribute instead (they are extendable and 
> flexible).
> My questions are:
>  * is it intentional to not support LogicalSchema for ReflectReader/Writer?
>  * does it mean that we should not mix services that use LogicalSchema (third 
> party or just written on Java, Phyton or other languages) with ones that use 
> ReflectReader/Writer?  
>  
> Thanks,
> Khrystyna



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to