private void ExtractValueTypesAndInlineObjectDefinitions()

in tools/Elastic.CommonSchema.Generator/Projection/TypeProjector.cs [250:320]


		private void ExtractValueTypesAndInlineObjectDefinitions()
		{
			foreach (var (name, fieldSetBaseClass) in FieldSetsBaseClasses)
			{
				var fieldSet = fieldSetBaseClass.FieldSet;
				var fields = fieldSetBaseClass.Properties;
				var parentPath = name;
				foreach (var (fullPath, field) in fieldSet.Fields)
				{
					if (fullPath == "host.ip")
					{

					}
					var currentPropertyReferences = fields;
					//If the fieldset declares itself as rooted the fields should be appended to `Base`
					if (fieldSet.Root == true)
						currentPropertyReferences = FieldSetsBaseClasses["base"].Properties;

					//always in the format of `entityname.[field]` where field can have dots too;
					var fieldTokens = fullPath.Split('.').ToArray();
					if (fieldTokens.Length <= 2)
					{
						parentPath = fullPath.StartsWith(name + ".") && fieldTokens.Length > 1 ? fieldTokens[0] : name;
						if (field.Type is FieldType.Object or FieldType.Nested)
						{
							InlineObjects[fullPath] = InlineObjects.TryGetValue(fullPath, out var o)
								? o
								: new InlineObject(fullPath, field);
							currentPropertyReferences[fullPath] =
								currentPropertyReferences.TryGetValue(fullPath, out var p)
									? p
									: new InlineObjectPropertyReference(field, parentPath, fullPath, InlineObjects[fullPath]);
						}
						else
							currentPropertyReferences[fullPath] = new ValueTypePropertyReference(field, parentPath, fullPath);
					}
					else
					{
						var allPaths = fieldTokens.Aggregate(new List<string>(), (list, s) =>
						{
							if (list.Count == 0) list.Add(s);
							else list.Add($"{list.Last()}.{s}");
							return list;
						});
						var inlineObjectPaths = allPaths.Skip(1).SkipLast(1).ToArray();

						// path is referencing an embedded nested ECS entity
						if (fieldSet.Nestings != null && fieldSet.Nestings.Any(nesting => fullPath.StartsWith($"{nesting}.")))
							continue;

						var foundInlineObjectPath = false;
						foreach (var path in inlineObjectPaths)
						{
							if (!fields.ContainsKey(path)) continue;

							InlineObjects[path] = InlineObjects.TryGetValue(path, out var o) ? o : new InlineObject(path, field);

							currentPropertyReferences[path] =
								currentPropertyReferences.TryGetValue(path, out var p)
									? p
									: new InlineObjectPropertyReference(field, parentPath, path, InlineObjects[path]);
							currentPropertyReferences = InlineObjects[path].Properties;
							parentPath = path;
							foundInlineObjectPath = true;
						}
						if (!foundInlineObjectPath) parentPath = name;
						currentPropertyReferences[fullPath] = new ValueTypePropertyReference(field, parentPath, fullPath);
					}
				}
			}
		}