示例#1
0
 private ScalarArrayTypeInfo(
     Type type,
     TraceLoggingDataType nativeFormat,
     int elementSize)
     : base(type)
 {
     this.nativeFormat = nativeFormat;
     this.elementSize  = elementSize;
 }
示例#2
0
 private ScalarTypeInfo(
     Type type,
     Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc,
     TraceLoggingDataType nativeFormat) 
     : base(type)
 {
     this.formatFunc = formatFunc;
     this.nativeFormat = nativeFormat;
 }
        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);
            var 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(Resources.GetResourceString("EventSource_NotSupportedArrayOfNil"));
                }
                if (coreType == (int)TraceLoggingDataType.Binary)
                {
                    throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedArrayOfBinary"));
                }
#if !BROKEN_UNTIL_M3
                if (coreType == (int)TraceLoggingDataType.Utf16String ||
                    coreType == (int)TraceLoggingDataType.MbcsString)
                {
                    throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedArrayOfNullTerminatedString"));
                }
#endif
            }

            if (((int)this.tags & 0xfffffff) != 0)
            {
                this.outType |= Statics.OutTypeChainFlag;
            }

            if (this.outType != 0)
            {
                this.inType |= Statics.InTypeChainFlag;
            }
        }
示例#4
0
 private ScalarTypeInfo(
     Type type,
     Func <EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc,
     TraceLoggingDataType nativeFormat)
     : base(type)
 {
     this.formatFunc   = formatFunc;
     this.nativeFormat = nativeFormat;
 }
示例#5
0
 public void AddCustom(string name, TraceLoggingDataType type, byte[] metadata)
 {
     if (this.BeginningBufferedArray)
     {
         throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedCustomSerializedData"));
     }
     this.impl.AddScalar(2);
     this.impl.AddNonscalar();
     this.AddField(new FieldMetadata(name, type, this.Tags, metadata));
 }
示例#6
0
 private ScalarArrayTypeInfo(
     Type type,
     Func <EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc,
     TraceLoggingDataType nativeFormat,
     int elementSize)
     : base(type)
 {
     this.formatFunc   = formatFunc;
     this.nativeFormat = nativeFormat;
     this.elementSize  = elementSize;
 }
示例#7
0
 public static TraceLoggingDataType FormatPtr(EventFieldFormat format, TraceLoggingDataType native)
 {
     if (format == EventFieldFormat.Default)
     {
         return(native);
     }
     if (format == EventFieldFormat.Hexadecimal)
     {
         return(Statics.HexIntPtrType);
     }
     return(Statics.MakeDataType(native, format));
 }
        // Token: 0x0600362F RID: 13871 RVA: 0x000D045C File Offset: 0x000CE65C
        public void AddBinary(string name, TraceLoggingDataType type)
        {
            TraceLoggingDataType traceLoggingDataType = type & (TraceLoggingDataType)31;

            if (traceLoggingDataType != TraceLoggingDataType.Binary && traceLoggingDataType - TraceLoggingDataType.CountedUtf16String > 1)
            {
                throw new ArgumentOutOfRangeException("type");
            }
            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray));
        }
示例#9
0
 /// <summary>
 /// Scalar or variable-length array.
 /// </summary>
 public FieldMetadata(
     string name,
     TraceLoggingDataType type,
     EventFieldTags tags,
     bool variableCount)
     : this(
         name,
         type,
         tags,
         variableCount ? Statics.InTypeVariableCountFlag : (byte)0,
         0,
         null)
 {
 }
示例#10
0
        /// <summary>
        /// Adds a null-terminated string field to an event.
        /// Compatible with core types: Utf16String, MbcsString.
        /// Compatible with dataCollector method: AddNullTerminatedString(string).
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a null-terminated string type.
        /// </param>
        public void AddNullTerminatedString(string name, TraceLoggingDataType type)
        {
            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
            case TraceLoggingDataType.Utf16String:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }

            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray));
        }
