XINCGer/Unity3DTraining · error · DescriptorValidationException

Property Case not found in

Error message

Property {clrName}Case not found in {containingType.ClrType}

What it means

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.

Solutions

  1. Regenerate all C# protobuf code from the current .proto files so the class contains the '<Name>Case' property.
  2. Ensure the descriptor and the generated message type come from the same build/version of the assembly.
  3. If implementing IMessage manually, add the standard '<Name>Case' property and 'Clear<Name>()' method.

Example fix

// before: hand-written message missing case property
// after: add to the class
public ChoiceOneofCase ChoiceCase => ...;
public void ClearChoice() => ...;
Defensive patterns

Strategy: validation

Validate before calling

if (typeof(Msg).GetProperty(oneofName + "Case") == null)
    throw new InvalidOperationException($"{typeof(Msg)} lacks {oneofName}Case property; regenerate protobuf code");

Try / catch

try { BuildGeneratedTypes(); } catch (DescriptorValidationException ex) { log.Error($"Generated type out of sync with descriptor: {ex.Message}"); throw; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of XINCGer/Unity3DTraining@016f98412e (2026-09-12). Data as JSON: /api/errors/58508f016c43b580. Report an issue: GitHub.

Appendix: source

Thrown at NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/OneofDescriptor.cs:111

        internal void CrossLink()
        {
            List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>();
            foreach (var field in ContainingType.Fields.InDeclarationOrder())
            {
                if (field.ContainingOneof == this)
                {
                    fieldCollection.Add(field);
                }
            }
            fields = new ReadOnlyCollection<FieldDescriptor>(fieldCollection);
        }

        private OneofAccessor CreateAccessor(string clrName)
        {
            var caseProperty = containingType.ClrType.GetProperty(clrName + "Case");
            if (caseProperty == null)
            {
                throw new DescriptorValidationException(this, "Property " + clrName + "Case not found in " + containingType.ClrType);
            }
            var clearMethod = containingType.ClrType.GetMethod("Clear" + clrName);
            if (clearMethod == null)
            {
                throw new DescriptorValidationException(this, "Method Clear" + clrName + " not found in " + containingType.ClrType);
            }

            return new OneofAccessor(caseProperty, clearMethod, this);
        }
    }
}

View on GitHub (pinned to 016f98412e)