{"record":{"id":"10f2f7d8eb6ab912","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-entitymanager-entityinfo","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Entity/EntityManager.EntityInfo.cs","lineNumber":107,"sourceCode":"                m_ParentEntity = null;\n                m_ChildEntities.Clear();\n            }\n\n            public IEntity GetChildEntity()\n            {\n                return m_ChildEntities.Count > 0 ? m_ChildEntities[0] : null;\n            }\n\n            public IEntity[] GetChildEntities()\n            {\n                return m_ChildEntities.ToArray();\n            }\n\n            public void GetChildEntities(List<IEntity> results)\n            {\n                if (results == null)\n                {\n                    throw new GameFrameworkException(\"Results is invalid.\");\n                }\n\n                results.Clear();\n                foreach (IEntity childEntity in m_ChildEntities)\n                {\n                    results.Add(childEntity);\n                }\n            }\n\n            public void AddChildEntity(IEntity childEntity)\n            {\n                if (m_ChildEntities.Contains(childEntity))\n                {\n                    throw new GameFrameworkException(\"Can not add child entity which is already exist.\");\n                }\n\n                m_ChildEntities.Add(childEntity);\n            }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Entity/EntityManager.EntityInfo.cs#L89-L125","documentation":"GetChildEntities copies all child entities of an entity into the caller-supplied results list. It throws GameFrameworkException when the results list is null, since there is nowhere to write the output. The entity itself does not need children — an empty list is valid — only a null list is rejected.","triggerScenarios":"Calling EntityInfo.GetChildEntities(null) or the EntityManager.GetChildEntities overload with a null List<IEntity>.","commonSituations":"Forgetting to allocate the results list before querying; refactoring from an allocation-returning API to the fill-list API and keeping the argument null.","solutions":["Allocate a List<IEntity> and pass it to GetChildEntities.","Null-check the list at the call site.","Prefer the overload that returns entity ids if you do not need the list reuse."],"exampleFix":"// before\nentityInfo.GetChildEntities(null);\n// after\nList<IEntity> children = new List<IEntity>();\nentityInfo.GetChildEntities(children);","handlingStrategy":"validation","validationCode":"if (results == null) results = new List<IEntity>();\nentityInfo.GetChildEntities(results);","typeGuard":"bool IsValidResults(List<IEntity> results) => results != null;","tryCatchPattern":"try { entityInfo.GetChildEntities(results); }\ncatch (GameFrameworkException ex) { Log.Error(\"GetChildEntities failed: {0}\", ex.Message); }","preventionTips":["Allocate the results list before calling fill-list APIs","Don't pass nullable list returns straight through","Reuse a scratch list per query to avoid nulls"],"tags":["csharp","gameframework","null-argument","entity"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}