Ejemplo n.º 1
0
        /// <summary>
        /// Look up and cross-link all field types etc.
        /// </summary>
        internal void CrossLink()
        {
            if (Proto.TypeName != "")
            {
                IDescriptor typeDescriptor =
                    File.DescriptorPool.LookupSymbol(Proto.TypeName, this);

                if (Proto.Type != 0)
                {
                    // Choose field type based on symbol.
                    if (typeDescriptor is MessageDescriptor)
                    {
                        fieldType = FieldType.Message;
                    }
                    else if (typeDescriptor is EnumDescriptor)
                    {
                        fieldType = FieldType.Enum;
                    }
                    else
                    {
                        throw new DescriptorValidationException(this, $"\"{Proto.TypeName}\" is not a type.");
                    }
                }

                if (fieldType == FieldType.Message)
                {
                    if (!(typeDescriptor is MessageDescriptor))
                    {
                        throw new DescriptorValidationException(this, $"\"{Proto.TypeName}\" is not a message type.");
                    }
                    messageType = (MessageDescriptor)typeDescriptor;

                    if (Proto.DefaultValue != "")
                    {
                        throw new DescriptorValidationException(this, "Messages can't have default values.");
                    }
                }
                else if (fieldType == FieldType.Enum)
                {
                    if (!(typeDescriptor is EnumDescriptor))
                    {
                        throw new DescriptorValidationException(this, $"\"{Proto.TypeName}\" is not an enum type.");
                    }
                    enumType = (EnumDescriptor)typeDescriptor;
                }
                else
                {
                    throw new DescriptorValidationException(this, "Field with primitive type has type_name.");
                }
            }
            else
            {
                if (fieldType == FieldType.Message || fieldType == FieldType.Enum)
                {
                    throw new DescriptorValidationException(this, "Field with message or enum type missing type_name.");
                }
            }

            // Note: no attempt to perform any default value parsing

            File.DescriptorPool.AddFieldByNumber(this);

            if (ContainingType != null && ContainingType.Proto.Options != null && ContainingType.Proto.Options.MessageSetWireFormat)
            {
                throw new DescriptorValidationException(this, "MessageSet format is not supported.");
            }
            accessor = CreateAccessor();
        }
Ejemplo n.º 2
0
 internal EnumValueDescriptor FindEnumValueByNumber(EnumDescriptor enumDescriptor, int number)
 {
     enumValuesByNumber.TryGetValue(new ObjectIntPair <IDescriptor>(enumDescriptor, number), out EnumValueDescriptor ret);
     return(ret);
 }
Ejemplo n.º 3
0
 public EnumValueDescriptor FindValueByName(string name)
 {
     return(base.File.DescriptorPool.FindSymbol <EnumValueDescriptor>(EnumDescriptor.smethod_0(base.FullName, Module.smethod_34 <string>(3349943853u), name)));
 }
Ejemplo n.º 4
0
 private void AddEnum(EnumDescriptor enumDescriptor)
 {
     filesBySymbol[enumDescriptor.FullName] = enumDescriptor.File;
 }
Ejemplo n.º 5
0
        internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file, EnumDescriptor parent, int index) : base(file, EnumValueDescriptor.smethod_0(parent.FullName, Module.smethod_34 <string>(3349943853u), proto.Name), index)
        {
            while (true)
            {
IL_90:
                uint arg_70_0 = 3117200364u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_70_0 ^ 2941281634u)) % 5u)
                    {
                    case 0u:
                        goto IL_90;

                    case 1u:
                        file.DescriptorPool.AddSymbol(this);
                        arg_70_0 = (num * 4059409295u ^ 1121610279u);
                        continue;

                    case 3u:
                        this.enumDescriptor = parent;
                        arg_70_0            = (num * 2476227708u ^ 3235142323u);
                        continue;

                    case 4u:
                        this.proto = proto;
                        arg_70_0   = (num * 3737544868u ^ 4180488678u);
                        continue;
                    }
                    goto Block_1;
                }
            }
Block_1:
            file.DescriptorPool.AddEnumValueByNumber(this);
        }
