/// <summary>
        /// Constructs an instance that will expect messages using the given
        /// descriptor. Normally <paramref name="baseDescriptor"/> should be
        /// a descriptor for TestAllTypes. However, if extensionRegistry is non-null,
        /// then baseDescriptor should be for TestAllExtensions instead, and instead of
        /// reading and writing normal fields, the tester will read and write extensions.
        /// All of the TestAllExtensions extensions must be registered in the registry.
        /// </summary>
        private ReflectionTester(MessageDescriptor baseDescriptor,
                                 ExtensionRegistry extensionRegistry)
        {
            this.baseDescriptor = baseDescriptor;
            this.extensionRegistry = extensionRegistry;

            this.file = baseDescriptor.File;
            Assert.AreEqual(1, file.Dependencies.Count);
            this.importFile = file.Dependencies[0];

            MessageDescriptor testAllTypes;
            if (baseDescriptor.Name == "TestAllTypes")
            {
                testAllTypes = baseDescriptor;
            }
            else
            {
                testAllTypes = file.FindTypeByName<MessageDescriptor>("TestAllTypes");
                Assert.NotNull(testAllTypes);
            }

            if (extensionRegistry == null)
            {
                // Use testAllTypes, rather than baseDescriptor, to allow
                // initialization using TestPackedTypes descriptors. These objects
                // won't be used by the methods for packed fields.
                this.optionalGroup =
                    testAllTypes.FindDescriptor<MessageDescriptor>("OptionalGroup");
                this.repeatedGroup =
                    testAllTypes.FindDescriptor<MessageDescriptor>("RepeatedGroup");
            }
            else
            {
                this.optionalGroup =
                    file.FindTypeByName<MessageDescriptor>("OptionalGroup_extension");
                this.repeatedGroup =
                    file.FindTypeByName<MessageDescriptor>("RepeatedGroup_extension");
            }
            this.nestedMessage = testAllTypes.FindDescriptor<MessageDescriptor>("NestedMessage");
            this.foreignMessage = file.FindTypeByName<MessageDescriptor>("ForeignMessage");
            this.importMessage = importFile.FindTypeByName<MessageDescriptor>("ImportMessage");

            this.nestedEnum = testAllTypes.FindDescriptor<EnumDescriptor>("NestedEnum");
            this.foreignEnum = file.FindTypeByName<EnumDescriptor>("ForeignEnum");
            this.importEnum = importFile.FindTypeByName<EnumDescriptor>("ImportEnum");

            Assert.NotNull(optionalGroup);
            Assert.NotNull(repeatedGroup);
            Assert.NotNull(nestedMessage);
            Assert.NotNull(foreignMessage);
            Assert.NotNull(importMessage);
            Assert.NotNull(nestedEnum);
            Assert.NotNull(foreignEnum);
            Assert.NotNull(importEnum);

            this.nestedB = nestedMessage.FindDescriptor<FieldDescriptor>("bb");
            this.foreignC = foreignMessage.FindDescriptor<FieldDescriptor>("c");
            this.importD = importMessage.FindDescriptor<FieldDescriptor>("d");
            this.nestedFoo = nestedEnum.FindValueByName("FOO");
            this.nestedBar = nestedEnum.FindValueByName("BAR");
            this.nestedBaz = nestedEnum.FindValueByName("BAZ");
            this.foreignFoo = foreignEnum.FindValueByName("FOREIGN_FOO");
            this.foreignBar = foreignEnum.FindValueByName("FOREIGN_BAR");
            this.foreignBaz = foreignEnum.FindValueByName("FOREIGN_BAZ");
            this.importFoo = importEnum.FindValueByName("IMPORT_FOO");
            this.importBar = importEnum.FindValueByName("IMPORT_BAR");
            this.importBaz = importEnum.FindValueByName("IMPORT_BAZ");

            this.groupA = optionalGroup.FindDescriptor<FieldDescriptor>("a");
            this.repeatedGroupA = repeatedGroup.FindDescriptor<FieldDescriptor>("a");

            Assert.NotNull(groupA);
            Assert.NotNull(repeatedGroupA);
            Assert.NotNull(nestedB);
            Assert.NotNull(foreignC);
            Assert.NotNull(importD);
            Assert.NotNull(nestedFoo);
            Assert.NotNull(nestedBar);
            Assert.NotNull(nestedBaz);
            Assert.NotNull(foreignFoo);
            Assert.NotNull(foreignBar);
            Assert.NotNull(foreignBaz);
            Assert.NotNull(importFoo);
            Assert.NotNull(importBar);
            Assert.NotNull(importBaz);
        }
 private void GetMessage(Message msg, MessageDescriptor ci)
 {
     // enter next message parsing level.
     var prev = PushLimit();
     while (_storage.Limit > 0)
     {
         // read next PB value from the stream.
         var id = _storage.GetIntPB();
         switch (_wirefmt = id & 0x7)
         {
             case Pbs.iVarInt: _data = _storage.GetLongPB(); break;
             case Pbs.iBit64: _data = _storage.GetB64(); break;
             case Pbs.iString:
                 _fsz = _storage.GetIntPB();
                 if (_fsz <= _storage.Limit)
                     break;
                 throw new ProtoBufException("nested blob size");
             case Pbs.iBit32: _data = _storage.GetB32(); break;
             default: throw new ProtoBufException("unsupported wire format");
         }
         // match PB field descriptor by id.
         var fi = ci.Find(id);
         if (fi != null)
             if(fi.Id == id)
                 msg.Get(fi, this);
             else TryReadPacked(fi, msg);
         else
             if (_fsz > 0) { _storage.Skip(_fsz); _fsz = 0; }
     }
     // exit message segment parsing.
     if (_storage.Limit < 0)
         throw new ProtoBufException("message size out of sync");
     _level--;
     PopLimit(prev);
 }
 public UnknownFieldSetTest()
 {
     descriptor = TestAllTypes.Descriptor;
     allFields = TestUtil.GetAllSet();
     allFieldsData = allFields.ToByteString();
     emptyMessage = TestEmptyMessage.ParseFrom(allFieldsData);
     unknownFields = emptyMessage.UnknownFields;
 }