示例#11
0
 /// <summary>
 /// Fixed-length array.
 /// </summary>
 public FieldMetadata(
     string name,
     TraceLoggingDataType type,
     EventFieldTags tags,
     ushort fixedCount)
     : this(
         name,
         type,
         tags,
         Statics.InTypeFixedCountFlag,
         fixedCount,
         null)
 {
 }
示例#12
0
 /// <summary>
 /// Custom serializer
 /// </summary>
 public FieldMetadata(
     string name,
     TraceLoggingDataType type,
     EventFieldTags tags,
     byte[]?custom)
     : this(
         name,
         type,
         tags,
         Statics.InTypeCustomCountFlag,
         checked ((ushort)(custom == null ? 0 : custom.Length)),
         custom)
 {
 }
示例#13
0
 /// <summary>
 /// Scalar or variable-length array.
 /// </summary>
 public FieldMetadata(
     string name,
     TraceLoggingDataType type,
     EventFieldTags tags,
     bool variableCount)
     : this(
         name,
         type,
         tags,
         variableCount ? Statics.InTypeVariableCountFlag : (byte)0,
         0,
         null)
 {
     return;
 }
        // Token: 0x060035DF RID: 13791 RVA: 0x000CF2B3 File Offset: 0x000CD4B3
        public static TraceLoggingDataType Format16(EventFieldFormat format, TraceLoggingDataType native)
        {
            switch (format)
            {
            case EventFieldFormat.Default:
                return(native);

            case EventFieldFormat.String:
                return(TraceLoggingDataType.Char16);

            case EventFieldFormat.Hexadecimal:
                return(TraceLoggingDataType.HexInt16);
            }
            return(Statics.MakeDataType(native, format));
        }
示例#15
0
 /// <summary>
 /// Fixed-length array.
 /// </summary>
 public FieldMetadata(
     string name,
     TraceLoggingDataType type,
     EventFieldTags tags,
     ushort fixedCount)
     : this(
         name,
         type,
         tags,
         Statics.InTypeFixedCountFlag,
         fixedCount,
         null)
 {
     return;
 }
示例#16
0
 /// <summary>
 /// Custom serializer
 /// </summary>
 public FieldMetadata(
     string name,
     TraceLoggingDataType type,
     EventFieldTags tags,
     byte[] custom)
     : this(
         name,
         type,
         tags,
         Statics.InTypeCustomCountFlag,
         checked((ushort)(custom == null ? 0 : custom.Length)),
         custom)
 {
     return;
 }
        // Token: 0x06003630 RID: 13872 RVA: 0x000D04B8 File Offset: 0x000CE6B8
        public void AddArray(string name, TraceLoggingDataType type)
        {
            TraceLoggingDataType traceLoggingDataType = type & (TraceLoggingDataType)31;

            switch (traceLoggingDataType)
            {
            case TraceLoggingDataType.Utf16String:
            case TraceLoggingDataType.MbcsString:
            case TraceLoggingDataType.Int8:
            case TraceLoggingDataType.UInt8:
            case TraceLoggingDataType.Int16:
            case TraceLoggingDataType.UInt16:
            case TraceLoggingDataType.Int32:
            case TraceLoggingDataType.UInt32:
            case TraceLoggingDataType.Int64:
            case TraceLoggingDataType.UInt64:
            case TraceLoggingDataType.Float:
            case TraceLoggingDataType.Double:
            case TraceLoggingDataType.Boolean32:
            case TraceLoggingDataType.Guid:
            case TraceLoggingDataType.FileTime:
            case TraceLoggingDataType.HexInt32:
            case TraceLoggingDataType.HexInt64:
                goto IL_7C;

            case TraceLoggingDataType.Binary:
            case (TraceLoggingDataType)16:
            case TraceLoggingDataType.SystemTime:
            case (TraceLoggingDataType)19:
                break;

            default:
                if (traceLoggingDataType == TraceLoggingDataType.Char8 || traceLoggingDataType == TraceLoggingDataType.Char16)
                {
                    goto IL_7C;
                }
                break;
            }
            throw new ArgumentOutOfRangeException("type");
IL_7C:
            if (this.BeginningBufferedArray)
            {
                throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedNestedArraysEnums"));
            }
            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, true));
        }
