public PropertyAnalysis( string name, MethodInfo getterInfo, TraceLoggingTypeInfo typeInfo, EventFieldAttribute fieldAttribute) { this.name = name; this.getterInfo = getterInfo; this.typeInfo = typeInfo; this.fieldAttribute = fieldAttribute; }
public PropertyAnalysis( string name, PropertyInfo propertyInfo, TraceLoggingTypeInfo typeInfo, EventFieldAttribute fieldAttribute) { this.name = name; this.propertyInfo = propertyInfo; this.getter = PropertyValue.GetPropertyGetter(propertyInfo); this.typeInfo = typeInfo; this.fieldAttribute = fieldAttribute; }
private static TraceLoggingTypeInfo[] MakeArray( TraceLoggingTypeInfo[] typeInfos) { if (typeInfos == null) { throw new ArgumentNullException("typeInfos"); } Contract.EndContractBlock(); return (TraceLoggingTypeInfo[])typeInfos.Clone(); ; }
private static TraceLoggingTypeInfo[] MakeArray(Type[] types) { if (types == null) { throw new ArgumentNullException("types"); } Contract.EndContractBlock(); var recursionCheck = new List<Type>(types.Length); var result = new TraceLoggingTypeInfo[types.Length]; for (int i = 0; i < types.Length; i++) { result[i] = TraceLoggingTypeInfo.GetInstance(types[i], recursionCheck); } return result; }
private TraceLoggingTypeInfo[] MakeArray(System.Reflection.ParameterInfo[] paramInfos) { if (paramInfos == null) { throw new ArgumentNullException("paramInfos"); } Contract.EndContractBlock(); var recursionCheck = new List<Type>(paramInfos.Length); var result = new TraceLoggingTypeInfo[paramInfos.Length]; for (int i = 0; i < paramInfos.Length; ++i) { result[i] = TraceLoggingTypeInfo.GetInstance(paramInfos[i].ParameterType, recursionCheck); } return result; }
private TraceLoggingEventTypes( EventTags tags, string defaultName, TraceLoggingTypeInfo[] typeInfos) { if (defaultName == null) { throw new ArgumentNullException("defaultName"); } Contract.EndContractBlock(); this.typeInfos = typeInfos; this.name = defaultName; this.tags = tags; this.level = Statics.DefaultLevel; var collector = new TraceLoggingMetadataCollector(); foreach (var typeInfo in typeInfos) { this.level = Statics.Combine((int)typeInfo.Level, this.level); this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode); this.keywords |= typeInfo.Keywords; typeInfo.WriteMetadata(collector, null, EventFieldFormat.Default); } this.typeMetadata = collector.GetMetadata(); this.scratchSize = collector.ScratchSize; this.dataCount = collector.DataCount; this.pinCount = collector.PinCount; }
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; } if (this.name == null) { this.name = dataType.Name; } }
public EnumerableTypeInfo(TraceLoggingTypeInfo <ElementType> elementInfo) { this.elementInfo = elementInfo; }
public ArrayTypeInfo(Type type, TraceLoggingTypeInfo elementInfo) : base(type) { this.elementInfo = elementInfo; }
public NullableTypeInfo(Type type, List<Type> recursionCheck) : base(type) { var typeArgs = type.GenericTypeArguments; Contract.Assert(typeArgs.Length == 1); this.valueInfo = TraceLoggingTypeInfo.GetInstance(typeArgs[0], recursionCheck); this.hasValueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("HasValue")); this.valueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("Value")); }
public EnumerableTypeInfo(Type type, TraceLoggingTypeInfo elementInfo) : base(type) { this.elementInfo = elementInfo; }
public static TraceLoggingTypeInfo CreateDefaultTypeInfo( Type dataType, List <Type> recursionCheck) { TraceLoggingTypeInfo result; if (recursionCheck.Contains(dataType)) { throw new NotSupportedException(SR.EventSource_RecursiveTypeDefinition); } recursionCheck.Add(dataType); var eventAttrib = Statics.GetCustomAttribute <EventDataAttribute>(dataType); if (eventAttrib != null || Statics.GetCustomAttribute <CompilerGeneratedAttribute>(dataType) != null || IsGenericMatch(dataType, typeof(KeyValuePair <,>))) { var analysis = new TypeAnalysis(dataType, eventAttrib, recursionCheck); result = new InvokeTypeInfo(dataType, analysis); } else if (dataType.IsArray) { var elementType = dataType.GetElementType(); if (elementType == typeof(bool)) { result = ScalarArrayTypeInfo.Boolean(); } else if (elementType == typeof(byte)) { result = ScalarArrayTypeInfo.Byte(); } else if (elementType == typeof(sbyte)) { result = ScalarArrayTypeInfo.SByte(); } else if (elementType == typeof(short)) { result = ScalarArrayTypeInfo.Int16(); } else if (elementType == typeof(ushort)) { result = ScalarArrayTypeInfo.UInt16(); } else if (elementType == typeof(int)) { result = ScalarArrayTypeInfo.Int32(); } else if (elementType == typeof(uint)) { result = ScalarArrayTypeInfo.UInt32(); } else if (elementType == typeof(long)) { result = ScalarArrayTypeInfo.Int64(); } else if (elementType == typeof(ulong)) { result = ScalarArrayTypeInfo.UInt64(); } else if (elementType == typeof(char)) { result = ScalarArrayTypeInfo.Char(); } else if (elementType == typeof(double)) { result = ScalarArrayTypeInfo.Double(); } else if (elementType == typeof(float)) { result = ScalarArrayTypeInfo.Single(); } else if (elementType == typeof(IntPtr)) { result = ScalarArrayTypeInfo.IntPtr(); } else if (elementType == typeof(UIntPtr)) { result = ScalarArrayTypeInfo.UIntPtr(); } else if (elementType == typeof(Guid)) { result = ScalarArrayTypeInfo.Guid(); } else { result = new ArrayTypeInfo(dataType, TraceLoggingTypeInfo.GetInstance(elementType, recursionCheck)); } } else { if (Statics.IsEnum(dataType)) { dataType = Enum.GetUnderlyingType(dataType); } if (dataType == typeof(string)) { result = new StringTypeInfo(); } else if (dataType == typeof(bool)) { result = ScalarTypeInfo.Boolean(); } else if (dataType == typeof(byte)) { result = ScalarTypeInfo.Byte(); } else if (dataType == typeof(sbyte)) { result = ScalarTypeInfo.SByte(); } else if (dataType == typeof(short)) { result = ScalarTypeInfo.Int16(); } else if (dataType == typeof(ushort)) { result = ScalarTypeInfo.UInt16(); } else if (dataType == typeof(int)) { result = ScalarTypeInfo.Int32(); } else if (dataType == typeof(uint)) { result = ScalarTypeInfo.UInt32(); } else if (dataType == typeof(long)) { result = ScalarTypeInfo.Int64(); } else if (dataType == typeof(ulong)) { result = ScalarTypeInfo.UInt64(); } else if (dataType == typeof(char)) { result = ScalarTypeInfo.Char(); } else if (dataType == typeof(double)) { result = ScalarTypeInfo.Double(); } else if (dataType == typeof(float)) { result = ScalarTypeInfo.Single(); } else if (dataType == typeof(DateTime)) { result = new DateTimeTypeInfo(); } else if (dataType == typeof(decimal)) { result = new DecimalTypeInfo(); } else if (dataType == typeof(IntPtr)) { result = ScalarTypeInfo.IntPtr(); } else if (dataType == typeof(UIntPtr)) { result = ScalarTypeInfo.UIntPtr(); } else if (dataType == typeof(Guid)) { result = ScalarTypeInfo.Guid(); } else if (dataType == typeof(TimeSpan)) { result = new TimeSpanTypeInfo(); } else if (dataType == typeof(DateTimeOffset)) { result = new DateTimeOffsetTypeInfo(); } else if (dataType == typeof(EmptyStruct)) { result = new NullTypeInfo(); } else if (IsGenericMatch(dataType, typeof(Nullable <>))) { result = new NullableTypeInfo(dataType, recursionCheck); } else { var elementType = FindEnumerableElementType(dataType); if (elementType != null) { result = new EnumerableTypeInfo(dataType, TraceLoggingTypeInfo.GetInstance(elementType, recursionCheck)); } else { throw new ArgumentException(SR.Format(SR.EventSource_NonCompliantTypeError, dataType.Name)); } } } return(result); }
public ArrayTypeInfo(Type type, TraceLoggingTypeInfo elementInfo) : base(type) { this.elementInfo = elementInfo; }
public EnumerableTypeInfo(Type type, TraceLoggingTypeInfo elementInfo) : base(type) { this.elementInfo = elementInfo; }
public NullableTypeInfo(List <Type> recursionCheck) { this.valueInfo = TraceLoggingTypeInfo <T> .GetInstance(recursionCheck); }
public ArrayTypeInfo(TraceLoggingTypeInfo <ElementType> elementInfo) { this.elementInfo = elementInfo; }
public KeyValuePairTypeInfo(List <Type> recursionCheck) { this.keyInfo = TraceLoggingTypeInfo <K> .GetInstance(recursionCheck); this.valueInfo = TraceLoggingTypeInfo <V> .GetInstance(recursionCheck); }
public ClassPropertyWriter(PropertyAnalysis property) { this.valueTypeInfo = (TraceLoggingTypeInfo <ValueType>)property.typeInfo; this.getter = (ClassPropertyWriter <ContainerType, ValueType> .Getter)Statics.CreateDelegate(typeof(ClassPropertyWriter <ContainerType, ValueType> .Getter), property.getterInfo); }