private static unsafe void GenerateMetadataForProperty(PropertyAnalysis property, byte *pMetadataBlob, ref uint offset, uint blobSize) { Debug.Assert(property != null); Debug.Assert(pMetadataBlob != null); // Check if this property is a nested struct. InvokeTypeInfo invokeTypeInfo = property.typeInfo as InvokeTypeInfo; if (invokeTypeInfo != null) { // Each nested struct is serialized as: // TypeCode.Object : 4 bytes // Number of properties : 4 bytes // Property description 0...N // Nested struct property name : NULL-terminated string. EventPipeMetadataGenerator.WriteToBuffer(pMetadataBlob, blobSize, ref offset, (uint)TypeCode.Object); // Get the set of properties to be serialized. PropertyAnalysis[] properties = invokeTypeInfo.properties; if (properties != null) { // Write the count of serializable properties. EventPipeMetadataGenerator.WriteToBuffer(pMetadataBlob, blobSize, ref offset, (uint)properties.Length); foreach (PropertyAnalysis prop in properties) { GenerateMetadataForProperty(prop, pMetadataBlob, ref offset, blobSize); } } else { // This struct has zero serializable properties so we just write the property count. EventPipeMetadataGenerator.WriteToBuffer(pMetadataBlob, blobSize, ref offset, (uint)0); } // Write the property name. fixed(char *pPropertyName = property.name) { EventPipeMetadataGenerator.WriteToBuffer(pMetadataBlob, blobSize, ref offset, (byte *)pPropertyName, ((uint)property.name.Length + 1) * 2); } } else { // Each primitive type is serialized as: // TypeCode : 4 bytes // PropertyName : NULL-terminated string TypeCode typeCode = GetTypeCodeExtended(property.typeInfo.DataType); Debug.Assert(typeCode != TypeCode.Object); // Write the type code. EventPipeMetadataGenerator.WriteToBuffer(pMetadataBlob, blobSize, ref offset, (uint)typeCode); // Write the property name. fixed(char *pPropertyName = property.name) { EventPipeMetadataGenerator.WriteToBuffer(pMetadataBlob, blobSize, ref offset, (byte *)pPropertyName, ((uint)property.name.Length + 1) * 2); } } }
// Token: 0x06003532 RID: 13618 RVA: 0x000CE574 File Offset: 0x000CC774 public static PropertyAccessor <ContainerType> Create(PropertyAnalysis property) { Type returnType = property.getterInfo.ReturnType; if (!Statics.IsValueType(typeof(ContainerType))) { if (returnType == typeof(int)) { return(new ClassPropertyWriter <ContainerType, int>(property)); } if (returnType == typeof(long)) { return(new ClassPropertyWriter <ContainerType, long>(property)); } if (returnType == typeof(string)) { return(new ClassPropertyWriter <ContainerType, string>(property)); } } return(new NonGenericProperytWriter <ContainerType>(property)); }
private static uint GetMetadataLengthForProperty(PropertyAnalysis property) { Debug.Assert(property != null); uint ret = 0; // Check if this property is a nested struct. InvokeTypeInfo invokeTypeInfo = property.typeInfo as InvokeTypeInfo; if (invokeTypeInfo != null) { // Each nested struct is serialized as: // TypeCode.Object : 4 bytes // Number of properties : 4 bytes // Property description 0...N // Nested struct property name : NULL-terminated string. ret += sizeof(uint) // TypeCode + sizeof(uint); // Property count // Get the set of properties to be serialized. PropertyAnalysis[] properties = invokeTypeInfo.properties; if (properties != null) { foreach (PropertyAnalysis prop in properties) { ret += GetMetadataLengthForProperty(prop); } } // Add the size of the property name. ret += (uint)((property.name.Length + 1) * 2); } else { ret += (uint)(sizeof(uint) + ((property.name.Length + 1) * 2)); } return(ret); }
// Token: 0x06003537 RID: 13623 RVA: 0x000CE678 File Offset: 0x000CC878 public StructPropertyWriter(PropertyAnalysis property) { this.valueTypeInfo = (TraceLoggingTypeInfo <ValueType>)property.typeInfo; this.getter = (StructPropertyWriter <ContainerType, ValueType> .Getter)Statics.CreateDelegate(typeof(StructPropertyWriter <ContainerType, ValueType> .Getter), property.getterInfo); }
// Token: 0x06003534 RID: 13620 RVA: 0x000CE5F7 File Offset: 0x000CC7F7 public NonGenericProperytWriter(PropertyAnalysis property) { this.getterInfo = property.getterInfo; this.typeInfo = property.typeInfo; }