{"record":{"id":"58508f016c43b580","repo":"XINCGer/Unity3DTraining","slug":"property-clrname-case-not-found-in-containingtyp","errorCode":null,"errorMessage":"Property {clrName}Case not found in {containingType.ClrType}","messagePattern":"Property (.+?)Case not found in (.+?)","errorType":"validation","errorClass":"DescriptorValidationException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/OneofDescriptor.cs","lineNumber":111,"sourceCode":"        internal void CrossLink()\n        {\n            List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>();\n            foreach (var field in ContainingType.Fields.InDeclarationOrder())\n            {\n                if (field.ContainingOneof == this)\n                {\n                    fieldCollection.Add(field);\n                }\n            }\n            fields = new ReadOnlyCollection<FieldDescriptor>(fieldCollection);\n        }\n\n        private OneofAccessor CreateAccessor(string clrName)\n        {\n            var caseProperty = containingType.ClrType.GetProperty(clrName + \"Case\");\n            if (caseProperty == null)\n            {\n                throw new DescriptorValidationException(this, \"Property \" + clrName + \"Case not found in \" + containingType.ClrType);\n            }\n            var clearMethod = containingType.ClrType.GetMethod(\"Clear\" + clrName);\n            if (clearMethod == null)\n            {\n                throw new DescriptorValidationException(this, \"Method Clear\" + clrName + \" not found in \" + containingType.ClrType);\n            }\n\n            return new OneofAccessor(caseProperty, clearMethod, this);\n        }\n    }\n}\n","sourceCodeStart":93,"sourceCodeEnd":123,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/OneofDescriptor.cs#L93-L123","documentation":"OneofDescriptor.CreateAccessor looks up a CLR property named '<clrName>Case' on the generated message type to serve as the oneof case discriminator. If reflection cannot find that property, it throws DescriptorValidationException. The generated C# class does not match what the descriptor expects.","triggerScenarios":"Loading a descriptor whose oneof CLR name does not correspond to a '<Name>Case' property on the containing generated type — e.g. mismatched/out-of-sync generated code, or constructing GeneratedMessageTypes manually without the case property.","commonSituations":"Mixing assemblies where descriptors were regenerated but the message assembly is stale, or hand-written IMessage implementations that omit the standard oneof case property pattern.","solutions":["Regenerate all C# protobuf code from the current .proto files so the class contains the '<Name>Case' property.","Ensure the descriptor and the generated message type come from the same build/version of the assembly.","If implementing IMessage manually, add the standard '<Name>Case' property and 'Clear<Name>()' method."],"exampleFix":"// before: hand-written message missing case property\n// after: add to the class\npublic ChoiceOneofCase ChoiceCase => ...;\npublic void ClearChoice() => ...;","handlingStrategy":"validation","validationCode":"if (typeof(Msg).GetProperty(oneofName + \"Case\") == null)\n    throw new InvalidOperationException($\"{typeof(Msg)} lacks {oneofName}Case property; regenerate protobuf code\");","typeGuard":null,"tryCatchPattern":"try { BuildGeneratedTypes(); } catch (DescriptorValidationException ex) { log.Error($\"Generated type out of sync with descriptor: {ex.Message}\"); throw; }","preventionTips":["Regenerate C# protobuf code in the same commit as .proto changes.","Never hand-edit generated *Grpc.cs/Proto.cs files; use partial classes for extensions."],"tags":["protobuf","reflection","oneof","descriptor-validation"],"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"}