where T : new()

in src/Elastic.CommonSchema/Serialization/PropertiesReaderJsonConverterBase.cs [17:53]


	where T : new()
{
	/// <inheritdoc cref="System.Text.Json.Serialization.JsonConverter{T}.Read"/>
	public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
	{
		if (reader.TokenType == JsonTokenType.Null)
		{
			reader.Read();
			return default;
		}
		if (reader.TokenType != JsonTokenType.StartObject)
			throw new JsonException();

		var ecsEvent = new T();

		var originalDepth = reader.CurrentDepth;
		while (reader.Read())
		{
			if (reader.TokenType == JsonTokenType.EndObject)
			{
				if (reader.CurrentDepth <= originalDepth)
					break;
				continue;
			}

			if (reader.TokenType != JsonTokenType.PropertyName)
				throw new JsonException();

			var _ = ReadProperties(ref reader, ecsEvent, options);
		}

		return ecsEvent;
	}

	/// <summary> Handle reading the current property</summary>
	protected abstract bool ReadProperties(ref Utf8JsonReader reader, T ecsEvent, JsonSerializerOptions options);
}