Example #1
0
        internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedClrTypeInfo generatedCodeInfo)
            : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
        {
            Proto = proto;
            if (generatedCodeInfo != null)
            {
                Parser  = generatedCodeInfo.Parser;
                ClrType = generatedCodeInfo.ClrType;
            }
            ContainingType = parent;

            // Note use of generatedCodeInfo. rather than generatedCodeInfo?. here... we don't expect
            // to see any nested oneofs, types or enums in "not actually generated" code... we do
            // expect fields though (for map entry messages).
            Oneofs = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.OneofDecl,
                (oneof, index) =>
                new OneofDescriptor(oneof, file, this, index, generatedCodeInfo.OneofNames[index]));

            NestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.NestedType,
                (type, index) =>
                new MessageDescriptor(type, file, this, index, generatedCodeInfo.NestedTypes[index]));

            EnumTypes = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.EnumType,
                (type, index) =>
                new EnumDescriptor(type, file, this, index, generatedCodeInfo.NestedEnums[index]));

            fieldsInDeclarationOrder = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.Field,
                (field, index) =>
                new FieldDescriptor(field, file, this, index, generatedCodeInfo != null ? generatedCodeInfo.PropertyNames[index] : null));
            fieldsInNumberOrder = new ReadOnlyCollection <FieldDescriptor>(fieldsInDeclarationOrder.OrderBy(field => field.FieldNumber).ToArray());
            // TODO: Use field => field.Proto.JsonName when we're confident it's appropriate. (And then use it in the formatter, too.)
            jsonFieldMap = CreateJsonFieldMap(fieldsInNumberOrder);
            file.DescriptorPool.AddSymbol(this);
            Fields = new FieldCollection(this);
        }
Example #2
0
        internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedClrTypeInfo generatedCodeInfo)
            : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
        {
            Proto          = proto;
            Parser         = generatedCodeInfo?.Parser;
            ClrType        = generatedCodeInfo?.ClrType;
            ContainingType = parent;

            // If generatedCodeInfo is null, we just won't generate an accessor for any fields.
            Oneofs = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.OneofDecl,
                (oneof, index) =>
                new OneofDescriptor(oneof, file, this, index, generatedCodeInfo?.OneofNames[index]));

            NestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.NestedType,
                (type, index) =>
                new MessageDescriptor(type, file, this, index, generatedCodeInfo?.NestedTypes[index]));

            EnumTypes = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.EnumType,
                (type, index) =>
                new EnumDescriptor(type, file, this, index, generatedCodeInfo?.NestedEnums[index]));

            Extensions = new ExtensionCollection(this, generatedCodeInfo?.Extensions);

            fieldsInDeclarationOrder = DescriptorUtil.ConvertAndMakeReadOnly(
                proto.Field,
                (field, index) =>
                new FieldDescriptor(field, file, this, index, generatedCodeInfo?.PropertyNames[index], null));
            fieldsInNumberOrder = new ReadOnlyCollection <FieldDescriptor>(fieldsInDeclarationOrder.OrderBy(field => field.FieldNumber).ToArray());
            // TODO: Use field => field.Proto.JsonName when we're confident it's appropriate. (And then use it in the formatter, too.)
            jsonFieldMap = CreateJsonFieldMap(fieldsInNumberOrder);
            file.DescriptorPool.AddSymbol(this);
            Fields = new FieldCollection(this);
        }
