Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteImpl()

unsafe void System.Diagnostics.Tracing.EventSource.WriteImpl ( string eventName,
ref EventSourceOptions options,
object data,
Guid * pActivityId,
Guid * pRelatedActivityId,
TraceLoggingEventTypes eventTypes )
inlineprivateinherited

Definition at line 2947 of file EventSource.cs.

2948 {
2949 try
2950 {
2951 fixed (EventSourceOptions* ptr3 = &options)
2952 {
2953 options.Opcode = (options.IsOpcodeSet ? options.Opcode : GetOpcodeWithDefault(options.Opcode, eventName));
2954 EventDescriptor descriptor;
2955 NameInfo nameInfo = UpdateDescriptor(eventName, eventTypes, ref options, out descriptor);
2956 if (nameInfo == null)
2957 {
2958 return;
2959 }
2961 int pinCount = eventTypes.pinCount;
2962 byte* scratch = stackalloc byte[(int)(uint)eventTypes.scratchSize];
2963 EventData* ptr = stackalloc EventData[eventTypes.dataCount + 3];
2964 for (int i = 0; i < eventTypes.dataCount + 3; i++)
2965 {
2966 ptr[i] = default(EventData);
2967 }
2968 GCHandle* ptr2 = stackalloc GCHandle[pinCount];
2969 for (int j = 0; j < pinCount; j++)
2970 {
2971 ptr2[j] = default(GCHandle);
2972 }
2975 {
2976 fixed (byte* pointer2 = nameInfo.nameMetadata)
2977 {
2978 fixed (byte* pointer3 = eventTypes.typeMetadata)
2979 {
2980 ptr->SetMetadata(pointer, providerMetadata.Length, 2);
2981 ptr[1].SetMetadata(pointer2, nameInfo.nameMetadata.Length, 1);
2982 ptr[2].SetMetadata(pointer3, eventTypes.typeMetadata.Length, 1);
2983 EventOpcode opcode = (EventOpcode)descriptor.Opcode;
2986 if (pActivityId == null && pRelatedActivityId == null && (options.ActivityOptions & EventActivityOptions.Disable) == 0)
2987 {
2988 switch (opcode)
2989 {
2990 case EventOpcode.Start:
2991 m_activityTracker.OnStart(m_name, eventName, 0, ref activityId, ref relatedActivityId, options.ActivityOptions);
2992 break;
2993 case EventOpcode.Stop:
2995 break;
2996 }
2997 if (activityId != Guid.Empty)
2998 {
3000 }
3002 {
3004 }
3005 }
3006 try
3007 {
3008 DataCollector.ThreadInstance.Enable(scratch, eventTypes.scratchSize, ptr + 3, eventTypes.dataCount, ptr2, pinCount);
3009 TraceLoggingTypeInfo traceLoggingTypeInfo = eventTypes.typeInfos[0];
3010 traceLoggingTypeInfo.WriteData(traceLoggingTypeInfo.PropertyValueFactory(data));
3011 WriteEventRaw(eventName, ref descriptor, orCreateEventHandle, pActivityId, pRelatedActivityId, (int)(DataCollector.ThreadInstance.Finish() - ptr), (IntPtr)ptr);
3012 if (m_Dispatchers != null)
3013 {
3014 EventPayload payload = (EventPayload)eventTypes.typeInfos[0].GetData(data);
3015 WriteToAllListeners(eventName, ref descriptor, nameInfo.tags, pActivityId, pRelatedActivityId, payload);
3016 }
3017 }
3018 catch (Exception ex)
3019 {
3020 if (ex is EventSourceException)
3021 {
3022 throw;
3023 }
3024 ThrowEventSourceException(eventName, ex);
3025 }
3026 finally
3027 {
3028 WriteCleanup(ptr2, pinCount);
3029 }
3030 }
3031 }
3032 }
3033 }
3034 }
3035 catch (Exception ex2)
3036 {
3037 if (ex2 is EventSourceException)
3038 {
3039 throw;
3040 }
3041 ThrowEventSourceException(eventName, ex2);
3042 }
3043 }
void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options, bool useTplSource=true)
void OnStop(string providerName, string activityName, int task, ref Guid activityId, bool useTplSource=true)
NameInfo UpdateDescriptor(string name, TraceLoggingEventTypes eventInfo, ref EventSourceOptions options, out EventDescriptor descriptor)
readonly TraceLoggingEventHandleTable m_eventHandleTable
virtual ReadOnlySpan< byte > ProviderMetadata
volatile OverrideEventProvider m_eventPipeProvider
unsafe void WriteEventRaw(string eventName, ref EventDescriptor eventDescriptor, IntPtr eventHandle, Guid *activityID, Guid *relatedActivityID, int dataCount, IntPtr data)
static EventOpcode GetOpcodeWithDefault(EventOpcode opcode, string eventName)
unsafe void WriteToAllListeners(EventWrittenEventArgs eventCallbackArgs, int eventDataCount, EventData *data)
volatile EventDispatcher m_Dispatchers
static unsafe void WriteCleanup(GCHandle *pPins, int cPins)
void ThrowEventSourceException(string eventName, Exception innerEx=null)
static readonly Guid Empty
Definition Guid.cs:86

References System.Guid.Empty, System.Diagnostics.Tracing.EventSource.GetOpcodeWithDefault(), System.Diagnostics.Tracing.EventSource.m_activityTracker, System.Diagnostics.Tracing.EventSource.m_Dispatchers, System.Diagnostics.Tracing.EventSource.m_eventHandleTable, System.Diagnostics.Tracing.EventSource.m_eventPipeProvider, System.Diagnostics.Tracing.EventSource.m_name, System.Diagnostics.Tracing.ActivityTracker.OnStart(), System.Diagnostics.Tracing.ActivityTracker.OnStop(), System.Diagnostics.Tracing.EventDescriptor.Opcode, System.options, System.pointer, System.Diagnostics.Tracing.EventSource.ProviderMetadata, System.Diagnostics.Tracing.DataCollector.ThreadInstance, System.Diagnostics.Tracing.EventSource.ThrowEventSourceException(), System.Diagnostics.Tracing.EventSource.UpdateDescriptor(), System.Diagnostics.Tracing.EventSource.WriteCleanup(), System.Diagnostics.Tracing.EventSource.WriteEventRaw(), and System.Diagnostics.Tracing.EventSource.WriteToAllListeners().

Referenced by System.Diagnostics.Tracing.EventSource.Write(), System.Diagnostics.Tracing.EventSource.Write(), System.Diagnostics.Tracing.EventSource.Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T >(), System.Diagnostics.Tracing.EventSource.Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T >(), System.Diagnostics.Tracing.EventSource.Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T >(), and System.Diagnostics.Tracing.EventSource.Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T >().