{"record":{"id":"28f4bf61d3d0490a","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-resourcemanager-resourcegroup","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceGroup.cs","lineNumber":200,"sourceCode":"                int index = 0;\n                string[] resourceNames = new string[m_ResourceNames.Count];\n                foreach (ResourceName resourceName in m_ResourceNames)\n                {\n                    resourceNames[index++] = resourceName.FullName;\n                }\n\n                return resourceNames;\n            }\n\n            /// <summary>\n            /// 获取资源组包含的资源名称列表。\n            /// </summary>\n            /// <param name=\"results\">资源组包含的资源名称列表。</param>\n            public void GetResourceNames(List<string> results)\n            {\n                if (results == null)\n                {\n                    throw new GameFrameworkException(\"Results is invalid.\");\n                }\n\n                results.Clear();\n                foreach (ResourceName resourceName in m_ResourceNames)\n                {\n                    results.Add(resourceName.FullName);\n                }\n            }\n\n            /// <summary>\n            /// 获取资源组包含的资源名称列表。\n            /// </summary>\n            /// <returns>资源组包含的资源名称列表。</returns>\n            public ResourceName[] InternalGetResourceNames()\n            {\n                int index = 0;\n                ResourceName[] resourceNames = new ResourceName[m_ResourceNames.Count];\n                foreach (ResourceName resourceName in m_ResourceNames)","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceGroup.cs#L182-L218","documentation":"ResourceManager.ResourceGroup.GetResourceNames fills a caller-supplied List<string> with the full names of all resources in the group. The library throws GameFrameworkException(\"Results is invalid.\") when the results list reference is null, because it uses the list as its output buffer (Clear + Add) and cannot write into a null list.","triggerScenarios":"Calling ResourceGroup.GetResourceNames(null) (or a List<string> variable that is still null at call time).","commonSituations":"Developers declare the list but forget to instantiate it before passing it in, or pass the result of a helper method that returned null; common when refactoring from a method that returned a new list to this fill-in-list API.","solutions":["Allocate the list before calling: var results = new List<string>(); group.GetResourceNames(results);","Audit all call sites of GetResourceNames for possibly-null arguments and initialize them.","Wrap the call in try-catch on GameFrameworkException if the list may come from external code."],"exampleFix":"// before\nList<string> names = null;\ngroup.GetResourceNames(names);\n// after\nList<string> names = new List<string>();\ngroup.GetResourceNames(names);","handlingStrategy":"validation","validationCode":"if (results == null) results = new List<string>();\ngroup.GetResourceNames(results);","typeGuard":"bool IsValidResults(List<string> results) => results != null;","tryCatchPattern":"try { group.GetResourceNames(results); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }","preventionTips":["Always instantiate result lists at declaration","Treat Get*Names(list) APIs as fill-in-place, not returning APIs","Add Debug.Assert(results != null) at call sites in debug builds"],"tags":["csharp","null-argument","resource-management"],"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"}