{"record":{"id":"5ea1b990edd7e233","repo":"XINCGer/Unity3DTraining","slug":"dependencies-passed-to-filedescriptor-buildfrom","errorCode":null,"errorMessage":"Dependencies passed to FileDescriptor.BuildFrom() don't match those listed in the FileDescriptorProto.","messagePattern":"Dependencies passed to FileDescriptor\\.BuildFrom\\(\\) don't match those listed in the FileDescriptorProto\\.","errorType":"validation","errorClass":"DescriptorValidationException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs","lineNumber":273,"sourceCode":"            // FileDescriptorProto's tree and put all of the descriptors into the\n            // DescriptorPool's lookup tables.  In the linking step, we look up all\n            // type references in the DescriptorPool, so that, for example, a\n            // FieldDescriptor for an embedded message contains a pointer directly\n            // to the Descriptor for that message's type.  We also detect undefined\n            // types in the linking step.\n            if (dependencies == null)\n            {\n                dependencies = new FileDescriptor[0];\n            }\n\n            DescriptorPool pool = new DescriptorPool(dependencies);\n            FileDescriptor result = new FileDescriptor(descriptorData, proto, dependencies, pool, allowUnknownDependencies, generatedCodeInfo);\n\n            // Validate that the dependencies we've been passed (as FileDescriptors) are actually the ones we\n            // need.\n            if (dependencies.Length != proto.Dependency.Count)\n            {\n                throw new DescriptorValidationException(\n                    result,\n                    \"Dependencies passed to FileDescriptor.BuildFrom() don't match \" +\n                    \"those listed in the FileDescriptorProto.\");\n            }\n\n            result.CrossLink();\n            return result;\n        }\n\n        private void CrossLink()\n        {\n            foreach (MessageDescriptor message in MessageTypes)\n            {\n                message.CrossLink();\n            }\n\n            foreach (ServiceDescriptor service in Services)\n            {","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs#L255-L291","documentation":"FileDescriptor.BuildFrom verifies that the FileDescriptor array passed by the caller exactly matches the dependency list declared inside the FileDescriptorProto. If the counts differ, the descriptor and supplied dependencies are inconsistent and a DescriptorValidationException is thrown.","triggerScenarios":"FromGeneratedCode/BuildFrom called with a dependencies array whose length differs from proto.Dependency.Count — e.g. dropping a dependency descriptor or adding an extra one.","commonSituations":"Hand-updating generated code after schema changes; copying BuildFrom boilerplate between generated files with different imports; a code generator version mismatch where the embedded descriptor lists imports the caller array omits.","solutions":["Regenerate the C# code so the dependencies array matches the descriptor's imports exactly.","Compare proto.Dependency with the passed dependencies array; add/remove entries so counts and order match.","Ensure all generated files are from the same protoc/plugin generation run.","If a dependency was intentionally removed from the .proto, rebuild both descriptor and code together."],"exampleFix":"// before\nreturn new FileDescriptor[] { A.Descriptor }; // proto declares 2 dependencies\n// after\nreturn new FileDescriptor[] { A.Descriptor, B.Descriptor }; // matches proto.Dependency.Count","handlingStrategy":"validation","validationCode":"bool DepsMatch(FileDescriptorProto p, FileDescriptor[] deps) => deps.Length == p.Dependency.Count && deps.Zip(p.Dependency, (fd, name) => fd.Name == name).All(x => x);","typeGuard":null,"tryCatchPattern":"try { BuildFrom(...); } catch (DescriptorValidationException e) when (e.Message.Contains(\"don't match\")) { log.LogError(\"Dependency array out of sync with descriptor imports — regenerate\"); }","preventionTips":["Generate dependencies arrays automatically via the code generator, not by hand.","Regenerate all generated files together after .proto changes.","Assert deps.Length == proto.Dependency.Count in tests."],"tags":["protobuf","descriptor","reflection","version-mismatch"],"backgroundTag":"schema-mismatch","analyzedSha":"016f98412ea5e11756b286736f479b66ab6216d5","analyzedAt":"2026-09-12T01:08:58.711Z","contentChangedAt":"2026-09-12T01:08:58.711Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}