{"record":{"id":"81e7172ba784eefa","repo":"EllanJiang/GameFramework","slug":"resource-groups-is-invalid","errorCode":null,"errorMessage":"Resource groups is invalid.","messagePattern":"Resource groups is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs","lineNumber":34,"sourceCode":"        /// </summary>\n        private sealed class ResourceGroupCollection : IResourceGroupCollection\n        {\n            private readonly ResourceGroup[] m_ResourceGroups;\n            private readonly Dictionary<ResourceName, ResourceInfo> m_ResourceInfos;\n            private readonly HashSet<ResourceName> m_ResourceNames;\n            private long m_TotalLength;\n            private long m_TotalCompressedLength;\n\n            /// <summary>\n            /// 初始化资源组集合的新实例。\n            /// </summary>\n            /// <param name=\"resourceGroups\">资源组集合。</param>\n            /// <param name=\"resourceInfos\">资源信息引用。</param>\n            public ResourceGroupCollection(ResourceGroup[] resourceGroups, Dictionary<ResourceName, ResourceInfo> resourceInfos)\n            {\n                if (resourceGroups == null || resourceGroups.Length < 1)\n                {\n                    throw new GameFrameworkException(\"Resource groups is invalid.\");\n                }\n\n                if (resourceInfos == null)\n                {\n                    throw new GameFrameworkException(\"Resource infos is invalid.\");\n                }\n\n                int lastIndex = resourceGroups.Length - 1;\n                for (int i = 0; i < lastIndex; i++)\n                {\n                    if (resourceGroups[i] == null)\n                    {\n                        throw new GameFrameworkException(Utility.Text.Format(\"Resource group index '{0}' is invalid.\", i));\n                    }\n\n                    for (int j = i + 1; j < resourceGroups.Length; j++)\n                    {\n                        if (resourceGroups[i] == resourceGroups[j])","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs#L16-L52","documentation":"The ResourceGroupCollection constructor aggregates multiple ResourceGroup objects and requires a non-empty array of them. It throws GameFrameworkException(\"Resource groups is invalid.\") when resourceGroups is null or has length 0, because the collection would otherwise have nothing to aggregate.","triggerScenarios":"Calling new ResourceGroupCollection(null, infos) or new ResourceGroupCollection(new ResourceGroup[0], infos).","commonSituations":"Building an update/verification set from groups selected by name where no group matched the filter, producing an empty or null array before constructing the collection.","solutions":["Check that the groups array is non-null and contains at least one ResourceGroup before constructing the collection.","Fix the group-selection logic so at least one valid group is collected.","If an empty selection is legitimate, skip creating the collection instead of constructing it."],"exampleFix":"// before\nResourceGroup[] groups = GetSelectedGroups(); // may be empty\nvar col = new ResourceGroupCollection(groups, resourceInfos);\n// after\nResourceGroup[] groups = GetSelectedGroups();\nif (groups == null || groups.Length == 0) return; // or log/skip\nvar col = new ResourceGroupCollection(groups, resourceInfos);","handlingStrategy":"validation","validationCode":"if (groups == null || groups.Length == 0)\n    throw new InvalidOperationException(\"At least one resource group is required\");\nvar col = new ResourceGroupCollection(groups, infos);","typeGuard":"bool IsValidGroups(ResourceGroup[] groups) => groups != null && groups.Length > 0;","tryCatchPattern":"try { var col = new ResourceGroupCollection(groups, infos); } catch (GameFrameworkException ex) { Log.Error(ex.Message); return; }","preventionTips":["Validate group selection results before constructing collections","Skip collection creation when no group matched","Log selected group names for diagnosis"],"tags":["csharp","constructor","resource-management"],"backgroundTag":"invalid-constructor-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"}