Exemple #4
0
        internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, string clrName)
            : base(file, file.ComputeFullName(parent, proto.Name), index)
        {
            this.proto = proto;
            containingType = parent;

            file.DescriptorPool.AddSymbol(this);
            accessor = CreateAccessor(clrName);
        }
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("JsonValueTest");
			_init_ds_(_boot_ds_, new JsonValueTest(),
				new FieldDescriptor("name", 10, 5),
				new FieldDescriptor("data", 18, 15, Struct.Descriptor)
			);
			return _boot_ds_;
		}
 /// <summary>
 /// Initializes an instance of the ReportItem class.
 /// </summary>
 /// <param name="descriptor">A message descriptor.</param>
 /// <param name="sourceFile">A source file.</param>
 /// <param name="sourceSpan">A source span.</param>
 /// <param name="sourceLine">A source line.</param>
 /// <param name="args">Some arguments required by the message descriptor.</param>
 public ReportItem(MessageDescriptor descriptor, SourceFile sourceFile, SourceSpan sourceSpan,
                   TokenList sourceLine, params string[] args)
 {
     MessageDescriptor = descriptor;
     SourceFile = sourceFile;
     SourceSpan = sourceSpan;
     SourceLine = sourceLine;
     Arguments = args;
 }
        internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file,
                                 MessageDescriptor parent, int index)
        {
            this.proto = proto;
            this.file = file;
            this.index = index;

            containingType = parent;
            fieldCount = 0;
        }