Example #3
0
        internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedCodeInfo generatedCodeInfo) : base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
        {
            MessageDescriptor __4__this;

            while (true)
            {
IL_247:
                uint arg_20A_0 = 4043199534u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_20A_0 ^ 3788346645u)) % 12u)
                    {
                    case 0u:
                        this.< ContainingType > k__BackingField = parent;
                        arg_20A_0 = (num * 1002898729u ^ 1601684763u);
                        continue;

                    case 1u:
                    {
                        GeneratedCodeInfo expr_1D9 = generatedCodeInfo;
                        this.< Parser > k__BackingField = ((expr_1D9 != null) ? expr_1D9.Parser : null);
                        arg_20A_0 = 2694476678u;
                        continue;
                    }

                    case 2u:
                        file.DescriptorPool.AddSymbol(this);
                        this.Fieldsk__BackingField = new MessageDescriptor.FieldCollection(this);
                        arg_20A_0 = (num * 174268781u ^ 339015310u);
                        continue;

                    case 3u:
                        goto IL_247;

                    case 4u:
                        this.< NestedTypes > k__BackingField = DescriptorUtil.ConvertAndMakeReadOnly <DescriptorProto, MessageDescriptor>(proto.NestedType, (DescriptorProto type, int index) => new MessageDescriptor(type, file, __4__this, index, generatedCodeInfo.NestedTypes[index]));
                        arg_20A_0 = (num * 1204710165u ^ 359963217u);
                        continue;

                    case 5u:
                    {
                        IEnumerable <FieldDescriptor>  arg_161_0 = this.fieldsInNumberOrder;
                        Func <FieldDescriptor, string> arg_161_1;
                        if ((arg_161_1 = MessageDescriptor.__c.__9__4_5) == null)
                        {
                            arg_161_1 = (MessageDescriptor.__c.__9__4_5 = new Func <FieldDescriptor, string>(MessageDescriptor.__c.__9.<.ctor > b__4_5));
                        }
                        this.jsonFieldMap = new ReadOnlyDictionary <string, FieldDescriptor>(arg_161_0.ToDictionary(arg_161_1));
                        arg_20A_0         = 3491112463u;
                        continue;
                    }

                    case 6u:
                    {
                        this.fieldsInDeclarationOrder = DescriptorUtil.ConvertAndMakeReadOnly <FieldDescriptorProto, FieldDescriptor>(proto.Field, delegate(FieldDescriptorProto field, int index)
                            {
                                FileDescriptor arg_26_1    = file;
                                MessageDescriptor arg_26_2 = __4__this;
                                GeneratedCodeInfo expr_14  = generatedCodeInfo;
                                return(new FieldDescriptor(field, arg_26_1, arg_26_2, index, (expr_14 != null) ? expr_14.PropertyNames[index] : null));
                            });
                        IEnumerable <FieldDescriptor> arg_11D_0 = this.fieldsInDeclarationOrder;
                        Func <FieldDescriptor, int>   arg_11D_1;
                        if ((arg_11D_1 = MessageDescriptor.__c.__9__4_4) == null)
                        {
                            arg_11D_1 = (MessageDescriptor.__c.__9__4_4 = new Func <FieldDescriptor, int>(MessageDescriptor.__c.__9.<.ctor > b__4_4));
                        }
                        this.fieldsInNumberOrder = new ReadOnlyCollection <FieldDescriptor>(arg_11D_0.OrderBy(arg_11D_1).ToArray <FieldDescriptor>());
                        arg_20A_0 = 2414391428u;
                        continue;
                    }

                    case 7u:
                    {
                        GeneratedCodeInfo expr_BF = generatedCodeInfo;
                        this.< ClrType > k__BackingField = ((expr_BF != null) ? expr_BF.ClrType : null);
                        arg_20A_0 = 3870743541u;
                        continue;
                    }

                    case 8u:
                        this.< EnumTypes > k__BackingField = DescriptorUtil.ConvertAndMakeReadOnly <EnumDescriptorProto, EnumDescriptor>(proto.EnumType, (EnumDescriptorProto type, int index) => new EnumDescriptor(type, file, __4__this, index, generatedCodeInfo.NestedEnums[index]));
                        arg_20A_0 = (num * 3914277205u ^ 2964567391u);
                        continue;

                    case 10u:
                        this.< Oneofs > k__BackingField = DescriptorUtil.ConvertAndMakeReadOnly <OneofDescriptorProto, OneofDescriptor>(proto.OneofDecl, (OneofDescriptorProto oneof, int index) => new OneofDescriptor(oneof, file, __4__this, index, generatedCodeInfo.OneofNames[index]));
                        arg_20A_0 = (num * 3879854900u ^ 3765292269u);
                        continue;

                    case 11u:
                        __4__this = this;
                        this.< Proto > k__BackingField = proto;
                        arg_20A_0 = (num * 1105444768u ^ 1991989292u);
                        continue;
                    }
                    return;
                }
            }
        }