Avro.AvroException:数组未在字段中实现非通用 IList

Ism*_*ail 3 c# avro apache-kafka confluent-platform asp.net-core-3.1

我有 .netcore 3.1 api 我正在使用 kafka 和我正在使用的融合云库,它们的版本是:

架构注册表 1.7.0 Serdes 1.3.0

在我的架构中,我有:

{
  "name": "orderLineIds",
  "type": {
    "type": "array",
    "items": "int"
  },
  "default": [],
  "doc": "Associated order line item ids related to this promotion"
}
Run Code Online (Sandbox Code Playgroud)

这会在我的班级中生成以下内容:

        public IList<System.Int32> orderLineIds
    {
        get
        {
            return this._orderLineIds;
        }
        set
        {
            this._orderLineIds = value;
        }
    }
Run Code Online (Sandbox Code Playgroud)

当我尝试产品活动时,出现以下错误:

Avro.AvroException:数组未在字段 orderLineIds 中实现非通用 IList

我是否做错了什么或从我的架构中遗漏了什么?

小智 5

我正在使用 .Net 5 和架构注册表 1.8.1,并且遇到了同样的问题。我发现如果你的集合是null,Avro 序列化程序会在尝试转换为 时抛出此异常IList

我会仔细检查是否orderLineIds始终至少有一个空列表并且不为空。

一旦我这样做了,我的错误就消失了。