{"record":{"id":"89e76d4166b6c48f","repo":"XINCGer/Unity3DTraining","slug":"name-is-already-defined-as-something-other-th","errorCode":null,"errorMessage":"\"{name}\" is already defined (as something other than a package) in file \"{old.File.Name}\".","messagePattern":"\"(.+?)\" is already defined \\(as something other than a package\\) in file \"(.+?)\"\\.","errorType":"validation","errorClass":"DescriptorValidationException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/DescriptorPool.cs","lineNumber":139,"sourceCode":"        {\n            int dotpos = fullName.LastIndexOf('.');\n            String name;\n            if (dotpos != -1)\n            {\n                AddPackage(fullName.Substring(0, dotpos), file);\n                name = fullName.Substring(dotpos + 1);\n            }\n            else\n            {\n                name = fullName;\n            }\n\n            IDescriptor old;\n            if (descriptorsByName.TryGetValue(fullName, out old))\n            {\n                if (!(old is PackageDescriptor))\n                {\n                    throw new DescriptorValidationException(file,\n                                                            \"\\\"\" + name +\n                                                            \"\\\" is already defined (as something other than a \" +\n                                                            \"package) in file \\\"\" + old.File.Name + \"\\\".\");\n                }\n            }\n            descriptorsByName[fullName] = new PackageDescriptor(name, fullName, file);\n        }\n\n        /// <summary>\n        /// Adds a symbol to the symbol table.\n        /// </summary>\n        /// <exception cref=\"DescriptorValidationException\">The symbol already existed\n        /// in the symbol table.</exception>\n        internal void AddSymbol(IDescriptor descriptor)\n        {\n            ValidateSymbolName(descriptor);\n            String fullName = descriptor.FullName;\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/DescriptorPool.cs#L121-L157","documentation":"DescriptorPool.AddPackage throws DescriptorValidationException when building a FileDescriptor if the package name being registered collides with an existing symbol (message, enum, service, field, etc.) of the same fully-qualified name in the pool. A name can only refer to a package if nothing else has already claimed it. This mirrors protobuf's C++ descriptor validation rules.","triggerScenarios":"Calling FileDescriptor.BuildFromByteString/FromGeneratedCode for a .proto file whose 'package' declaration has the same fully-qualified name as a message, enum, or service already registered in the same descriptor pool — e.g. package foo.bar while a message foo.bar already exists from a previously loaded file.","commonSituations":"Merging multiple .proto files into one pool where one file's package path coincidentally matches another file's message name; renaming/moving declarations so a package path now shadows an existing type; generated-code registration order issues after schema refactoring.","solutions":["Rename the conflicting declaration: either the package in one .proto file or the message/enum/service with the same fully-qualified name.","Check every loaded file in the pool for a type whose fully-qualified name equals the package name in the failing file.","Regenerate code after renaming so descriptors are consistent.","If files are loaded dynamically, load the package-declaring file first or into a separate pool to avoid cross-file collisions."],"exampleFix":"// before (file A)\nmessage foo { ... } // fully-qualified: foo\n// file B\npackage foo.bar; // collides with message foo\n// after\nmessage FooMsg { ... } // no collision with package foo","handlingStrategy":"validation","validationCode":"// Before building a FileDescriptor, collect every type FQN already in the pool\n// and check the new file's package against them:\nbool collides = existingTypeFqns.Contains(newFileProto.Package);","typeGuard":null,"tryCatchPattern":"try\n{\n    var fd = FileDescriptor.BuildFromByteString(bytes, dependencies);\n}\ncatch (DescriptorValidationException ex) when (ex.Message.Contains(\"as something other than a package\"))\n{\n    // surface the conflicting file/name to schema maintainers\n}","preventionTips":["Never name packages the same as any message/enum/service","Keep a registry of fully-qualified names across all .proto files in the repo and lint for collisions","Load file sets together and version them as one unit"],"tags":["protobuf","descriptor","naming-collision","csharp"],"backgroundTag":"schema-validation-failed","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"}