示例#18
0
        public void AddBinary(string name, TraceLoggingDataType type)
        {
            switch (type & (TraceLoggingDataType)31)
            {
            case TraceLoggingDataType.Binary:
            case TraceLoggingDataType.CountedUtf16String:
            case TraceLoggingDataType.CountedMbcsString:
                this.impl.AddScalar(2);
                this.impl.AddNonscalar();
                this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray));
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
示例#19
0
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType Format8(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            return(format switch
            {
                EventFieldFormat.Default => native,
                EventFieldFormat.String => TraceLoggingDataType.Char8,
                EventFieldFormat.Boolean => TraceLoggingDataType.Boolean8,
                EventFieldFormat.Hexadecimal => TraceLoggingDataType.HexInt8,
#if false
                EventSourceFieldFormat.Signed => TraceLoggingDataType.Int8,
                EventSourceFieldFormat.Unsigned => TraceLoggingDataType.UInt8,
#endif
                _ => MakeDataType(native, format),
            });
示例#20
0
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType FormatPtr(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            switch (format)
            {
            case EventFieldFormat.Default:
                return(native);

            case EventFieldFormat.Hexadecimal:
                return(HexIntPtrType);

            default:
                return(MakeDataType(native, format));
            }
        }
示例#21
0
        /// <summary>
        /// Adds a scalar field to an event.
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a fixed-size type
        /// (e.g. string types are not supported).
        /// </param>
        public void AddScalar(string name, TraceLoggingDataType type)
        {
            int size;

            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
            case TraceLoggingDataType.Int8:
            case TraceLoggingDataType.UInt8:
            case TraceLoggingDataType.Char8:
                size = 1;
                break;

            case TraceLoggingDataType.Int16:
            case TraceLoggingDataType.UInt16:
            case TraceLoggingDataType.Char16:
                size = 2;
                break;

            case TraceLoggingDataType.Int32:
            case TraceLoggingDataType.UInt32:
            case TraceLoggingDataType.HexInt32:
            case TraceLoggingDataType.Float:
            case TraceLoggingDataType.Boolean32:
                size = 4;
                break;

            case TraceLoggingDataType.Int64:
            case TraceLoggingDataType.UInt64:
            case TraceLoggingDataType.HexInt64:
            case TraceLoggingDataType.Double:
            case TraceLoggingDataType.FileTime:
                size = 8;
                break;

            case TraceLoggingDataType.Guid:
            case TraceLoggingDataType.SystemTime:
                size = 16;
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            this.impl.AddScalar(size);
            this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray));
        }
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType Format16(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            return format switch
            {
                EventFieldFormat.Default => native,
                EventFieldFormat.String => TraceLoggingDataType.Char16,
                EventFieldFormat.Hexadecimal => TraceLoggingDataType.HexInt16,
#if false
                EventSourceFieldFormat.Port => TraceLoggingDataType.Port,
                EventSourceFieldFormat.Signed => TraceLoggingDataType.Int16,
                EventSourceFieldFormat.Unsigned => TraceLoggingDataType.UInt16,
#endif
                _ => MakeDataType(native, format),
            };
        }
示例#23
0
文件: Statics.cs 项目: KotovN/coreclr
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType Format32(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            switch (format)
            {
            case EventFieldFormat.Default:
                return(native);

            case EventFieldFormat.Boolean:
                return(TraceLoggingDataType.Boolean32);

            case EventFieldFormat.Hexadecimal:
                return(TraceLoggingDataType.HexInt32);

#if false
            case EventSourceFieldFormat.Ipv4Address:
                return(TraceLoggingDataType.Ipv4Address);

            case EventSourceFieldFormat.ProcessId:
                return(TraceLoggingDataType.ProcessId);

            case EventSourceFieldFormat.ThreadId:
                return(TraceLoggingDataType.ThreadId);

            case EventSourceFieldFormat.Win32Error:
                return(TraceLoggingDataType.Win32Error);

            case EventSourceFieldFormat.NTStatus:
                return(TraceLoggingDataType.NTStatus);
#endif
            case EventFieldFormat.HResult:
                return(TraceLoggingDataType.HResult);

#if false
            case EventSourceFieldFormat.Signed:
                return(TraceLoggingDataType.Int32);

            case EventSourceFieldFormat.Unsigned:
                return(TraceLoggingDataType.UInt32);
#endif
            default:
                return(MakeDataType(native, format));
            }
        }
