[
https://issues.apache.org/jira/browse/AVRO-3540?focusedWorklogId=783707&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-783707
]
ASF GitHub Bot logged work on AVRO-3540:
----------------------------------------
Author: ASF GitHub Bot
Created on: 22/Jun/22 05:55
Start Date: 22/Jun/22 05:55
Worklog Time Spent: 10m
Work Description: KalleOlaviNiemitalo commented on code in PR #1728:
URL: https://github.com/apache/avro/pull/1728#discussion_r903310104
##########
lang/csharp/src/apache/main/Reflect/ClassCache.cs:
##########
@@ -252,7 +259,18 @@ public void LoadClassCache(Type objType, Schema s)
throw new AvroException($"Cant map non-generic type
{objType.Name} to map {ms.Name}");
}
- if
(!typeof(string).IsAssignableFrom(objType.GenericTypeArguments[0]))
+ var genericTypeDef = objType.GetGenericTypeDefinition();
+ if (!objType.IsInstanceOfType(typeof(IDictionary))
Review Comment:
[Type.IsInstanceOfType(object)](https://docs.microsoft.com/dotnet/api/system.type.isinstanceoftype?view=netstandard-2.0)
is not correct here. This checks whether `typeof(IDictionary)`, which is an
instance of Type, is an instance of _objType_. Which would be true if _objType_
is `typeof(Type)` or `typeof(MemberInfo)` or `typeof(object)`, but false if
_objType_ is `typeof(IDictionary)`. To check whether instances of _objType_
implement IDictionary, you can use
`typeof(IDictionary).IsAssignableFrom(objType)`.
Issue Time Tracking
-------------------
Worklog Id: (was: 783707)
Time Spent: 1h (was: 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: 1h
> 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)