From f20f7ace96e7cbbef8ba59c7c9cf9f1f69b86ba4 Mon Sep 17 00:00:00 2001 From: mhamster Date: Sat, 14 Oct 2023 16:37:03 +0700 Subject: [PATCH] Update UniversalJsonConverter.cs UniversalJsonConverter now skips indexed params --- Content.Server/GuideGenerator/UniversalJsonConverter.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Content.Server/GuideGenerator/UniversalJsonConverter.cs b/Content.Server/GuideGenerator/UniversalJsonConverter.cs index bcf9702c1c0..a17855c548b 100644 --- a/Content.Server/GuideGenerator/UniversalJsonConverter.cs +++ b/Content.Server/GuideGenerator/UniversalJsonConverter.cs @@ -73,6 +73,11 @@ public override void Write(Utf8JsonWriter writer, T obj, JsonSerializerOptions o // If the field has a [JsonIgnore] attribute, skip it if (Attribute.GetCustomAttribute(prop, typeof(JsonIgnoreAttribute), true) != null) continue; + // If GetIndexParameters().Length is not 0 then it means that property is indexed + // And since we cannot get its values without passing index (which type can LITERALLY BE ANYTHING) then let's just skip it + // Yeah, i know that this will lead to a potential data loss, but what i can do about it? + if (prop.GetIndexParameters().Length != 0) continue; // Corvax-Wiki + // If the property has a [JsonPropertyName] attribute, get the property name. Otherwise, use the property name. JsonPropertyNameAttribute? attr = (JsonPropertyNameAttribute?) Attribute.GetCustomAttribute(prop, typeof(JsonPropertyNameAttribute), true); string name = attr == null ? prop.Name : attr.Name;