{"record":{"id":"72bf7f412a8884bc","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-uimanager-uigroup","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.UIGroup.cs","lineNumber":281,"sourceCode":"\n                return results.ToArray();\n            }\n\n            /// <summary>\n            /// 从界面组中获取界面。\n            /// </summary>\n            /// <param name=\"uiFormAssetName\">界面资源名称。</param>\n            /// <param name=\"results\">要获取的界面。</param>\n            public void GetUIForms(string uiFormAssetName, List<IUIForm> results)\n            {\n                if (string.IsNullOrEmpty(uiFormAssetName))\n                {\n                    throw new GameFrameworkException(\"UI form asset name is invalid.\");\n                }\n\n                if (results == null)\n                {\n                    throw new GameFrameworkException(\"Results is invalid.\");\n                }\n\n                results.Clear();\n                foreach (UIFormInfo uiFormInfo in m_UIFormInfos)\n                {\n                    if (uiFormInfo.UIForm.UIFormAssetName == uiFormAssetName)\n                    {\n                        results.Add(uiFormInfo.UIForm);\n                    }\n                }\n            }\n\n            /// <summary>\n            /// 从界面组中获取所有界面。\n            /// </summary>\n            /// <returns>界面组中的所有界面。</returns>\n            public IUIForm[] GetAllUIForms()\n            {","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.UIGroup.cs#L263-L299","documentation":"The list overload of GetUIForms requires a non-null results list to fill. Passing null results throws GameFrameworkException('Results is invalid.') after the asset name passes validation, because the method clears and appends into that list.","triggerScenarios":"Calling UIGroup.GetUIForms(validName, null); a results variable that was declared but never instantiated; a helper returning null lists.","commonSituations":"Developers expecting the method to allocate the list for them; refactors where list initialization was removed; nullable fields defaulting to null.","solutions":["Instantiate the List<IUIForm> before calling GetUIForms(name, results)","Check for null and create the list if needed at the call site","Prefer the allocation-free overload only when you genuinely own a reusable list"],"exampleFix":"// before\nList<IUIForm> results = null;\nuiGroup.GetUIForms(\"GameOver\", results);\n// after\nList<IUIForm> results = new List<IUIForm>();\nuiGroup.GetUIForms(\"GameOver\", results);","handlingStrategy":"validation","validationCode":"var results = resultsList ?? new List<IUIForm>();","typeGuard":"bool HasResults(List<IUIForm> list) => list != null;","tryCatchPattern":"try { uiGroup.GetUIForms(name, results); } catch (GameFrameworkException ex) when (ex.Message.Contains(\"Results is invalid\")) { results = new List<IUIForm>(); uiGroup.GetUIForms(name, results); }","preventionTips":["Never pass null lists to fill-style overloads; the library does not allocate","Initialize reusable list fields in constructors","Prefer the allocating GetUIForms(name) overload unless profiling demands reuse"],"tags":["unity","gameframework","ui","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"}