{"record":{"id":"e75a352a3af8c10c","repo":"EllanJiang/GameFramework","slug":"resource-info-0-is-invalid","errorCode":null,"errorMessage":"Resource info '{0}' is invalid.","messagePattern":"Resource info '(.+?)' is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs","lineNumber":79,"sourceCode":"                    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                {\n                    resourceGroup.InternalGetResourceNames(cachedResourceNames);\n                    foreach (ResourceName resourceName in cachedResourceNames)\n                    {\n                        ResourceInfo resourceInfo = null;\n                        if (!m_ResourceInfos.TryGetValue(resourceName, out resourceInfo))\n                        {\n                            throw new GameFrameworkException(Utility.Text.Format(\"Resource info '{0}' is invalid.\", resourceName.FullName));\n                        }\n\n                        if (m_ResourceNames.Add(resourceName))\n                        {\n                            m_TotalLength += resourceInfo.Length;\n                            m_TotalCompressedLength += resourceInfo.CompressedLength;\n                        }\n                    }\n                }\n            }\n\n            /// <summary>\n            /// 获取资源组集合是否准备完毕。\n            /// </summary>\n            public bool Ready\n            {\n                get\n                {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceGroupCollection.cs#L61-L97","documentation":"During construction, ResourceGroupCollection resolves each resource name from every group against the supplied resourceInfos dictionary. It throws GameFrameworkException(\"Resource info '{0}' is invalid.\") when a group contains a resource name absent from the dictionary, meaning the group's resource list and the resource-info table are out of sync.","triggerScenarios":"The resourceInfos dictionary was built from a different (older/newer) resource list than the one the groups were populated from — e.g. constructing the collection with a dictionary from a previous InitResources or a partially updated state.","commonSituations":"Version mismatch between the packaged resource list and the local resource metadata; hot-update where groups were refreshed but m_ResourceInfos was not; passing a stale or hand-built dictionary to the constructor.","solutions":["Ensure both the groups and the resourceInfos dictionary come from the same ResourceManager state (same InitResources/UpdateResources generation).","Re-run resource initialization so the dictionary matches the current resource list.","Verify the package version matches the resource metadata version to avoid name drift."],"exampleFix":"// before\nvar staleInfos = LoadOldResourceInfos();\nvar col = new ResourceGroupCollection(groups, staleInfos);\n// after\nrm.InitResources(variant); // rebuild groups + infos together\nvar col = new ResourceGroupCollection(groups, rm.CurrentResourceInfos);","handlingStrategy":"validation","validationCode":"bool infosReady = groups.All(g =>\n    g.GetResourceNames(/* temp list */).All(n => resourceInfos.ContainsKey(ResourceName.Parse(n))));\nif (!infosReady) throw new InvalidOperationException(\"Resource infos out of sync with groups\");","typeGuard":"bool InfosMatchGroups(IEnumerable<string> names, Dictionary<ResourceName, ResourceInfo> infos) => names.All(n => infos.ContainsKey(ResourceName.Parse(n)));","tryCatchPattern":"try { var col = new ResourceGroupCollection(groups, infos); } catch (GameFrameworkException ex) { Log.Error($\"Missing resource info: {ex.Message}\"); }","preventionTips":["Build groups and resource infos from the same initialization pass","Re-run InitResources after any package/version change","Never pass stale or manually constructed dictionaries"],"tags":["csharp","resource-management","consistency"],"backgroundTag":"resource-not-found","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"}