dotnet/runtime

Support using any dictionary as JsonExtensionData

開放

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

 (23 則留言) (8 個反應) (1 位負責人)C# (5,445 個分叉)batch import
area-System.Text.Jsonenhancementhelp wantedwishlist

倉庫指標

星標
 (17,886 顆星)
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.

貢獻者指南