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

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

                Author: ASF GitHub Bot
            Created on: 22/Jun/22 07:46
            Start Date: 22/Jun/22 07:46
    Worklog Time Spent: 10m 
      Work Description: KalleOlaviNiemitalo commented on code in PR #1728:
URL: https://github.com/apache/avro/pull/1728#discussion_r903399808


##########
lang/csharp/src/apache/main/Reflect/DotnetProperty.cs:
##########
@@ -67,7 +67,8 @@ private bool IsPropertyCompatible(Avro.Schema.Type schemaTag)
                 case Avro.Schema.Type.Array:
                     return typeof(IEnumerable).IsAssignableFrom(propType);
                 case Avro.Schema.Type.Map:
-                    return typeof(IDictionary).IsAssignableFrom(propType);
+                    var dictionaryType = typeof(IDictionary);
+                    return dictionaryType.IsAssignableFrom(propType) && 
propType.GenericTypeArguments[0] == typeof(string);

Review Comment:
   > question if this should actually be a check with typeof(IDictionary<,>) 
instead
   
   `typeof(IDictionary<,>).IsAssignableFrom(propType)` is always false, if 
`propType` comes from PropertyInfo.PropertyType and thus cannot be an open 
generic type:
   
   ```
   Microsoft (R) Roslyn C# Compiler version 2.10.0.0
   Loading context from 'CSharpInteractive.rsp'.
   Type "#help" for more information.
   > typeof(IDictionary<string, 
int>).IsAssignableFrom(typeof(Dictionary<string, int>))
   true
   > typeof(IDictionary<,>).IsAssignableFrom(typeof(Dictionary<,>))
   false
   > typeof(IDictionary<,>).IsAssignableFrom(typeof(Dictionary<string, int>))
   false
   ```
   
   See also <https://github.com/dotnet/command-line-api/issues/1768>.





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

    Worklog Id:     (was: 783745)
    Time Spent: 2h  (was: 1h 50m)

> .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
>          Time Spent: 2h
>  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.7#820007)

Reply via email to