{"record":{"id":"ccf2cca98f7a5c3b","repo":"EllanJiang/GameFramework","slug":"resource-group-0-duplicated","errorCode":null,"errorMessage":"Resource group '{0}' duplicated.","messagePattern":"Resource group '(.+?)' duplicated\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs","lineNumber":54,"sourceCode":"\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])\n                        {\n                            throw new GameFrameworkException(Utility.Text.Format(\"Resource group '{0}' duplicated.\", resourceGroups[i].Name));\n                        }\n                    }\n                }\n\n                if (resourceGroups[lastIndex] == null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Resource group index '{0}' is invalid.\", lastIndex));\n                }\n\n                m_ResourceGroups = resourceGroups;\n                m_ResourceInfos = resourceInfos;\n                m_ResourceNames = new HashSet<ResourceName>();\n                m_TotalLength = 0L;\n                m_TotalCompressedLength = 0L;\n\n                List<ResourceName> cachedResourceNames = new List<ResourceName>();\n                foreach (ResourceGroup resourceGroup in m_ResourceGroups)\n                {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs#L36-L72","documentation":"ResourceGroupCollection rejects duplicate group references: while validating the array it compares each pair and throws GameFrameworkException(\"Resource group '{0}' duplicated.\") when the same ResourceGroup instance appears more than once, because aggregating it twice would double-count resources and lengths.","triggerScenarios":"Constructing the collection with the same ResourceGroup object appearing at two or more indices in the resourceGroups array.","commonSituations":"Adding a group by several overlapping name lists (e.g. \"UI\" requested both directly and via a parent config), or accumulating groups in a list without a Distinct() pass.","solutions":["Deduplicate the array before construction: groups.Distinct().ToArray().","Track already-added group names when assembling the array from multiple sources.","Log which group names were requested and verify each is only added once."],"exampleFix":"// before\nvar groups = new ResourceGroup[] { rm.GetResourceGroup(\"UI\"), rm.GetResourceGroup(\"UI\") };\nvar col = new ResourceGroupCollection(groups, infos);\n// after\nvar groups = new ResourceGroup[] { rm.GetResourceGroup(\"UI\"), rm.GetResourceGroup(\"UI\") }\n    .Distinct().ToArray();\nvar col = new ResourceGroupCollection(groups, infos);","handlingStrategy":"validation","validationCode":"groups = groups.Distinct().ToArray();\nvar col = new ResourceGroupCollection(groups, infos);","typeGuard":"bool NoDuplicates(ResourceGroup[] groups) => groups.Distinct().Count() == groups.Length;","tryCatchPattern":"try { var col = new ResourceGroupCollection(groups, infos); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }","preventionTips":["Deduplicate group arrays with Distinct()","Track added group names in a HashSet when building from multiple sources","Review config for groups referenced by multiple aliases"],"tags":["csharp","constructor","duplicate"],"backgroundTag":"invalid-argument-value","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"}