dotnet/runtime

Support using any dictionary as JsonExtensionData

Offen

#31.645 geöffnet am 03.02.2020

 (23 Kommentare) (8 Reaktionen) (1 zugewiesene Person)C# (5.445 Forks)batch import
area-System.Text.Jsonenhancementhelp wantedwishlist

Repository-Metriken

Stars
 (17.886 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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.

Contributor Guide