dotnet/runtime

Support using any dictionary as JsonExtensionData

Open

#31,645 建立於 2020年2月3日

在 GitHub 查看
 (23 留言) (8 反應) (1 負責人)C# (5,445 fork)batch import
area-System.Text.Jsonenhancementhelp wantedwishlist

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

IMHO, IReadOnlyDictionary should work identical to IDictionary when using with JsonExtensionData attribute.

[JsonExtensionData]
public IReadOnlyDictionary<string, JsonElement> Payload { get; set; }

Currently it fails with error:

System.InvalidOperationException: The data extension property 'Payload' does not match the required signature of IDictionary<string, JsonElement> or IDictionary<string, object>.

This is analogous to collection properties which can be defined as List<T>, IList<T> or IReadOnlyList<T> etc.

貢獻者指南