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

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

                Author: ASF GitHub Bot
            Created on: 18/Jul/22 07:43
            Start Date: 18/Jul/22 07:43
    Worklog Time Spent: 10m 
      Work Description: github-code-scanning[bot] commented on code in PR #1728:
URL: https://github.com/apache/avro/pull/1728#discussion_r923050461


##########
lang/csharp/src/apache/main/Reflect/ClassCache.cs:
##########
@@ -290,5 +304,26 @@
                     break;
             }
         }
+        private static Type FindOpenGenericInterface(
+            Type expected,
+            Type actual)
+        {
+            if (actual.IsGenericType &&
+                actual.GetGenericTypeDefinition() == expected)
+            {
+                return actual;
+            }
+
+            Type[] interfaces = actual.GetInterfaces();
+            foreach (Type interfaceType in interfaces)
+            {
+                if (interfaceType.IsGenericType &&
+                    interfaceType.GetGenericTypeDefinition() == expected)
+                {
+                    return interfaceType;
+                }
+            }

Review Comment:
   ## Missed opportunity to use Where
   
   This foreach loop implicitly filters its target sequence [here](1) - 
consider filtering the sequence explicitly using '.Where(...)'.
   
   [Show more 
details](https://github.com/apache/avro/security/code-scanning/2779)



##########
lang/csharp/src/apache/test/Reflect/TestReflect.cs:
##########
@@ -21,12 +21,172 @@
 using NUnit.Framework;
 using Avro.IO;
 using Avro.Reflect;
+using System.Collections.Generic;
+using System;
+using Avro.Specific;
+using System.Linq;
+using System.Diagnostics.CodeAnalysis;
 
 namespace Avro.Test
 {
     [TestFixture]
     class TestReflect
     {
+        public class IDictionaryTestClass : IDictionary<string, int>
+        {
+            Dictionary<string, int> _pairs = new Dictionary<string, int>();

Review Comment:
   ## Missed 'readonly' opportunity
   
   Field '_pairs' can be 'readonly'.
   
   [Show more 
details](https://github.com/apache/avro/security/code-scanning/2778)



##########
lang/csharp/src/apache/main/Reflect/DotnetProperty.cs:
##########
@@ -136,5 +142,27 @@
                 _property.SetValue(o, v);
             }
         }
+
+        private static Type FindOpenGenericInterface(
+            Type expected,
+            Type actual)
+        {
+            if (actual.IsGenericType &&
+                actual.GetGenericTypeDefinition() == expected)
+            {
+                return actual;
+            }
+
+            Type[] interfaces = actual.GetInterfaces();
+            foreach (Type interfaceType in interfaces)
+            {
+                if (interfaceType.IsGenericType &&
+                    interfaceType.GetGenericTypeDefinition() == expected)
+                {
+                    return interfaceType;
+                }
+            }

Review Comment:
   ## Missed opportunity to use Where
   
   This foreach loop implicitly filters its target sequence [here](1) - 
consider filtering the sequence explicitly using '.Where(...)'.
   
   [Show more 
details](https://github.com/apache/avro/security/code-scanning/2780)



##########
lang/csharp/src/apache/main/Reflect/ReflectDefaultWriter.cs:
##########
@@ -203,5 +232,26 @@
                     throw new AvroException("Unknown schema type: " + sc.Tag);
             }
         }
+        private static Type FindOpenGenericInterface(
+            Type expected,
+            Type actual)
+        {
+            if (actual.IsGenericType &&
+                actual.GetGenericTypeDefinition() == expected)
+            {
+                return actual;
+            }
+
+            Type[] interfaces = actual.GetInterfaces();
+            foreach (Type interfaceType in interfaces)
+            {
+                if (interfaceType.IsGenericType &&
+                    interfaceType.GetGenericTypeDefinition() == expected)
+                {
+                    return interfaceType;
+                }
+            }

Review Comment:
   ## Missed opportunity to use Where
   
   This foreach loop implicitly filters its target sequence [here](1) - 
consider filtering the sequence explicitly using '.Where(...)'.
   
   [Show more 
details](https://github.com/apache/avro/security/code-scanning/2781)





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

    Worklog Id:     (was: 791883)
    Time Spent: 3h 20m  (was: 3h 10m)

> .NET/C# Allow Reflect reader/writer to support Dictionaries keyed by 
> something other than string
> ------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-3540
>                 URL: https://issues.apache.org/jira/browse/AVRO-3540
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: csharp
>            Reporter: Christopher Fingar
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: AVRO-3540.patch
>
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> Currently the existing reflect code does not support converting other key 
> types to string.
> My change provides an opt-in functionality using the default converters. 
> This allows users to keep there existing code instead of converting types to 
> use string keys.
>  
>  



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

Reply via email to