{"record":{"id":"c48b8c597625c229","repo":"XINCGer/Unity3DTraining","slug":"name-is-not-defined","errorCode":null,"errorMessage":"\"{name}\" is not defined.","messagePattern":"\"(.+?)\" is not defined\\.","errorType":"validation","errorClass":"DescriptorValidationException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/DescriptorPool.cs","lineNumber":325,"sourceCode":"                                // We only found the first part of the symbol.  Now look for\n                                // the whole thing.  If this fails, we *don't* want to keep\n                                // searching parent scopes.\n                                scopeToTry.Length = dotpos + 1;\n                                scopeToTry.Append(name);\n                                result = FindSymbol<IDescriptor>(scopeToTry.ToString());\n                            }\n                            break;\n                        }\n\n                        // Not found.  Remove the name so we can try again.\n                        scopeToTry.Length = dotpos;\n                    }\n                }\n            }\n\n            if (result == null)\n            {\n                throw new DescriptorValidationException(relativeTo, \"\\\"\" + name + \"\\\" is not defined.\");\n            }\n            else\n            {\n                return result;\n            }\n        }\n\n        /// <summary>\n        /// Struct used to hold the keys for the fieldByNumber table.\n        /// </summary>\n        private struct DescriptorIntPair : IEquatable<DescriptorIntPair>\n        {\n            private readonly int number;\n            private readonly IDescriptor descriptor;\n\n            internal DescriptorIntPair(IDescriptor descriptor, int number)\n            {\n                this.number = number;","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/DescriptorPool.cs#L307-L343","documentation":"DescriptorPool.LookupSymbol throws DescriptorValidationException when resolving a type name referenced from a proto declaration (e.g. a field's type_name or a method's input/output type) fails. The name is looked up with protobuf's scope resolution rules (relative to the referencing descriptor's scope, then the root), and if nothing matches, the reference is reported as undefined relative to the containing descriptor.","triggerScenarios":"Building a FileDescriptor where a field's type_name (e.g. \".myapp.MissingMessage\" or a relative \"MissingMessage\") does not match any message/enum registered in the pool — a typo in a type reference, a referenced type defined in a file that was not added to the pool, or a type removed by refactoring while references remained.","commonSituations":"Loading a subset of a FileDescriptorSet (missing dependency files); renaming a message in one .proto without updating references; hand-building descriptors with type_name strings that don't match actual declarations; relying on relative names without the leading dot when the type lives in a different package.","solutions":["Ensure all dependency .proto files of the failing file are built into the same descriptor pool before it.","Fix the type reference: use the correct fully-qualified name with a leading dot (e.g. \".myapp.Message\") or correct relative name.","Check for typos/renames: search your .proto sources for the referenced name and update the definition or reference.","When loading dynamically, build the full transitive dependency set (protoc --include_imports) instead of individual files."],"exampleFix":"// before\nnew FieldDescriptorProto { Name = \"owner\", TypeName = \"User\", ... } // User not in pool\n// after\nnew FieldDescriptorProto { Name = \"owner\", TypeName = \".myapp.User\", ... } // correct FQN, User file loaded first","handlingStrategy":"validation","validationCode":"// Ensure every imported/dependent file is passed as a dependency before building:\nvar byName = allFiles.ToDictionary(f => f.Name);\nvar deps = fileProto.Dependency\n    .Select(d => byName.TryGetValue(d, out var fd) ? fd : throw new InvalidOperationException($\"Missing dependency {d}\"))\n    .ToList();","typeGuard":null,"tryCatchPattern":"try\n{\n    var fd = FileDescriptor.BuildFromByteString(bytes, dependencies);\n}\ncatch (DescriptorValidationException ex) when (ex.Message.Contains(\"is not defined.\"))\n{\n    // load missing dependency files or fix the type_name reference\n}","preventionTips":["Use protoc --include_imports and load the full transitive descriptor set","Always use fully-qualified type references with a leading dot in hand-built descriptors","Run a rename refactor across all .proto files together (grep all references)"],"tags":["protobuf","descriptor","symbol-resolution","csharp"],"backgroundTag":"resource-not-found","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"}