{"record":{"id":"b04016147216eb20","repo":"EllanJiang/GameFramework","slug":"resource-group-names-is-invalid","errorCode":null,"errorMessage":"Resource group names is invalid.","messagePattern":"Resource group names is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":2182,"sourceCode":"            }\n\n            results.Clear();\n            foreach (KeyValuePair<string, ResourceGroup> resourceGroup in m_ResourceGroups)\n            {\n                results.Add(resourceGroup.Value);\n            }\n        }\n\n        /// <summary>\n        /// 获取资源组集合。\n        /// </summary>\n        /// <param name=\"resourceGroupNames\">要获取的资源组名称的集合。</param>\n        /// <returns>要获取的资源组集合。</returns>\n        public IResourceGroupCollection GetResourceGroupCollection(params string[] resourceGroupNames)\n        {\n            if (resourceGroupNames == null || resourceGroupNames.Length < 1)\n            {\n                throw new GameFrameworkException(\"Resource group names is invalid.\");\n            }\n\n            ResourceGroup[] resourceGroups = new ResourceGroup[resourceGroupNames.Length];\n            for (int i = 0; i < resourceGroupNames.Length; i++)\n            {\n                if (string.IsNullOrEmpty(resourceGroupNames[i]))\n                {\n                    throw new GameFrameworkException(\"Resource group name is invalid.\");\n                }\n\n                resourceGroups[i] = (ResourceGroup)GetResourceGroup(resourceGroupNames[i]);\n                if (resourceGroups[i] == null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Resource group '{0}' is not exist.\", resourceGroupNames[i]));\n                }\n            }\n\n            return new ResourceGroupCollection(resourceGroups, m_ResourceInfos);","sourceCodeStart":2164,"sourceCodeEnd":2200,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L2164-L2200","documentation":"ResourceManager.GetResourceGroupCollection(params string[] resourceGroupNames) throws this when the names array is null or has zero entries. A collection requires at least one named resource group to aggregate.","triggerScenarios":"Calling GetResourceGroupCollection() with no arguments, with a null string[], or with an empty array variable.","commonSituations":"Building the name list from config that yielded no entries, then spreading it via params; callers passing an array that a parse step returned empty.","solutions":["Pass at least one valid resource group name","Check array length > 0 before calling","Fix the configuration/parsing step that produced an empty name list"],"exampleFix":"// before\nstring[] names = LoadNames(); // empty\nvar collection = manager.GetResourceGroupCollection(names);\n// after\nif (names != null && names.Length > 0)\n    var collection = manager.GetResourceGroupCollection(names);","handlingStrategy":"validation","validationCode":"if (names == null || names.Length == 0) throw new ArgumentException(\"At least one resource group name is required\", nameof(names));","typeGuard":"bool IsValidGroupNames(string[] names) => names != null && names.Length > 0 && names.All(n => !string.IsNullOrEmpty(n));","tryCatchPattern":"try { var col = manager.GetResourceGroupCollection(names); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Resource group names is invalid.\") { log.Error(\"No resource group names supplied\"); }","preventionTips":["Check collections are non-empty before spreading into params","Fail fast on empty config lists at startup","Use a dedicated wrapper type for group-name lists that enforces non-emptiness"],"tags":["csharp","gameframework","invalid-argument","resource-groups"],"backgroundTag":"missing-required-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}