dotnet/runtime

Support using any dictionary as JsonExtensionData

オープン

#31,645 opened on 2020/02/03

 (23 件のコメント) (8 件のリアクション) (1 人の担当者)C# (5,445 件のフォーク)batch import
area-System.Text.Jsonenhancementhelp wantedwishlist

Repository metrics

Stars
 (17,886 個のスター)
PR merge metrics
 (平均マージ 12d 11h) (30d で 661 merged PRs)

説明

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.

コントリビューターガイド