Exemple #8
0
 static Item()
 {
     byte[] numArray = Convert.FromBase64String("Cg9ydXN0L2l0ZW0ucHJvdG8SCVJ1c3RQcm90bxoTcnVzdC9pdGVtX21vZC5wcm90byKaAQoESXRlbRIKCgJpZBgBIAIoBRIMCgRuYW1lGAIgASgJEgwKBHNsb3QYAyABKAUSDQoFY291bnQYBCABKAUSEAoIc3Vic2xvdHMYBiABKAUSEQoJY29uZGl0aW9uGAcgASgCEhQKDG1heGNvbmRpdGlvbhgIIAEoAhIgCgdzdWJpdGVtGAUgAygLMg8uUnVzdFByb3RvLkl0ZW1CAkgB");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         RustProto.Proto.Item.descriptor = root;
         RustProto.Proto.Item.internal__static_RustProto_Item__Descriptor = RustProto.Proto.Item.Descriptor.MessageTypes[0];
         RustProto.Proto.Item.internal__static_RustProto_Item__FieldAccessorTable = new FieldAccessorTable<RustProto.Item, RustProto.Item.Builder>(RustProto.Proto.Item.internal__static_RustProto_Item__Descriptor, new string[] { "Id", "Name", "Slot", "Count", "Subslots", "Condition", "Maxcondition", "Subitem" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[] { RustProto.Proto.ItemMod.Descriptor }, internalDescriptorAssigner);
 }
Exemple #9
0
 static Blueprint()
 {
     byte[] numArray = Convert.FromBase64String("ChRydXN0L2JsdWVwcmludC5wcm90bxIJUnVzdFByb3RvIhcKCUJsdWVwcmludBIKCgJpZBgBIAIoBUICSAE=");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         RustProto.Proto.Blueprint.descriptor = root;
         RustProto.Proto.Blueprint.internal__static_RustProto_Blueprint__Descriptor = RustProto.Proto.Blueprint.Descriptor.MessageTypes[0];
         RustProto.Proto.Blueprint.internal__static_RustProto_Blueprint__FieldAccessorTable = new FieldAccessorTable<RustProto.Blueprint, RustProto.Blueprint.Builder>(RustProto.Proto.Blueprint.internal__static_RustProto_Blueprint__Descriptor, new string[] { "Id" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[0], internalDescriptorAssigner);
 }
Exemple #10
0
 static Vitals()
 {
     byte[] numArray = Convert.FromBase64String("ChFydXN0L3ZpdGFscy5wcm90bxIJUnVzdFByb3RvIu8BCgZWaXRhbHMSEwoGaGVhbHRoGAEgASgCOgMxMDASFQoJaHlkcmF0aW9uGAIgASgCOgIzMBIWCghjYWxvcmllcxgDIAEoAjoEMTAwMBIUCglyYWRpYXRpb24YBCABKAI6ATASGQoOcmFkaWF0aW9uX2FudGkYBSABKAI6ATASFgoLYmxlZWRfc3BlZWQYBiABKAI6ATASFAoJYmxlZWRfbWF4GAcgASgCOgEwEhUKCmhlYWxfc3BlZWQYCCABKAI6ATASEwoIaGVhbF9tYXgYCSABKAI6ATASFgoLdGVtcGVyYXR1cmUYCiABKAI6ATBCAkgB");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         RustProto.Proto.Vitals.descriptor = root;
         RustProto.Proto.Vitals.internal__static_RustProto_Vitals__Descriptor = RustProto.Proto.Vitals.Descriptor.MessageTypes[0];
         RustProto.Proto.Vitals.internal__static_RustProto_Vitals__FieldAccessorTable = new FieldAccessorTable<RustProto.Vitals, RustProto.Vitals.Builder>(RustProto.Proto.Vitals.internal__static_RustProto_Vitals__Descriptor, new string[] { "Health", "Hydration", "Calories", "Radiation", "RadiationAnti", "BleedSpeed", "BleedMax", "HealSpeed", "HealMax", "Temperature" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[0], internalDescriptorAssigner);
 }
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("ProtoMessageSample", Pbs.iNone);
			_init_ds_(_boot_ds_, new ProtoMessageSample(),
				new FieldDescriptor("id", 8, 129),
				new FieldDescriptor("name", 18, 5),
				new FieldDescriptor("align", 24, 16, EnumDescriptors.Align),
				new FieldDescriptor("weights", 33, 332)
			);
			return _boot_ds_;
		}
Exemple #12
0
 static ItemMod()
 {
     byte[] numArray = Convert.FromBase64String("ChNydXN0L2l0ZW1fbW9kLnByb3RvEglSdXN0UHJvdG8iIwoHSXRlbU1vZBIKCgJpZBgBIAIoBRIMCgRuYW1lGAIgASgJQgJIAQ==");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         RustProto.Proto.ItemMod.descriptor = root;
         RustProto.Proto.ItemMod.internal__static_RustProto_ItemMod__Descriptor = RustProto.Proto.ItemMod.Descriptor.MessageTypes[0];
         RustProto.Proto.ItemMod.internal__static_RustProto_ItemMod__FieldAccessorTable = new FieldAccessorTable<RustProto.ItemMod, RustProto.ItemMod.Builder>(RustProto.Proto.ItemMod.internal__static_RustProto_ItemMod__Descriptor, new string[] { "Id", "Name" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[0], internalDescriptorAssigner);
 }
Exemple #13
0
 static Error()
 {
     byte[] numArray = Convert.FromBase64String("ChBydXN0L2Vycm9yLnByb3RvEglSdXN0UHJvdG8iKAoFRXJyb3ISDgoGc3RhdHVzGAEgAigJEg8KB21lc3NhZ2UYAiACKAkiKQoJR2FtZUVycm9yEg0KBWVycm9yGAEgAigJEg0KBXRyYWNlGAIgAigJQgJIAQ==");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         RustProto.Proto.Error.descriptor = root;
         RustProto.Proto.Error.internal__static_RustProto_Error__Descriptor = RustProto.Proto.Error.Descriptor.MessageTypes[0];
         RustProto.Proto.Error.internal__static_RustProto_Error__FieldAccessorTable = new FieldAccessorTable<RustProto.Error, RustProto.Error.Builder>(RustProto.Proto.Error.internal__static_RustProto_Error__Descriptor, new string[] { "Status", "Message" });
         RustProto.Proto.Error.internal__static_RustProto_GameError__Descriptor = RustProto.Proto.Error.Descriptor.MessageTypes[1];
         RustProto.Proto.Error.internal__static_RustProto_GameError__FieldAccessorTable = new FieldAccessorTable<GameError, GameError.Builder>(RustProto.Proto.Error.internal__static_RustProto_GameError__Descriptor, new string[] { "Error", "Trace" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[0], internalDescriptorAssigner);
 }
Exemple #14
0
 static Avatar()
 {
     byte[] numArray = Convert.FromBase64String("ChFydXN0L2F2YXRhci5wcm90bxIJUnVzdFByb3RvGhRydXN0L2JsdWVwcmludC5wcm90bxoPcnVzdC9pdGVtLnByb3RvGhFydXN0L2NvbW1vbi5wcm90bxoRcnVzdC92aXRhbHMucHJvdG8iqAIKBkF2YXRhchIeCgNwb3MYASABKAsyES5SdXN0UHJvdG8uVmVjdG9yEiIKA2FuZxgCIAEoCzIVLlJ1c3RQcm90by5RdWF0ZXJuaW9uEiEKBnZpdGFscxgDIAEoCzIRLlJ1c3RQcm90by5WaXRhbHMSKAoKYmx1ZXByaW50cxgEIAMoCzIULlJ1c3RQcm90by5CbHVlcHJpbnQSIgoJaW52ZW50b3J5GAUgAygLMg8uUnVzdFByb3RvLkl0ZW0SIQoId2VhcmFibGUYBiADKAsyDy5SdXN0UHJvdG8uSXRlbRIdCgRiZWx0GAcgAygLMg8uUnVzdFByb3RvLkl0ZW0SJwoJYXdheUV2ZW50GAggASgLMhQuUnVzdFByb3RvLkF3YXlFdmVudCKZAQoJQXdheUV2ZW50EjAKBHR5cGUYASACKA4yIi5SdXN0UHJvdG8uQXdheUV2ZW50LkF3YXlFdmVudFR5cGUSEQoJdGltZXN0YW1wGAIgAigFEhIKCmluc3RpZ2F0b3IYAyABKAQiMwoNQXdheUV2ZW50VHlwZRILCgdVTktOT1dOEAASCwoHU0xVTUJFUhABEggKBERJRUQQAkICSAE=");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         RustProto.Proto.Avatar.descriptor = root;
         RustProto.Proto.Avatar.internal__static_RustProto_Avatar__Descriptor = RustProto.Proto.Avatar.Descriptor.MessageTypes[0];
         RustProto.Proto.Avatar.internal__static_RustProto_Avatar__FieldAccessorTable = new FieldAccessorTable<RustProto.Avatar, RustProto.Avatar.Builder>(RustProto.Proto.Avatar.internal__static_RustProto_Avatar__Descriptor, new string[] { "Pos", "Ang", "Vitals", "Blueprints", "Inventory", "Wearable", "Belt", "AwayEvent" });
         RustProto.Proto.Avatar.internal__static_RustProto_AwayEvent__Descriptor = RustProto.Proto.Avatar.Descriptor.MessageTypes[1];
         RustProto.Proto.Avatar.internal__static_RustProto_AwayEvent__FieldAccessorTable = new FieldAccessorTable<AwayEvent, AwayEvent.Builder>(RustProto.Proto.Avatar.internal__static_RustProto_AwayEvent__Descriptor, new string[] { "Type", "Timestamp", "Instigator" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[] { RustProto.Proto.Blueprint.Descriptor, RustProto.Proto.Item.Descriptor, Common.Descriptor, RustProto.Proto.Vitals.Descriptor }, internalDescriptorAssigner);
 }
Exemple #15
0
 static Common()
 {
     byte[] numArray = Convert.FromBase64String("ChFydXN0L2NvbW1vbi5wcm90bxIJUnVzdFByb3RvIjIKBlZlY3RvchIMCgF4GAEgASgCOgEwEgwKAXkYAiABKAI6ATASDAoBehgDIAEoAjoBMCJECgpRdWF0ZXJuaW9uEgwKAXgYASABKAI6ATASDAoBeRgCIAEoAjoBMBIMCgF6GAMgASgCOgEwEgwKAXcYBCABKAI6ATBCAkgB");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         Common.descriptor = root;
         Common.internal__static_RustProto_Vector__Descriptor = Common.Descriptor.MessageTypes[0];
         Common.internal__static_RustProto_Vector__FieldAccessorTable = new FieldAccessorTable<Vector, Vector.Builder>(Common.internal__static_RustProto_Vector__Descriptor, new string[] { "X", "Y", "Z" });
         Common.internal__static_RustProto_Quaternion__Descriptor = Common.Descriptor.MessageTypes[1];
         Common.internal__static_RustProto_Quaternion__FieldAccessorTable = new FieldAccessorTable<Quaternion, Quaternion.Builder>(Common.internal__static_RustProto_Quaternion__Descriptor, new string[] { "X", "Y", "Z", "W" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[0], internalDescriptorAssigner);
 }
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("CachedRequest");
			_init_ds_(_boot_ds_, new CachedRequest(),
				new FieldDescriptor("Opcode", 8, 1),
				new FieldDescriptor("Data", 18, 6),
				new FieldDescriptor("Key", 26, 6),
				new FieldDescriptor("Expires", 32, 1),
				new FieldDescriptor("Flags", 40, 2),
				new FieldDescriptor("Cas", 48, 2),
				new FieldDescriptor("Delta", 56, 2)
			);
			return _boot_ds_;
		}
Exemple #17
0
        internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, Type generatedType)
            : base(file, file.ComputeFullName(parent, proto.Name), index)
        {
            this.proto = proto;
            this.generatedType = generatedType;
            containingType = parent;

            if (proto.Value.Count == 0)
            {
                // We cannot allow enums with no values because this would mean there
                // would be no valid default value for fields of this type.
                throw new DescriptorValidationException(this, "Enums must contain at least one value.");
            }

            values = DescriptorUtil.ConvertAndMakeReadOnly(proto.Value,
                                                           (value, i) => new EnumValueDescriptor(value, file, this, i));

            File.DescriptorPool.AddSymbol(this);
        }
Exemple #18
0
 static Worldsave()
 {
     byte[] numArray = Convert.FromBase64String("ChRydXN0L3dvcmxkc2F2ZS5wcm90bxIJUnVzdFByb3RvGg9ydXN0L2l0ZW0ucHJvdG8aEXJ1c3QvY29tbW9uLnByb3RvGhFydXN0L3ZpdGFscy5wcm90byIpCgpvYmplY3REb29yEg0KBVN0YXRlGAEgASgFEgwKBE9wZW4YAiABKAgiNgoQb2JqZWN0RGVwbG95YWJsZRIRCglDc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CAkgB");
     FileDescriptor.InternalDescriptorAssigner internalDescriptorAssigner = (FileDescriptor root) => {
         Worldsave.descriptor = root;
         Worldsave.internal__static_RustProto_objectDoor__Descriptor = Worldsave.Descriptor.MessageTypes[0];
         Worldsave.internal__static_RustProto_objectDoor__FieldAccessorTable = new FieldAccessorTable<objectDoor, objectDoor.Builder>(Worldsave.internal__static_RustProto_objectDoor__Descriptor, new string[] { "State", "Open" });
         Worldsave.internal__static_RustProto_objectDeployable__Descriptor = Worldsave.Descriptor.MessageTypes[1];
         Worldsave.internal__static_RustProto_objectDeployable__FieldAccessorTable = new FieldAccessorTable<objectDeployable, objectDeployable.Builder>(Worldsave.internal__static_RustProto_objectDeployable__Descriptor, new string[] { "CreatorID", "OwnerID" });
         Worldsave.internal__static_RustProto_objectStructMaster__Descriptor = Worldsave.Descriptor.MessageTypes[2];
         Worldsave.internal__static_RustProto_objectStructMaster__FieldAccessorTable = new FieldAccessorTable<objectStructMaster, objectStructMaster.Builder>(Worldsave.internal__static_RustProto_objectStructMaster__Descriptor, new string[] { "ID", "DecayDelay", "CreatorID", "OwnerID" });
         Worldsave.internal__static_RustProto_objectStructComponent__Descriptor = Worldsave.Descriptor.MessageTypes[3];
         Worldsave.internal__static_RustProto_objectStructComponent__FieldAccessorTable = new FieldAccessorTable<objectStructComponent, objectStructComponent.Builder>(Worldsave.internal__static_RustProto_objectStructComponent__Descriptor, new string[] { "ID", "MasterID", "MasterViewID" });
         Worldsave.internal__static_RustProto_objectFireBarrel__Descriptor = Worldsave.Descriptor.MessageTypes[4];
         Worldsave.internal__static_RustProto_objectFireBarrel__FieldAccessorTable = new FieldAccessorTable<objectFireBarrel, objectFireBarrel.Builder>(Worldsave.internal__static_RustProto_objectFireBarrel__Descriptor, new string[] { "OnFire" });
         Worldsave.internal__static_RustProto_objectNetInstance__Descriptor = Worldsave.Descriptor.MessageTypes[5];
         Worldsave.internal__static_RustProto_objectNetInstance__FieldAccessorTable = new FieldAccessorTable<objectNetInstance, objectNetInstance.Builder>(Worldsave.internal__static_RustProto_objectNetInstance__Descriptor, new string[] { "ServerPrefab", "OwnerPrefab", "ProxyPrefab", "GroupID" });
         Worldsave.internal__static_RustProto_objectNGCInstance__Descriptor = Worldsave.Descriptor.MessageTypes[6];
         Worldsave.internal__static_RustProto_objectNGCInstance__FieldAccessorTable = new FieldAccessorTable<objectNGCInstance, objectNGCInstance.Builder>(Worldsave.internal__static_RustProto_objectNGCInstance__Descriptor, new string[] { "ID", "Data" });
         Worldsave.internal__static_RustProto_objectCoords__Descriptor = Worldsave.Descriptor.MessageTypes[7];
         Worldsave.internal__static_RustProto_objectCoords__FieldAccessorTable = new FieldAccessorTable<objectCoords, objectCoords.Builder>(Worldsave.internal__static_RustProto_objectCoords__Descriptor, new string[] { "Pos", "OldPos", "Rot", "OldRot" });
         Worldsave.internal__static_RustProto_objectICarriableTrans__Descriptor = Worldsave.Descriptor.MessageTypes[8];
         Worldsave.internal__static_RustProto_objectICarriableTrans__FieldAccessorTable = new FieldAccessorTable<objectICarriableTrans, objectICarriableTrans.Builder>(Worldsave.internal__static_RustProto_objectICarriableTrans__Descriptor, new string[] { "TransCarrierID" });
         Worldsave.internal__static_RustProto_objectTakeDamage__Descriptor = Worldsave.Descriptor.MessageTypes[9];
         Worldsave.internal__static_RustProto_objectTakeDamage__FieldAccessorTable = new FieldAccessorTable<objectTakeDamage, objectTakeDamage.Builder>(Worldsave.internal__static_RustProto_objectTakeDamage__Descriptor, new string[] { "Health" });
         Worldsave.internal__static_RustProto_objectSleepingAvatar__Descriptor = Worldsave.Descriptor.MessageTypes[10];
         Worldsave.internal__static_RustProto_objectSleepingAvatar__FieldAccessorTable = new FieldAccessorTable<objectSleepingAvatar, objectSleepingAvatar.Builder>(Worldsave.internal__static_RustProto_objectSleepingAvatar__Descriptor, new string[] { "FootArmor", "LegArmor", "TorsoArmor", "HeadArmor", "Timestamp", "Vitals" });
         Worldsave.internal__static_RustProto_objectLockable__Descriptor = Worldsave.Descriptor.MessageTypes[11];
         Worldsave.internal__static_RustProto_objectLockable__FieldAccessorTable = new FieldAccessorTable<objectLockable, objectLockable.Builder>(Worldsave.internal__static_RustProto_objectLockable__Descriptor, new string[] { "Password", "Locked", "Users" });
         Worldsave.internal__static_RustProto_SavedObject__Descriptor = Worldsave.Descriptor.MessageTypes[12];
         Worldsave.internal__static_RustProto_SavedObject__FieldAccessorTable = new FieldAccessorTable<SavedObject, SavedObject.Builder>(Worldsave.internal__static_RustProto_SavedObject__Descriptor, new string[] { "Id", "Door", "Inventory", "Deployable", "StructMaster", "StructComponent", "FireBarrel", "NetInstance", "Coords", "NgcInstance", "CarriableTrans", "TakeDamage", "SortOrder", "SleepingAvatar", "Lockable" });
         Worldsave.internal__static_RustProto_WorldSave__Descriptor = Worldsave.Descriptor.MessageTypes[13];
         Worldsave.internal__static_RustProto_WorldSave__FieldAccessorTable = new FieldAccessorTable<WorldSave, WorldSave.Builder>(Worldsave.internal__static_RustProto_WorldSave__Descriptor, new string[] { "SceneObject", "InstanceObject" });
         return null;
     };
     FileDescriptor.InternalBuildGeneratedFileFrom(numArray, new FileDescriptor[] { RustProto.Proto.Item.Descriptor, Common.Descriptor, RustProto.Proto.Vitals.Descriptor }, internalDescriptorAssigner);
 }
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("Any", Pbs.iNone);
			_init_ds_(_boot_ds_, new Any(),
				new FieldDescriptor("type_url", 10, 5),
				new FieldDescriptor("value", 18, 6)
			);
			return _boot_ds_;
		}
 /// <summary>
 /// Central interception point for well-known type formatting. Any well-known types which
 /// don't need special handling can fall back to WriteMessage. We avoid assuming that the
 /// values are using the embedded well-known types, in order to allow for dynamic messages
 /// in the future.
 /// </summary>
 private void WriteWellKnownTypeValue(StringBuilder builder, MessageDescriptor descriptor, object value)
 {
     // Currently, we can never actually get here, because null values are always handled by the caller. But if we *could*,
     // this would do the right thing.
     if (value == null)
     {
         WriteNull(builder);
         return;
     }
     // For wrapper types, the value will either be the (possibly boxed) "native" value,
     // or the message itself if we're formatting it at the top level (e.g. just calling ToString on the object itself).
     // If it's the message form, we can extract the value first, which *will* be the (possibly boxed) native value,
     // and then proceed, writing it as if we were definitely in a field. (We never need to wrap it in an extra string...
     // WriteValue will do the right thing.)
     if (descriptor.IsWrapperType)
     {
         if (value is IMessage)
         {
             var message = (IMessage) value;
             value = message.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.GetValue(message);
         }
         WriteValue(builder, value);
         return;
     }
     if (descriptor.FullName == Timestamp.Descriptor.FullName)
     {
         WriteTimestamp(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == Duration.Descriptor.FullName)
     {
         WriteDuration(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == FieldMask.Descriptor.FullName)
     {
         WriteFieldMask(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == Struct.Descriptor.FullName)
     {
         WriteStruct(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == ListValue.Descriptor.FullName)
     {
         var fieldAccessor = descriptor.Fields[ListValue.ValuesFieldNumber].Accessor;
         WriteList(builder, (IList) fieldAccessor.GetValue((IMessage) value));
         return;
     }
     if (descriptor.FullName == Value.Descriptor.FullName)
     {
         WriteStructFieldValue(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == Any.Descriptor.FullName)
     {
         WriteAny(builder, (IMessage) value);
         return;
     }
     WriteMessage(builder, (IMessage) value);
 }
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("OneOfTest", Pbs.iNone);
			_init_ds_(_boot_ds_, new OneOfTest(),
				new FieldDescriptor("str", 10, 5),
				new FieldDescriptor("date", 18, 6),
				new FieldDescriptor("msg", 26, 15, Any.Descriptor),
				new FieldDescriptor("name", 34, 5),
				new FieldDescriptor("i32", 80, 1),
				new FieldDescriptor("bol", 88, 13),
				new FieldDescriptor("cha", 96, 14),
				new FieldDescriptor("si3", 112, 1025),
				new FieldDescriptor("fx3", 125, 9),
				new FieldDescriptor("ui64", 128, 2),
				new FieldDescriptor("si64", 136, 1026),
				new FieldDescriptor("i64", 144, 2),
				new FieldDescriptor("dbl", 153, 12),
				new FieldDescriptor("flt", 165, 11),
				new FieldDescriptor("dat", 168, 7)
			);
			return _boot_ds_;
		}
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("KVTest", Pbs.iNone);
			_init_ds_(_boot_ds_, new KVTest(),
				new FieldDescriptor("name", 10, 5),
				new FieldDescriptor("m1", 18, 82, _map_ds_(2, 15, Any.Descriptor)),
				new FieldDescriptor("m2", 26, 82, _map_ds_(5, 16, EnumDescriptors.Color)),
				new FieldDescriptor("m3", 34, 82, _map_ds_(1, 5))
			);
			return _boot_ds_;
		}
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("KVMap2", Pbs.iNone);
			_init_ds_(_boot_ds_, new KVMap2(),
				new FieldDescriptor("name", 10, 5),
				new FieldDescriptor("rcmap", 18, 82, _map_ds_(1, 15, KVMap2.Descriptor))
			);
			return _boot_ds_;
		}
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("CachedConfiguration");
			_init_ds_(_boot_ds_, new CachedConfiguration(),
				new FieldDescriptor("AllocPageSize", 8, 1),
				new FieldDescriptor("CacheSize", 16, 1),
				new FieldDescriptor("ReserveMemory", 24, 13),
				new FieldDescriptor("UseLargePages", 32, 13),
				new FieldDescriptor("HashTableSize", 40, 1),
				new FieldDescriptor("Address", 50, 5),
				new FieldDescriptor("Name", 58, 5)
			);
			return _boot_ds_;
		}
Exemple #25
0
 /// <summary>
 /// Central interception point for well-known type formatting. Any well-known types which
 /// don't need special handling can fall back to WriteMessage. We avoid assuming that the
 /// values are using the embedded well-known types, in order to allow for dynamic messages
 /// in the future.
 /// </summary>
 private void WriteWellKnownTypeValue(StringBuilder builder, MessageDescriptor descriptor, object value, bool inField)
 {
     if (value == null)
     {
         WriteNull(builder);
         return;
     }
     // For wrapper types, the value will either be the (possibly boxed) "native" value,
     // or the message itself if we're formatting it at the top level (e.g. just calling ToString on the object itself).
     // If it's the message form, we can extract the value first, which *will* be the (possibly boxed) native value,
     // and then proceed, writing it as if we were definitely in a field. (We never need to wrap it in an extra string...
     // WriteValue will do the right thing.)
     // TODO: Detect this differently when we have dynamic messages.
     if (descriptor.File == Int32Value.Descriptor.File)
     {
         if (value is IMessage)
         {
             var message = (IMessage) value;
             value = message.Descriptor.Fields[Wrappers.WrapperValueFieldNumber].Accessor.GetValue(message);
         }
         WriteValue(builder, value);
         return;
     }
     if (descriptor.FullName == Timestamp.Descriptor.FullName)
     {
         MaybeWrapInString(builder, value, WriteTimestamp, inField);
         return;
     }
     if (descriptor.FullName == Duration.Descriptor.FullName)
     {
         MaybeWrapInString(builder, value, WriteDuration, inField);
         return;
     }
     if (descriptor.FullName == FieldMask.Descriptor.FullName)
     {
         MaybeWrapInString(builder, value, WriteFieldMask, inField);
         return;
     }
     if (descriptor.FullName == Struct.Descriptor.FullName)
     {
         WriteStruct(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == ListValue.Descriptor.FullName)
     {
         var fieldAccessor = descriptor.Fields[ListValue.ValuesFieldNumber].Accessor;
         WriteList(builder, (IList) fieldAccessor.GetValue((IMessage) value));
         return;
     }
     if (descriptor.FullName == Value.Descriptor.FullName)
     {
         WriteStructFieldValue(builder, (IMessage) value);
         return;
     }
     WriteMessage(builder, (IMessage) value);
 }
Exemple #26
0
 /// <summary>
 /// Verifies whether all the required fields in the specified message
 /// descriptor are present in this field set, as well as whether
 /// all the embedded messages are themselves initialized.
 /// </summary>
 internal bool IsInitializedWithRespectTo(MessageDescriptor type)
 {
     foreach (FieldDescriptor field in type.Fields) {
     if (field.IsRequired && !HasField(field)) {
       return false;
     }
       }
       return IsInitialized;
 }
Exemple #27
0
 private static void AssertDescriptorPresent(TypeRegistry registry, MessageDescriptor descriptor)
 {
     Assert.AreSame(descriptor, registry.Find(descriptor.FullName));
 }
Exemple #28
0
 private static void AssertDescriptorAbsent(TypeRegistry registry, MessageDescriptor descriptor)
 {
     Assert.IsNull(registry.Find(descriptor.FullName));
 }
Exemple #29
0
 /// <summary>
 /// Central interception point for well-known type formatting. Any well-known types which
 /// don't need special handling can fall back to WriteMessage. We avoid assuming that the
 /// values are using the embedded well-known types, in order to allow for dynamic messages
 /// in the future.
 /// </summary>
 private void WriteWellKnownTypeValue(StringBuilder builder, MessageDescriptor descriptor, object value, bool inField)
 {
     if (value == null)
     {
         WriteNull(builder);
         return;
     }
     // For wrapper types, the value will be the (possibly boxed) "native" value,
     // so we can write it as if we were unconditionally writing the Value field for the wrapper type.
     if (descriptor.File == Int32Value.Descriptor.File)
     {
         WriteSingleValue(builder, descriptor.FindFieldByNumber(1), value);
         return;
     }
     if (descriptor.FullName == Timestamp.Descriptor.FullName)
     {
         MaybeWrapInString(builder, value, WriteTimestamp, inField);
         return;
     }
     if (descriptor.FullName == Duration.Descriptor.FullName)
     {
         MaybeWrapInString(builder, value, WriteDuration, inField);
         return;
     }
     if (descriptor.FullName == FieldMask.Descriptor.FullName)
     {
         MaybeWrapInString(builder, value, WriteFieldMask, inField);
         return;
     }
     if (descriptor.FullName == Struct.Descriptor.FullName)
     {
         WriteStruct(builder, (IMessage) value);
         return;
     }
     if (descriptor.FullName == ListValue.Descriptor.FullName)
     {
         var fieldAccessor = descriptor.Fields[ListValue.ValuesFieldNumber].Accessor;
         WriteList(builder, fieldAccessor, (IList) fieldAccessor.GetValue(value));
         return;
     }
     if (descriptor.FullName == Value.Descriptor.FullName)
     {
         WriteStructFieldValue(builder, (IMessage) value);
         return;
     }
     WriteMessage(builder, (IMessage) value);
 }
		private static MessageDescriptor _boot_ds() 
		{
			_boot_ds_= new MessageDescriptor_30("CachedStats");
			_init_ds_(_boot_ds_, new CachedStats(),
				new FieldDescriptor("Uptime", 8, 1),
				new FieldDescriptor("CurrentItems", 16, 2),
				new FieldDescriptor("CurrentBytes", 24, 2),
				new FieldDescriptor("TotalMemory", 32, 2),
				new FieldDescriptor("Evictions", 40, 2),
				new FieldDescriptor("Requests", 48, 2),
				new FieldDescriptor("GetHits", 56, 2),
				new FieldDescriptor("Updates", 64, 2),
				new FieldDescriptor("Misses", 72, 2),
				new FieldDescriptor("BytesOut", 80, 2),
				new FieldDescriptor("BytesIn", 88, 2),
				new FieldDescriptor("BpsIn", 96, 2),
				new FieldDescriptor("BpsOut", 104, 2),
				new FieldDescriptor("Rps", 112, 2),
				new FieldDescriptor("Address", 122, 5)
			);
			return _boot_ds_;
		}