Ejemplo n.º 6
0
        internal void CrossLink()
        {
            if (FieldDescriptor.smethod_3(this.Proto.TypeName, ""))
            {
                goto IL_191;
            }
            goto IL_3CA;
            uint arg_333_0;

            while (true)
            {
IL_32E:
                uint num;
                switch ((num = (arg_333_0 ^ 3013306013u)) % 30u)
                {
                case 0u:
                {
                    IDescriptor descriptor;
                    arg_333_0 = ((descriptor is EnumDescriptor) ? 2821381071u : 2537082698u);
                    continue;
                }

                case 1u:
                    arg_333_0 = (((!FieldDescriptor.smethod_3(this.Proto.DefaultValue, "")) ? 3504232881u : 4081425330u) ^ num * 3450336043u);
                    continue;

                case 2u:
                {
                    IDescriptor descriptor;
                    this.messageType = (MessageDescriptor)descriptor;
                    arg_333_0        = 4036915674u;
                    continue;
                }

                case 3u:
                {
                    IDescriptor descriptor = base.File.DescriptorPool.LookupSymbol(this.Proto.TypeName, this);
                    arg_333_0 = (num * 1137267228u ^ 1800642603u);
                    continue;
                }

                case 4u:
                    arg_333_0 = (((this.Proto.Type != (FieldDescriptorProto.Types.Type) 0) ? 3944142871u : 3881033019u) ^ num * 2947199265u);
                    continue;

                case 5u:
                    arg_333_0 = (num * 3768717094u ^ 4265278771u);
                    continue;

                case 6u:
                    goto IL_3D9;

                case 7u:
                    this.fieldType = FieldType.Message;
                    arg_333_0      = (num * 2040762779u ^ 2945237881u);
                    continue;

                case 8u:
                    arg_333_0 = (((this.fieldType != FieldType.Enum) ? 4206089270u : 4050017104u) ^ num * 2028914515u);
                    continue;

                case 9u:
                {
                    IDescriptor descriptor;
                    arg_333_0 = (((!(descriptor is EnumDescriptor)) ? 2973306776u : 2993182602u) ^ num * 1211533732u);
                    continue;
                }

                case 10u:
                    this.fieldType = FieldType.Enum;
                    arg_333_0      = (num * 335191304u ^ 978261121u);
                    continue;

                case 11u:
                    goto IL_3EA;

                case 12u:
                {
                    IDescriptor descriptor;
                    arg_333_0 = (((descriptor is MessageDescriptor) ? 1340053915u : 1990891018u) ^ num * 3272437084u);
                    continue;
                }

                case 13u:
                    goto IL_3FB;

                case 14u:
                    goto IL_425;

                case 15u:
                    goto IL_436;

                case 16u:
                    goto IL_191;

                case 17u:
                {
                    IDescriptor descriptor;
                    this.enumType = (EnumDescriptor)descriptor;
                    arg_333_0     = 4053406812u;
                    continue;
                }

                case 18u:
                    this.accessor = this.CreateAccessor(this.propertyName);
                    arg_333_0     = 3795529724u;
                    continue;

                case 19u:
                    goto IL_447;

                case 20u:
                    arg_333_0 = ((this.fieldType != FieldType.Message) ? 2460784210u : 3995577395u);
                    continue;

                case 22u:
                    arg_333_0 = (((this.containingType.Proto.Options == null) ? 419873589u : 668635125u) ^ num * 1090866907u);
                    continue;

                case 23u:
                    arg_333_0 = (((this.containingType != null) ? 572724748u : 1874315500u) ^ num * 1436619519u);
                    continue;

                case 24u:
                {
                    IDescriptor descriptor;
                    arg_333_0 = (((!(descriptor is MessageDescriptor)) ? 471649775u : 1414817504u) ^ num * 4283271988u);
                    continue;
                }

                case 25u:
                    arg_333_0 = ((this.fieldType != FieldType.Enum) ? 2708078287u : 4205631964u);
                    continue;

                case 26u:
                    goto IL_3CA;

                case 27u:
                    goto IL_471;

                case 28u:
                    arg_333_0 = ((this.containingType.Proto.Options.MessageSetWireFormat ? 288763958u : 1623010749u) ^ num * 3306098553u);
                    continue;

                case 29u:
                    base.File.DescriptorPool.AddFieldByNumber(this);
                    arg_333_0 = 2913542014u;
                    continue;
                }
                break;
            }
            return;

IL_3D9:
            throw new DescriptorValidationException(this, Module.smethod_33 <string>(1009936473u));
IL_3EA:
            throw new DescriptorValidationException(this, Module.smethod_37 <string>(3005745843u));
IL_3FB:
            throw new DescriptorValidationException(this, FieldDescriptor.smethod_0(Module.smethod_33 <string>(3783798939u), new object[]
            {
                this.Proto.TypeName
            }));
IL_425:
            throw new DescriptorValidationException(this, Module.smethod_33 <string>(306987899u));
IL_436:
            throw new DescriptorValidationException(this, Module.smethod_37 <string>(785259833u));
IL_447:
            throw new DescriptorValidationException(this, FieldDescriptor.smethod_0(Module.smethod_33 <string>(2096439923u), new object[]
            {
                this.Proto.TypeName
            }));
IL_471:
            throw new DescriptorValidationException(this, FieldDescriptor.smethod_0(Module.smethod_37 <string>(1924739148u), new object[]
            {
                this.Proto.TypeName
            }));
IL_191:
            arg_333_0 = 2419306412u;
            goto IL_32E;
IL_3CA:
            arg_333_0 = ((this.fieldType == FieldType.Message) ? 4199521082u : 2785444915u);
            goto IL_32E;
        }