using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#region Manually created from Must
public interface IMustConstraint { }
public class RangeConstraint : IMustConstraint
public Range range { get; set; }
public class WildcardConstraint : IMustConstraint
public Wildcard wildcard { get; set; }
#endregion Manually created from Must
[JsonProperty("@timestamp")]
public Timestamp Timestamp { get; set; }
public string gte { get; set; }
public string lt { get; set; }
[JsonProperty("request.keyword")]
public RequestKeyword RequestKeyword { get; set; }
public class RequestKeyword
public string value { get; set; }
public bool case_insensitive { get; set; }
public List<IMustConstraint> must { get; set; }
public BoolQuery @bool { get; set; }
public Query query { get; set; }
public static void Test()
new RangeConstraint() { range = new () { Timestamp = new () { gte = "now-7d", lt = "now" } } },
new WildcardConstraint() { wildcard = new () { RequestKeyword = new () { value = "/message/*/*-message/2c35669dd87e471faad1f90374d8d380/status", case_insensitive = true } } },
var json = JsonConvert.SerializeObject(root, Formatting.Indented);
Assert.IsTrue(JToken.DeepEquals(JToken.Parse(json), JToken.Parse(GetRequiredJson())));
static string GetRequiredJson() => @"{
""value"": ""/message/*/*-message/2c35669dd87e471faad1f90374d8d380/status"",
""case_insensitive"": true
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , Environment.Version);
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Assembly.GetName().Name, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");