You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/07/04 03:47:00 UTC
[jira] [Work logged] (AVRO-3540) .NET/C# Allow Reflect reader/writer to support Dictionaries keyed by something other than string
[ https://issues.apache.org/jira/browse/AVRO-3540?focusedWorklogId=787476&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787476 ]
ASF GitHub Bot logged work on AVRO-3540:
----------------------------------------
Author: ASF GitHub Bot
Created on: 04/Jul/22 03:46
Start Date: 04/Jul/22 03:46
Worklog Time Spent: 10m
Work Description: KalleOlaviNiemitalo commented on code in PR #1728:
URL: https://github.com/apache/avro/pull/1728#discussion_r912605714
##########
lang/csharp/src/apache/main/Reflect/ClassCache.cs:
##########
@@ -249,33 +249,19 @@ public void LoadClassCache(Type objType, Schema s)
LoadClassCache(objType.GenericTypeArguments[0], ars.ItemSchema);
break;
case MapSchema ms:
- if (!objType.IsGenericType && !typeof(IDictionary).IsAssignableFrom(objType))
- {
- throw new AvroException($"Cant map type {objType.Name} to map {ms.Name}");
- }
-
- if (!objType.IsGenericType)
- {
- throw new AvroException($"Cant map non-generic type {objType.Name} to map {ms.Name}");
+ var dictionaryType = FindOpenGenericInterface(typeof(IDictionary<,>), objType);
+ if (dictionaryType == null)
+ {
+ throw new AvroException($"Can't map type {objType.Name} to map {ms.Name}");
Review Comment:
I wonder if some of these exceptions should be AvroTypeException. The exception types are not very clearly documented. When I call the Avro library from an application, I end up just catching AvroException and treating all derived types the same.
On the master branch, ClassCache throws only AvroException. I suppose it can then be kept that way in this PR.
Issue Time Tracking
-------------------
Worklog Id: (was: 787476)
Time Spent: 2h 50m (was: 2h 40m)
> .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 50m
> 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)