private FieldMetadata( string name, TraceLoggingDataType dataType, EventFieldTags tags, byte countFlags, ushort fixedCount = 0, byte[]?custom = null) { if (name == null) { throw new ArgumentNullException( nameof(name), "This usually means that the object passed to Write is of a type that" + " does not support being used as the top-level object in an event," + " e.g. a primitive or built-in type."); } Statics.CheckName(name); int coreType = (int)dataType & Statics.InTypeMask; this.name = name; this.nameSize = Encoding.UTF8.GetByteCount(this.name) + 1; this.inType = (byte)(coreType | countFlags); this.outType = (byte)(((int)dataType >> 8) & Statics.OutTypeMask); this.tags = tags; this.fixedCount = fixedCount; this.custom = custom; if (countFlags != 0) { if (coreType == (int)TraceLoggingDataType.Nil) { throw new NotSupportedException(SR.EventSource_NotSupportedArrayOfNil); } if (coreType == (int)TraceLoggingDataType.Binary) { throw new NotSupportedException(SR.EventSource_NotSupportedArrayOfBinary); } if (coreType == (int)TraceLoggingDataType.Utf16String || coreType == (int)TraceLoggingDataType.MbcsString) { throw new NotSupportedException(SR.EventSource_NotSupportedArrayOfNullTerminatedString); } } if (((int)this.tags & 0xfffffff) != 0) { this.outType |= Statics.OutTypeChainFlag; } if (this.outType != 0) { this.inType |= Statics.InTypeChainFlag; } }
// Token: 0x060035D6 RID: 13782 RVA: 0x000CF170 File Offset: 0x000CD370 public static byte[] MetadataForString(string name, int prefixSize, int suffixSize, int additionalSize) { Statics.CheckName(name); int num = Encoding.UTF8.GetByteCount(name) + 3 + prefixSize + suffixSize; byte[] array = new byte[num]; ushort num2 = checked ((ushort)(num + additionalSize)); array[0] = (byte)num2; array[1] = (byte)(num2 >> 8); Encoding.UTF8.GetBytes(name, 0, name.Length, array, 2 + prefixSize); return(array); }
public static byte[] MetadataForString(string name, int prefixSize, int suffixSize, int additionalSize) { Statics.CheckName(name); int length = Encoding.UTF8.GetByteCount(name) + 3 + prefixSize + suffixSize; byte[] bytes = new byte[length]; int num1 = additionalSize; ushort num2 = checked ((ushort)(length + num1)); bytes[0] = (byte)num2; bytes[1] = (byte)((uint)num2 >> 8); Encoding.UTF8.GetBytes(name, 0, name.Length, bytes, 2 + prefixSize); return(bytes); }
/// <summary> /// A complete metadata chunk can be expressed as: /// length16 + prefix + null-terminated-utf8-name + suffix + additionalData. /// We assume that excludedData will be provided by some other means, /// but that its size is known. This function returns a blob containing /// length16 + prefix + name + suffix, with prefix and suffix initialized /// to 0's. The length16 value is initialized to the length of the returned /// blob plus additionalSize, so that the concatenation of the returned blob /// plus a blob of size additionalSize constitutes a valid metadata blob. /// </summary> /// <param name="name"> /// The name to include in the blob. /// </param> /// <param name="prefixSize"> /// Amount of space to reserve before name. For provider or field blobs, this /// should be 0. For event blobs, this is used for the tags field and will vary /// from 1 to 4, depending on how large the tags field needs to be. /// </param> /// <param name="suffixSize"> /// Amount of space to reserve after name. For example, a provider blob with no /// traits would reserve 0 extra bytes, but a provider blob with a single GroupId /// field would reserve 19 extra bytes. /// </param> /// <param name="additionalSize"> /// Amount of additional data in another blob. This value will be counted in the /// blob's length field, but will not be included in the returned byte[] object. /// The complete blob would then be the concatenation of the returned byte[] object /// with another byte[] object of length additionalSize. /// </param> /// <returns> /// A byte[] object with the length and name fields set, with room reserved for /// prefix and suffix. If additionalSize was 0, the byte[] object is a complete /// blob. Otherwise, another byte[] of size additionalSize must be concatenated /// with this one to form a complete blob. /// </returns> public static byte[] MetadataForString( string name, int prefixSize, int suffixSize, int additionalSize) { Statics.CheckName(name); int metadataSize = Encoding.UTF8.GetByteCount(name) + 3 + prefixSize + suffixSize; var metadata = new byte[metadataSize]; ushort totalSize = checked ((ushort)(metadataSize + additionalSize)); metadata[0] = unchecked ((byte)totalSize); metadata[1] = unchecked ((byte)(totalSize >> 8)); Encoding.UTF8.GetBytes(name, 0, name.Length, metadata, 2 + prefixSize); return(metadata); }
// Token: 0x06003637 RID: 13879 RVA: 0x000D06DC File Offset: 0x000CE8DC internal TraceLoggingTypeInfo(Type dataType, string name, EventLevel level, EventOpcode opcode, EventKeywords keywords, EventTags tags) { if (dataType == null) { throw new ArgumentNullException("dataType"); } if (name == null) { throw new ArgumentNullException("eventName"); } Statics.CheckName(name); this.name = name; this.keywords = keywords; this.level = level; this.opcode = opcode; this.tags = tags; this.dataType = dataType; }
private FieldMetadata(string name, TraceLoggingDataType dataType, EventFieldTags tags, byte countFlags, ushort fixedCount = 0, byte[] custom = null) { if (name == null) { throw new ArgumentNullException("name", "This usually means that the object passed to Write is of a type that does not support being used as the top-level object in an event, e.g. a primitive or built-in type."); } Statics.CheckName(name); int num = (int)(dataType & (TraceLoggingDataType)31); this.name = name; this.nameSize = Encoding.UTF8.GetByteCount(this.name) + 1; this.inType = (byte)((uint)num | (uint)countFlags); this.outType = (byte)((int)dataType >> 8 & (int)sbyte.MaxValue); this.tags = tags; this.fixedCount = fixedCount; this.custom = custom; if ((int)countFlags != 0) { if (num == 0) { throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedArrayOfNil")); } if (num == 14) { throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedArrayOfBinary")); } if (num == 1 || num == 2) { throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedArrayOfNullTerminatedString")); } } if ((this.tags & (EventFieldTags)268435455) != EventFieldTags.None) { this.outType = (byte)((uint)this.outType | 128U); } if ((int)this.outType == 0) { return; } this.inType = (byte)((uint)this.inType | 128U); }