Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
TypeAnalysis.cs
Go to the documentation of this file.
4
6
7internal sealed class TypeAnalysis
8{
9 internal readonly PropertyAnalysis[] properties;
10
11 internal readonly string name;
12
13 internal readonly EventKeywords keywords;
14
15 internal readonly EventLevel level = (EventLevel)(-1);
16
17 internal readonly EventOpcode opcode = (EventOpcode)(-1);
18
19 internal readonly EventTags tags;
20
21 [RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")]
23 {
25 PropertyInfo[] array = dataType.GetProperties();
26 foreach (PropertyInfo propertyInfo in array)
27 {
28 if (!Statics.HasCustomAttribute(propertyInfo, typeof(EventIgnoreAttribute)) && propertyInfo.CanRead && propertyInfo.GetIndexParameters().Length == 0)
29 {
30 MethodInfo getMethod = propertyInfo.GetGetMethod();
31 if (!(getMethod == null) && !getMethod.IsStatic && getMethod.IsPublic)
32 {
33 Type propertyType = propertyInfo.PropertyType;
35 EventFieldAttribute customAttribute = Statics.GetCustomAttribute<EventFieldAttribute>(propertyInfo);
36 string text = ((customAttribute != null && customAttribute.Name != null) ? customAttribute.Name : (Statics.ShouldOverrideFieldName(propertyInfo.Name) ? instance.Name : propertyInfo.Name));
37 list.Add(new PropertyAnalysis(text, propertyInfo, instance, customAttribute));
38 }
39 }
40 }
41 properties = list.ToArray();
44 {
45 TraceLoggingTypeInfo typeInfo = propertyAnalysis.typeInfo;
46 level = (EventLevel)Statics.Combine((int)typeInfo.Level, (int)level);
47 opcode = (EventOpcode)Statics.Combine((int)typeInfo.Opcode, (int)opcode);
48 keywords |= typeInfo.Keywords;
49 tags |= typeInfo.Tags;
50 }
51 if (eventAttrib != null)
52 {
53 level = (EventLevel)Statics.Combine((int)eventAttrib.Level, (int)level);
54 opcode = (EventOpcode)Statics.Combine((int)eventAttrib.Opcode, (int)opcode);
55 keywords |= eventAttrib.Keywords;
56 tags |= eventAttrib.Tags;
57 name = eventAttrib.Name;
58 }
59 if (name == null)
60 {
61 name = dataType.Name;
62 }
63 }
64}
static bool ShouldOverrideFieldName(string fieldName)
Definition Statics.cs:74
static bool HasCustomAttribute(PropertyInfo propInfo, Type attributeType)
Definition Statics.cs:158
static byte Combine(int settingValue, byte defaultValue)
Definition Statics.cs:48
static TraceLoggingTypeInfo GetInstance(Type type, List< Type > recursionCheck)
readonly PropertyAnalysis[] properties
TypeAnalysis(Type dataType, EventDataAttribute eventAttrib, List< Type > recursionCheck)
ParameterInfo[] GetIndexParameters()
PropertyInfo[] GetProperties()
Definition Type.cs:877