{"record":{"id":"ea57a50f78c875b4","repo":"EllanJiang/GameFramework","slug":"results-is-invalid-resourcemanager-resourcegroupcollection","errorCode":null,"errorMessage":"Results is invalid.","messagePattern":"Results is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs","lineNumber":242,"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    }\n}\n","sourceCodeStart":224,"sourceCodeEnd":254,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs#L224-L254","documentation":"ResourceGroupCollection.GetResourceNames fills a caller-supplied List<string> with the full names of all resources aggregated in the collection. It throws GameFrameworkException(\"Results is invalid.\") when the results list is null, since the list is used directly as the output buffer.","triggerScenarios":"Calling collection.GetResourceNames(null) or with a List<string> variable that is null at call time.","commonSituations":"Forgetting to instantiate the list before the call; passing the return of another method that returned null; refactoring from an API that returns a list to this fill-in-place API.","solutions":["Allocate the list first: var results = new List<string>(); collection.GetResourceNames(results);","Initialize list fields/variables before passing them to any GetResourceNames overload.","Catch GameFrameworkException around the call if the list origin is uncertain."],"exampleFix":"// before\nList<string> names = null;\ncollection.GetResourceNames(names);\n// after\nList<string> names = new List<string>();\ncollection.GetResourceNames(names);","handlingStrategy":"validation","validationCode":"if (results == null) results = new List<string>();\ncollection.GetResourceNames(results);","typeGuard":"bool IsValidResults(List<string> results) => results != null;","tryCatchPattern":"try { collection.GetResourceNames(results); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }","preventionTips":["Instantiate result lists before calling fill-in APIs","Use the same list-allocation convention across all Get*Names calls","Assert non-null arguments 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"}