示例#24
0
        /// <summary>
        /// Adds an array field to an event.
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a fixed-size type
        /// or a string type. In the case of a string type, this adds an array
        /// of characters, not an array of strings.
        /// </param>
        public void AddArray(string name, TraceLoggingDataType type)
        {
            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
            case TraceLoggingDataType.Utf16String:
            case TraceLoggingDataType.MbcsString:
            case TraceLoggingDataType.Int8:
            case TraceLoggingDataType.UInt8:
            case TraceLoggingDataType.Int16:
            case TraceLoggingDataType.UInt16:
            case TraceLoggingDataType.Int32:
            case TraceLoggingDataType.UInt32:
            case TraceLoggingDataType.Int64:
            case TraceLoggingDataType.UInt64:
            case TraceLoggingDataType.Float:
            case TraceLoggingDataType.Double:
            case TraceLoggingDataType.Boolean32:
            case TraceLoggingDataType.Guid:
            case TraceLoggingDataType.FileTime:
            case TraceLoggingDataType.HexInt32:
            case TraceLoggingDataType.HexInt64:
            case TraceLoggingDataType.Char16:
            case TraceLoggingDataType.Char8:
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            if (this.BeginningBufferedArray)
            {
#if PROJECTN
                throw new NotSupportedException(SR.GetResourceString("EventSource_NotSupportedNestedArraysEnums", null));
#else
                throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedNestedArraysEnums"));
#endif
            }

            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, true));
        }
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType Format32(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            return format switch
            {
                EventFieldFormat.Default => native,
                EventFieldFormat.Boolean => TraceLoggingDataType.Boolean32,
                EventFieldFormat.Hexadecimal => TraceLoggingDataType.HexInt32,
#if false
                EventSourceFieldFormat.Ipv4Address => TraceLoggingDataType.Ipv4Address,
                EventSourceFieldFormat.ProcessId => TraceLoggingDataType.ProcessId,
                EventSourceFieldFormat.ThreadId => TraceLoggingDataType.ThreadId,
                EventSourceFieldFormat.Win32Error => TraceLoggingDataType.Win32Error,
                EventSourceFieldFormat.NTStatus => TraceLoggingDataType.NTStatus,
#endif
                EventFieldFormat.HResult => TraceLoggingDataType.HResult,
#if false
                case EventSourceFieldFormat.Signed:
                    return TraceLoggingDataType.Int32;
示例#26
0
        public static TraceLoggingDataType Format32(EventFieldFormat format, TraceLoggingDataType native)
        {
            switch (format)
            {
            case EventFieldFormat.Default:
                return(native);

            case EventFieldFormat.Boolean:
                return(TraceLoggingDataType.Boolean32);

            case EventFieldFormat.Hexadecimal:
                return(TraceLoggingDataType.HexInt32);

            case EventFieldFormat.HResult:
                return(TraceLoggingDataType.HResult);

            default:
                return(Statics.MakeDataType(native, format));
            }
        }
示例#27
0
        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);
        }
示例#28
0
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType Format8(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            switch (format)
            {
            case EventFieldFormat.Default:
                return(native);

            case EventFieldFormat.String:
                return(TraceLoggingDataType.Char8);

            case EventFieldFormat.Boolean:
                return(TraceLoggingDataType.Boolean8);

            case EventFieldFormat.Hexadecimal:
                return(TraceLoggingDataType.HexInt8);

            default:
                return(MakeDataType(native, format));
            }
        }
