Skip to content

Commit fdf1435

Browse files
committed
fix: Serialization of nested OrderedHashtables.
1 parent ddce4b8 commit fdf1435

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/readme.graph.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,19 @@ directive:
546546
{
547547
return $;
548548
} else {
549+
// Add using namespaces to class.
550+
let namespaceRegex = /(namespace.*.Runtime\n\{)/gm
551+
$ = $.replace(namespaceRegex,'$1\n\tusing System.Linq;');
552+
549553
// Changes excludes hashset to a case-insensitive hashset.
550554
let fromJsonRegex = /(\s*FromJson<\w*>\s*\(JsonObject\s*json\s*,\s*System\.Collections\.Generic\.IDictionary.*)(\s*)({)/gm
551555
$ = $.replace(fromJsonRegex, '$1$2$3\n$2 if (excludes != null){ excludes = new System.Collections.Generic.HashSet<string>(excludes, global::System.StringComparer.OrdinalIgnoreCase);}');
552556
557+
// Serialize OrderedDictionary
558+
let enumerableRegex = /(if.*\(value.*IEnumerable.*\))/gm
559+
let orderedSerializerImpl = 'if (value is System.Collections.Specialized.OrderedDictionary ovalue) { return JsonSerializable.ToJson((ovalue?.Cast<global::System.Collections.DictionaryEntry>().ToDictionary(kvp => kvp.Key as string, kvp => kvp.Value, global::System.StringComparer.OrdinalIgnoreCase)), null);}';
560+
$ = $.replace(enumerableRegex, `${orderedSerializerImpl}\n\n$1`)
561+
553562
return $;
554563
}
555564

0 commit comments

Comments
 (0)