private static void GenerateClasses(StringBuilder sb, LuaClassDict luaClasses)
 {
     // .IsUpdated(name)
     foreach (var name in luaClasses.Names)
     {
         GenerateClassFromDictionary(sb, name, luaClasses.GetFieldDictionary(name));
     }
 }
        private static LuaClassDict BuildClasses(LuaTable table, string name)
        {
            var luaClasses = new LuaClassDict();

            luaClasses.Add(new LuaClass(table, name));
            BuildClasses(luaClasses, table);

            return(luaClasses);
        }
        private static void BuildClasses(LuaClassDict luaClasses, Dictionary <string, object> luaFields)
        {
            foreach (var(name, value) in luaFields)
            {
                if (value is LuaTable table)
                {
                    if (table.IsArray())
                    {
                        var list = table.ToList();
                        if (list.Count != 0 && list.HasDefinedType(out var listType) && listType == typeof(LuaTable))
                        {
                            // We will make the big-brain assumption that all the tables here belong to the same class
                            var allFieldsInListClass = new Dictionary <string, object>();
                            list
                            .Cast <LuaTable>()
                            .SelectMany(t => t.ToDictionary())
                            .ToList()
                            .ForEach(kvp => allFieldsInListClass[kvp.Key] = kvp.Value);

                            luaClasses.Add(new LuaClass(allFieldsInListClass, name.ToCSharpName()));
                            BuildClasses(luaClasses, allFieldsInListClass);

                            foreach (var luaTable in list.Cast <LuaTable>().ToList())
                            {
                                BuildClasses(luaClasses, luaTable);
                            }
                        }
                    }
                    else
                    {
                        luaClasses.Add(new LuaClass(table, name.ToCSharpName()));
                        BuildClasses(luaClasses, table);
                    }
                }
            }
        }
 private static void BuildClasses(LuaClassDict luaClasses, LuaTable luaTable)
 {
     BuildClasses(luaClasses, luaTable.ToDictionary());
 }