示例#29
0
文件: Statics.cs 项目: KotovN/coreclr
        /// <summary>
        /// Adjusts the native type based on format.
        /// - If format is default, return native.
        /// - If format is recognized, return the canonical type for that format.
        /// - Otherwise remove existing format from native and apply the requested format.
        /// </summary>
        public static TraceLoggingDataType FormatPtr(
            EventFieldFormat format,
            TraceLoggingDataType native)
        {
            switch (format)
            {
            case EventFieldFormat.Default:
                return(native);

            case EventFieldFormat.Hexadecimal:
                return(HexIntPtrType);

#if false
            case EventSourceFieldFormat.Signed:
                return(IntPtrType);

            case EventSourceFieldFormat.Unsigned:
                return(UIntPtrType);
#endif
            default:
                return(MakeDataType(native, format));
            }
        }
示例#30
0
        /// <summary>
        /// Adds an array field to an event.
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a fixed-size type.
        /// </param>
        public void AddArray(string name, TraceLoggingDataType type)
        {
            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
            case TraceLoggingDataType.Int8:
            case TraceLoggingDataType.UInt8:
            case TraceLoggingDataType.Int16:
            case TraceLoggingDataType.UInt16:
            case TraceLoggingDataType.Int32:
            case TraceLoggingDataType.UInt32:
            case TraceLoggingDataType.Int64:
            case TraceLoggingDataType.UInt64:
            case TraceLoggingDataType.Float:
            case TraceLoggingDataType.Double:
            case TraceLoggingDataType.Boolean32:
            case TraceLoggingDataType.Guid:
            case TraceLoggingDataType.FileTime:
            case TraceLoggingDataType.HexInt32:
            case TraceLoggingDataType.HexInt64:
            case TraceLoggingDataType.Char16:
            case TraceLoggingDataType.Char8:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }

            if (this.BeginningBufferedArray)
            {
                throw new NotSupportedException(SR.EventSource_NotSupportedNestedArraysEnums);
            }

            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, true));
        }
示例#31
0
 public FieldMetadata(string name, TraceLoggingDataType type, EventFieldTags tags, bool variableCount)
     : this(name, type, tags, variableCount ? (byte)64 : (byte)0, (ushort)0, (byte[])null)
 {
 }
示例#32
0
 public FieldMetadata(string name, TraceLoggingDataType type, EventFieldTags tags, ushort fixedCount)
     : this(name, type, tags, (byte)32, fixedCount, (byte[])null)
 {
 }
