using System.Text.Json; namespace AIStudio.Tools; public static class JsonSerializerOptionsExtensions { /// The options, with their TypeInfoResolver set. extension(JsonSerializerOptions options) { /// /// Makes the options read-only and returns them, so that a static field gets its options in one expression. /// /// /// Options with contracts of their own, i.e., with a TypeInfoResolver, should never change after they were /// declared: whoever used them before such a change would have read or written with other contracts. /// /// The same options, now read-only. public JsonSerializerOptions AsReadOnly() { options.MakeReadOnly(); return options; } } }