Skip to content

Commit

Permalink
Replace reflection based on PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-ww committed Jul 25, 2024
1 parent 0b4ca45 commit 89ef906
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/serialization/json/JsonSerializationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,13 @@ public void WriteDictionaryValue<T>(string? key, T values) where T : IDictionary
{
if(!string.IsNullOrEmpty(key))
writer.WritePropertyName(key!);
var type = values.GetType();
if(!type.IsGenericType || type.GetGenericArguments()[0] != typeof(string))
throw new InvalidOperationException($"error serialization additional data value with key {key}, unsupported type {type}");

writer.WriteStartObject();
foreach(DictionaryEntry entry in values)
{
WriteAnyValue((string)entry.Key, entry.Value);
if(entry.Key is not string keyStr)
throw new InvalidOperationException($"error serialization additional data value with key {key}, unsupported type {values.GetType()}");
WriteAnyValue(keyStr, entry.Value);
}
writer.WriteEndObject();
}
Expand Down

0 comments on commit 89ef906

Please sign in to comment.