Skip to content

Commit

Permalink
Update UniversalJsonConverter.cs
Browse files Browse the repository at this point in the history
UniversalJsonConverter now skips indexed params
  • Loading branch information
mhamsterr committed Oct 14, 2023
1 parent 33e4a75 commit f20f7ac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Content.Server/GuideGenerator/UniversalJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f20f7ac

Please sign in to comment.