示例#33
0
 public static TraceLoggingDataType MakeDataType(
     TraceLoggingDataType baseType,
     EventFieldFormat format)
 {
     return((TraceLoggingDataType)(((int)baseType & 0x1f) | ((int)format << 8)));
 }
        /// <summary>
        /// Adds a custom-serialized field to an event.
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">The encoding type for the field.</param>
        /// <param name="metadata">Additional information needed to decode the field, if any.</param>
        public void AddCustom(string name, TraceLoggingDataType type, byte[] metadata)
        {
            if (this.BeginningBufferedArray)
            {
                throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedCustomSerializedData"));
            }

            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(
                name,
                type,
                this.Tags,
                metadata));
        }
        /// <summary>
        /// Adds an array field to an event.
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a fixed-size type
        /// or a string type. In the case of a string type, this adds an array
        /// of characters, not an array of strings.
        /// </param>
        public void AddArray(string name, TraceLoggingDataType type)
        {
            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
                case TraceLoggingDataType.Utf16String:
                case TraceLoggingDataType.MbcsString:
                case TraceLoggingDataType.Int8:
                case TraceLoggingDataType.UInt8:
                case TraceLoggingDataType.Int16:
                case TraceLoggingDataType.UInt16:
                case TraceLoggingDataType.Int32:
                case TraceLoggingDataType.UInt32:
                case TraceLoggingDataType.Int64:
                case TraceLoggingDataType.UInt64:
                case TraceLoggingDataType.Float:
                case TraceLoggingDataType.Double:
                case TraceLoggingDataType.Boolean32:
                case TraceLoggingDataType.Guid:
                case TraceLoggingDataType.FileTime:
                case TraceLoggingDataType.HexInt32:
                case TraceLoggingDataType.HexInt64:
                case TraceLoggingDataType.Char16:
                case TraceLoggingDataType.Char8:
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }

            if (this.BeginningBufferedArray)
            {
                throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedNestedArraysEnums"));
            }

            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, true));
        }
        /// <summary>
        /// Adds a binary-format field to an event.
        /// Compatible with core types: Binary, CountedUtf16String, CountedMbcsString.
        /// Compatible with dataCollector methods: AddBinary(string), AddArray(Any8bitType[]).
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a Binary or CountedString type.
        /// </param>
        public void AddBinary(string name, TraceLoggingDataType type)
        {
            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
                case TraceLoggingDataType.Binary:
                case TraceLoggingDataType.CountedMbcsString:
                case TraceLoggingDataType.CountedUtf16String:
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }

            this.impl.AddScalar(2);
            this.impl.AddNonscalar();
            this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray));
        }
        /// <summary>
        /// Adds a scalar field to an event.
        /// </summary>
        /// <param name="name">
        /// The name to use for the added field. This value must not be null.
        /// </param>
        /// <param name="type">
        /// The type code for the added field. This must be a fixed-size type
        /// (e.g. string types are not supported).
        /// </param>
        public void AddScalar(string name, TraceLoggingDataType type)
        {
            int size;
            switch ((TraceLoggingDataType)((int)type & Statics.InTypeMask))
            {
                case TraceLoggingDataType.Int8:
                case TraceLoggingDataType.UInt8:
                case TraceLoggingDataType.Char8:
                    size = 1;
                    break;
                case TraceLoggingDataType.Int16:
                case TraceLoggingDataType.UInt16:
                case TraceLoggingDataType.Char16:
                    size = 2;
                    break;
                case TraceLoggingDataType.Int32:
                case TraceLoggingDataType.UInt32:
                case TraceLoggingDataType.HexInt32:
                case TraceLoggingDataType.Float:
                case TraceLoggingDataType.Boolean32:
                    size = 4;
                    break;
                case TraceLoggingDataType.Int64:
                case TraceLoggingDataType.UInt64:
                case TraceLoggingDataType.HexInt64:
                case TraceLoggingDataType.Double:
                case TraceLoggingDataType.FileTime:
                    size = 8;
                    break;
                case TraceLoggingDataType.Guid:
                case TraceLoggingDataType.SystemTime:
                    size = 16;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }

            this.impl.AddScalar(size);
            this.AddField(new FieldMetadata(name, type, this.Tags, this.BeginningBufferedArray));
        }
示例#38
0
 public FieldMetadata(string name, TraceLoggingDataType type, EventFieldTags tags, byte[] custom)
     : this(name, type, tags, (byte)96, custom == null ? (ushort)0 : checked ((ushort)custom.Length), custom)
 {
 }
示例#39
0
        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);
            var 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(Resources.GetResourceString("EventSource_NotSupportedArrayOfNil"));
                }
                if (coreType == (int)TraceLoggingDataType.Binary)
                {
                    throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedArrayOfBinary"));
                }
#if !BROKEN_UNTIL_M3
                if (coreType == (int)TraceLoggingDataType.Utf16String ||
                    coreType == (int)TraceLoggingDataType.MbcsString)
                {
                    throw new NotSupportedException(Resources.GetResourceString("EventSource_NotSupportedArrayOfNullTerminatedString"));
                }
#endif
            }

            if (((int)this.tags & 0xfffffff) != 0)
            {
                this.outType |= Statics.OutTypeChainFlag;
            }

            if (this.outType != 0)
            {
                this.inType |= Statics.InTypeChainFlag;
            }
        }
示例#40
0
 private ScalarArrayTypeInfo(
     Type type,
     Func<EventFieldFormat, TraceLoggingDataType, TraceLoggingDataType> formatFunc,
     TraceLoggingDataType nativeFormat,
     int elementSize) 
     : base(type)
 {
     this.formatFunc = formatFunc;
     this.nativeFormat = nativeFormat;
     this.elementSize = elementSize;
 }