internal TraceLoggingEventTypes( string name, EventTags tags, System.Reflection.ParameterInfo[] paramInfos) { if (name is null) { throw new ArgumentNullException(nameof(name)); } this.typeInfos = MakeArray(paramInfos); #if FEATURE_PERFTRACING this.paramNames = MakeParamNameArray(paramInfos); #endif this.name = name; this.tags = tags; this.level = Statics.DefaultLevel; var collector = new TraceLoggingMetadataCollector(); for (int i = 0; i < typeInfos.Length; ++i) { TraceLoggingTypeInfo typeInfo = typeInfos[i]; this.level = Statics.Combine((int)typeInfo.Level, this.level); this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode); this.keywords |= typeInfo.Keywords; string?paramName = paramInfos[i].Name; if (Statics.ShouldOverrideFieldName(paramName !)) { paramName = typeInfo.Name; } typeInfo.WriteMetadata(collector, paramName, EventFieldFormat.Default); } this.typeMetadata = collector.GetMetadata(); this.scratchSize = collector.ScratchSize; this.dataCount = collector.DataCount; this.pinCount = collector.PinCount; }
// Token: 0x060035ED RID: 13805 RVA: 0x000CF468 File Offset: 0x000CD668 public static Type FindEnumerableElementType(Type type) { Type type2 = null; if (Statics.IsGenericMatch(type, typeof(IEnumerable <>))) { type2 = Statics.GetGenericArguments(type)[0]; } else { Type[] array = type.FindInterfaces(new TypeFilter(Statics.IsGenericMatch), typeof(IEnumerable <>)); foreach (Type type3 in array) { if (type2 != null) { type2 = null; break; } type2 = Statics.GetGenericArguments(type3)[0]; } } return(type2); }
private TraceLoggingEventTypes(EventTags tags, string defaultName, TraceLoggingTypeInfo[] typeInfos) { if (defaultName == null) { throw new ArgumentNullException("defaultName"); } this.typeInfos = typeInfos; this.name = defaultName; this.tags = tags; this.level = (byte)5; TraceLoggingMetadataCollector collector = new TraceLoggingMetadataCollector(); foreach (TraceLoggingTypeInfo typeInfo in typeInfos) { this.level = Statics.Combine((int)typeInfo.Level, this.level); this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode); this.keywords = this.keywords | typeInfo.Keywords; typeInfo.WriteMetadata(collector, (string)null, EventFieldFormat.Default); } this.typeMetadata = collector.GetMetadata(); this.scratchSize = collector.ScratchSize; this.dataCount = collector.DataCount; this.pinCount = collector.PinCount; }
// Token: 0x06003575 RID: 13685 RVA: 0x000CEB16 File Offset: 0x000CCD16 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format) { collector.AddArray(name, Statics.Format8(format, TraceLoggingDataType.Int8)); }
// Token: 0x060035B9 RID: 13753 RVA: 0x000CEE30 File Offset: 0x000CD030 public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format) { collector.AddBinary(name, Statics.MakeDataType(TraceLoggingDataType.CountedUtf16String, format)); }
public override Func <PropertyValue, PropertyValue> GetPropertyGetter(PropertyInfo property) { var type = property.PropertyType; if (!Statics.IsValueType(type)) { var getter = (Func <TContainer, object>)GetGetMethod(property, type); return(container => new PropertyValue(getter((TContainer)container.ReferenceValue))); } else { if (type.GetTypeInfo().IsEnum) { type = Enum.GetUnderlyingType(type); } if (type == typeof(Boolean)) { var f = (Func <TContainer, Boolean>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Byte)) { var f = (Func <TContainer, Byte>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(SByte)) { var f = (Func <TContainer, SByte>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Char)) { var f = (Func <TContainer, Char>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Int16)) { var f = (Func <TContainer, Int16>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(UInt16)) { var f = (Func <TContainer, UInt16>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Int32)) { var f = (Func <TContainer, Int32>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(UInt32)) { var f = (Func <TContainer, UInt32>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Int64)) { var f = (Func <TContainer, Int64>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(UInt64)) { var f = (Func <TContainer, UInt64>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(IntPtr)) { var f = (Func <TContainer, IntPtr>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(UIntPtr)) { var f = (Func <TContainer, UIntPtr>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Single)) { var f = (Func <TContainer, Single>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Double)) { var f = (Func <TContainer, Double>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Guid)) { var f = (Func <TContainer, Guid>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(DateTime)) { var f = (Func <TContainer, DateTime>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(DateTimeOffset)) { var f = (Func <TContainer, DateTimeOffset>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(TimeSpan)) { var f = (Func <TContainer, TimeSpan>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } if (type == typeof(Decimal)) { var f = (Func <TContainer, Decimal>)GetGetMethod(property, type); return(container => new PropertyValue(f((TContainer)container.ReferenceValue))); } return(container => new PropertyValue(property.GetValue(container.ReferenceValue))); } }
// Token: 0x06003569 RID: 13673 RVA: 0x000CEA1C File Offset: 0x000CCC1C public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format) { collector.AddScalar(name, Statics.Format32(format, TraceLoggingDataType.Float)); }
// Token: 0x0600358D RID: 13709 RVA: 0x000CEC2C File Offset: 0x000CCE2C public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format) { collector.AddArray(name, Statics.FormatPtr(format, Statics.UIntPtrType)); }
// 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); }
public TypeAnalysis(Type dataType, EventDataAttribute eventAttrib, List <Type> recursionCheck) { IEnumerable <PropertyInfo> properties = Statics.GetProperties(dataType); List <PropertyAnalysis> propertyAnalysisList = new List <PropertyAnalysis>(); foreach (PropertyInfo propInfo in properties) { if (!Statics.HasCustomAttribute(propInfo, typeof(EventIgnoreAttribute)) && propInfo.CanRead && propInfo.GetIndexParameters().Length == 0) { MethodInfo getMethod = Statics.GetGetMethod(propInfo); if (!(getMethod == (MethodInfo)null) && !getMethod.IsStatic && getMethod.IsPublic) { TraceLoggingTypeInfo typeInfoInstance = Statics.GetTypeInfoInstance(propInfo.PropertyType, recursionCheck); EventFieldAttribute customAttribute = Statics.GetCustomAttribute <EventFieldAttribute>(propInfo); string name = customAttribute == null || customAttribute.Name == null ? (Statics.ShouldOverrideFieldName(propInfo.Name) ? typeInfoInstance.Name : propInfo.Name) : customAttribute.Name; propertyAnalysisList.Add(new PropertyAnalysis(name, getMethod, typeInfoInstance, customAttribute)); } } } this.properties = propertyAnalysisList.ToArray(); foreach (PropertyAnalysis property in this.properties) { TraceLoggingTypeInfo traceLoggingTypeInfo = property.typeInfo; this.level = (EventLevel)Statics.Combine((int)traceLoggingTypeInfo.Level, (int)this.level); this.opcode = (EventOpcode)Statics.Combine((int)traceLoggingTypeInfo.Opcode, (int)this.opcode); this.keywords = this.keywords | traceLoggingTypeInfo.Keywords; this.tags = this.tags | traceLoggingTypeInfo.Tags; } if (eventAttrib != null) { this.level = (EventLevel)Statics.Combine((int)eventAttrib.Level, (int)this.level); this.opcode = (EventOpcode)Statics.Combine((int)eventAttrib.Opcode, (int)this.opcode); this.keywords = this.keywords | eventAttrib.Keywords; this.tags = this.tags | eventAttrib.Tags; this.name = eventAttrib.Name; } if (this.name != null) { return; } this.name = dataType.Name; }
// Token: 0x060035C0 RID: 13760 RVA: 0x000CEE9A File Offset: 0x000CD09A public override void WriteMetadata(TraceLoggingMetadataCollector collector, string name, EventFieldFormat format) { collector.AddArray(name, Statics.MakeDataType(TraceLoggingDataType.Guid, format)); }
public TypeAnalysis( Type dataType, EventDataAttribute?eventAttrib, List <Type> recursionCheck) { var propertyList = new List <PropertyAnalysis>(); foreach (PropertyInfo propertyInfo in dataType.GetProperties()) { if (Statics.HasCustomAttribute(propertyInfo, typeof(EventIgnoreAttribute))) { continue; } if (!propertyInfo.CanRead || propertyInfo.GetIndexParameters().Length != 0) { continue; } MethodInfo?getterInfo = propertyInfo.GetGetMethod(); if (getterInfo == null) { continue; } if (getterInfo.IsStatic || !getterInfo.IsPublic) { continue; } Type propertyType = propertyInfo.PropertyType; var propertyTypeInfo = TraceLoggingTypeInfo.GetInstance(propertyType, recursionCheck); EventFieldAttribute?fieldAttribute = Statics.GetCustomAttribute <EventFieldAttribute>(propertyInfo); string propertyName = fieldAttribute != null && fieldAttribute.Name != null ? fieldAttribute.Name : Statics.ShouldOverrideFieldName(propertyInfo.Name) ? propertyTypeInfo.Name : propertyInfo.Name; propertyList.Add(new PropertyAnalysis( propertyName, propertyInfo, propertyTypeInfo, fieldAttribute)); } this.properties = propertyList.ToArray(); foreach (PropertyAnalysis property in this.properties) { TraceLoggingTypeInfo typeInfo = property.typeInfo; this.level = (EventLevel)Statics.Combine((int)typeInfo.Level, (int)this.level); this.opcode = (EventOpcode)Statics.Combine((int)typeInfo.Opcode, (int)this.opcode); this.keywords |= typeInfo.Keywords; this.tags |= typeInfo.Tags; } if (eventAttrib != null) { this.level = (EventLevel)Statics.Combine((int)eventAttrib.Level, (int)this.level); this.opcode = (EventOpcode)Statics.Combine((int)eventAttrib.Opcode, (int)this.opcode); this.keywords |= eventAttrib.Keywords; this.tags |= eventAttrib.Tags; this.name = eventAttrib.Name; } this.name ??= dataType.Name; }
public override void WriteMetadata(TraceLoggingMetadataCollector collector, string?name, EventFieldFormat format) { collector.AddScalar(name !, Statics.FormatScalar(format, nativeFormat)); }
public static TraceLoggingTypeInfo <DataType> CreateDefaultTypeInfo <DataType>(List <Type> recursionCheck) { Type type = typeof(DataType); if (recursionCheck.Contains(type)) { throw new NotSupportedException(Environment.GetResourceString("EventSource_RecursiveTypeDefinition")); } recursionCheck.Add(type); EventDataAttribute customAttribute = Statics.GetCustomAttribute <EventDataAttribute>(type); TraceLoggingTypeInfo traceLoggingTypeInfo; if (customAttribute != null || Statics.GetCustomAttribute <CompilerGeneratedAttribute>(type) != null) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new InvokeTypeInfo <DataType>(new TypeAnalysis(type, customAttribute, recursionCheck)); } else if (type.IsArray) { Type elementType = type.GetElementType(); if (elementType == typeof(bool)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new BooleanArrayTypeInfo(); } else if (elementType == typeof(byte)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new ByteArrayTypeInfo(); } else if (elementType == typeof(sbyte)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new SByteArrayTypeInfo(); } else if (elementType == typeof(short)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new Int16ArrayTypeInfo(); } else if (elementType == typeof(ushort)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UInt16ArrayTypeInfo(); } else if (elementType == typeof(int)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new Int32ArrayTypeInfo(); } else if (elementType == typeof(uint)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UInt32ArrayTypeInfo(); } else if (elementType == typeof(long)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new Int64ArrayTypeInfo(); } else if (elementType == typeof(ulong)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UInt64ArrayTypeInfo(); } else if (elementType == typeof(char)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new CharArrayTypeInfo(); } else if (elementType == typeof(double)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new DoubleArrayTypeInfo(); } else if (elementType == typeof(float)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new SingleArrayTypeInfo(); } else if (elementType == typeof(IntPtr)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new IntPtrArrayTypeInfo(); } else if (elementType == typeof(UIntPtr)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UIntPtrArrayTypeInfo(); } else if (elementType == typeof(Guid)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new GuidArrayTypeInfo(); } else { traceLoggingTypeInfo = (TraceLoggingTypeInfo)Statics.CreateInstance(typeof(ArrayTypeInfo <>).MakeGenericType(elementType), (object)Statics.GetTypeInfoInstance(elementType, recursionCheck)); } } else if (Statics.IsEnum(type)) { Type underlyingType = Enum.GetUnderlyingType(type); if (underlyingType == typeof(int)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumInt32TypeInfo <DataType>(); } else if (underlyingType == typeof(uint)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumUInt32TypeInfo <DataType>(); } else if (underlyingType == typeof(byte)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumByteTypeInfo <DataType>(); } else if (underlyingType == typeof(sbyte)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumSByteTypeInfo <DataType>(); } else if (underlyingType == typeof(short)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumInt16TypeInfo <DataType>(); } else if (underlyingType == typeof(ushort)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumUInt16TypeInfo <DataType>(); } else if (underlyingType == typeof(long)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumInt64TypeInfo <DataType>(); } else if (underlyingType == typeof(ulong)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new EnumUInt64TypeInfo <DataType>(); } else { throw new NotSupportedException(Environment.GetResourceString("EventSource_NotSupportedEnumType", (object)type.Name, (object)underlyingType.Name)); } } else if (type == typeof(string)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new StringTypeInfo(); } else if (type == typeof(bool)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new BooleanTypeInfo(); } else if (type == typeof(byte)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new ByteTypeInfo(); } else if (type == typeof(sbyte)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new SByteTypeInfo(); } else if (type == typeof(short)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new Int16TypeInfo(); } else if (type == typeof(ushort)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UInt16TypeInfo(); } else if (type == typeof(int)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new Int32TypeInfo(); } else if (type == typeof(uint)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UInt32TypeInfo(); } else if (type == typeof(long)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new Int64TypeInfo(); } else if (type == typeof(ulong)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UInt64TypeInfo(); } else if (type == typeof(char)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new CharTypeInfo(); } else if (type == typeof(double)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new DoubleTypeInfo(); } else if (type == typeof(float)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new SingleTypeInfo(); } else if (type == typeof(DateTime)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new DateTimeTypeInfo(); } else if (type == typeof(Decimal)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new DecimalTypeInfo(); } else if (type == typeof(IntPtr)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new IntPtrTypeInfo(); } else if (type == typeof(UIntPtr)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new UIntPtrTypeInfo(); } else if (type == typeof(Guid)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new GuidTypeInfo(); } else if (type == typeof(TimeSpan)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new TimeSpanTypeInfo(); } else if (type == typeof(DateTimeOffset)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new DateTimeOffsetTypeInfo(); } else if (type == typeof(EmptyStruct)) { traceLoggingTypeInfo = (TraceLoggingTypeInfo) new NullTypeInfo <EmptyStruct>(); } else if (Statics.IsGenericMatch(type, (object)typeof(KeyValuePair <,>))) { Type[] genericArguments = Statics.GetGenericArguments(type); traceLoggingTypeInfo = (TraceLoggingTypeInfo)Statics.CreateInstance(typeof(KeyValuePairTypeInfo <,>).MakeGenericType(genericArguments[0], genericArguments[1]), (object)recursionCheck); } else if (Statics.IsGenericMatch(type, (object)typeof(Nullable <>))) { traceLoggingTypeInfo = (TraceLoggingTypeInfo)Statics.CreateInstance(typeof(NullableTypeInfo <>).MakeGenericType(Statics.GetGenericArguments(type)[0]), (object)recursionCheck); } else { Type enumerableElementType = Statics.FindEnumerableElementType(type); if (enumerableElementType != (Type)null) { traceLoggingTypeInfo = (TraceLoggingTypeInfo)Statics.CreateInstance(typeof(EnumerableTypeInfo <,>).MakeGenericType(type, enumerableElementType), (object)Statics.GetTypeInfoInstance(enumerableElementType, recursionCheck)); } else { throw new ArgumentException(Environment.GetResourceString("EventSource_NonCompliantTypeError", (object)type.Name)); } } return((TraceLoggingTypeInfo <DataType>)traceLoggingTypeInfo); }