{"record":{"id":"76faced7cd2643ed","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-objectpoolmanager","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/ObjectPool/ObjectPoolManager.cs","lineNumber":294,"sourceCode":"\n            return results.ToArray();\n        }\n\n        /// <summary>\n        /// 获取对象池。\n        /// </summary>\n        /// <param name=\"condition\">要检查的条件。</param>\n        /// <param name=\"results\">要获取的对象池。</param>\n        public void GetObjectPools(Predicate<ObjectPoolBase> condition, List<ObjectPoolBase> results)\n        {\n            if (condition == null)\n            {\n                throw new GameFrameworkException(\"Condition is invalid.\");\n            }\n\n            if (results == null)\n            {\n                throw new GameFrameworkException(\"Results is invalid.\");\n            }\n\n            results.Clear();\n            foreach (KeyValuePair<TypeNamePair, ObjectPoolBase> objectPool in m_ObjectPools)\n            {\n                if (condition(objectPool.Value))\n                {\n                    results.Add(objectPool.Value);\n                }\n            }\n        }\n\n        /// <summary>\n        /// 获取所有对象池。\n        /// </summary>\n        /// <returns>所有对象池。</returns>\n        public ObjectPoolBase[] GetAllObjectPools()\n        {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/ObjectPool/ObjectPoolManager.cs#L276-L312","documentation":"GetObjectPools(Predicate<ObjectPoolBase>, List<ObjectPoolBase>) requires a non-null results list because it clears and fills it with matching pools. A null list throws GameFrameworkException(\"Results is invalid.\").","triggerScenarios":"Calling GetObjectPools(condition, null) — passing an uninitialized list field, or a method parameter that was null when forwarded.","commonSituations":"Reuse-buffer patterns where the cached List was never created; forwarding another method's null argument; assuming the method allocates the list for you (the non-list overload does).","solutions":["Create and pass a List<ObjectPoolBase> instance; the method clears it before filling.","Null-check/new-up the list before calling.","Use the overload GetObjectPools(Predicate) that allocates and returns the array for you."],"exampleFix":"// before\nList<ObjectPoolBase> buffer; // null\nobjectPoolComponent.GetObjectPools(p => p.Priority > 0, buffer);\n// after\nList<ObjectPoolBase> buffer = new List<ObjectPoolBase>();\nobjectPoolComponent.GetObjectPools(p => p.Priority > 0, buffer);","handlingStrategy":"validation","validationCode":"if (results == null) results = new List<ObjectPoolBase>();\nobjectPoolComponent.GetObjectPools(condition, results);","typeGuard":"static bool IsValidResults(List<ObjectPoolBase> l) => l != null;","tryCatchPattern":"try { objectPoolComponent.GetObjectPools(condition, results); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Results is invalid.\") { results = new List<ObjectPoolBase>(); }","preventionTips":["Always new-up reused list buffers before first use.","Or use the overload returning a freshly allocated array.","Null-check forwarded list arguments at API boundaries."],"tags":["csharp","objectpool","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}