{"record":{"id":"e58671c355dd9dd2","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-fsm","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Fsm/Fsm.cs","lineNumber":402,"sourceCode":"            int index = 0;\n            FsmState<T>[] results = new FsmState<T>[m_States.Count];\n            foreach (KeyValuePair<Type, FsmState<T>> state in m_States)\n            {\n                results[index++] = state.Value;\n            }\n\n            return results;\n        }\n\n        /// <summary>\n        /// 获取有限状态机的所有状态。\n        /// </summary>\n        /// <param name=\"results\">有限状态机的所有状态。</param>\n        public void GetAllStates(List<FsmState<T>> results)\n        {\n            if (results == null)\n            {\n                throw new GameFrameworkException(\"Results is invalid.\");\n            }\n\n            results.Clear();\n            foreach (KeyValuePair<Type, FsmState<T>> state in m_States)\n            {\n                results.Add(state.Value);\n            }\n        }\n\n        /// <summary>\n        /// 是否存在有限状态机数据。\n        /// </summary>\n        /// <param name=\"name\">有限状态机数据名称。</param>\n        /// <returns>有限状态机数据是否存在。</returns>\n        public bool HasData(string name)\n        {\n            if (string.IsNullOrEmpty(name))\n            {","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Fsm/Fsm.cs#L384-L420","documentation":"Null guard in Fsm<T>.GetAllStates(List<FsmState<T>>): thrown when the caller-supplied results list is null. This overload exists to let callers reuse a list and avoid allocation, so a null list defeats its purpose; pass an initialized List<FsmState<T>> or use the allocating overload.","triggerScenarios":"Calling fsm.GetAllStates(null), typically when a list field was never initialized or a helper method forwards a null collection.","commonSituations":"Debug/inspection utilities enumerating states of an FSM; deferred initialization where the list member is allocated later than the call.","solutions":["Pass a newly allocated List<FsmState<T>> to GetAllStates","Initialize the list field before the call","Null-check the list argument before invoking"],"exampleFix":"// before\nList<FsmState<FsmOwner>> states = null;\nfsm.GetAllStates(states); // throws\n// after\nvar states = new List<FsmState<FsmOwner>>();\nfsm.GetAllStates(states);","handlingStrategy":"validation","validationCode":"if (results == null) results = new List<FsmState<T>>();\nfsm.GetAllStates(results);","typeGuard":null,"tryCatchPattern":"try { fsm.GetAllStates(results); }\ncatch (GameFrameworkException ex) { Log.Error(\"GetAllStates requires a valid list: {0}\", ex.Message); }","preventionTips":["Always allocate the list before calling GetAllStates","Initialize list fields at declaration or in Awake","Wrap FSM inspection helpers with argument validation"],"tags":["unity","fsm","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"}