string EventAttribute(EventData eventData)
 {
     if (ReferenceEquals(eventData, null))
         throw new NullReferenceException();
     var sb = new StringBuilder("Event(").AppendFormat("{0}", eventData.EventId);
     if (false == String.IsNullOrWhiteSpace(eventData.Message))
     {
         sb.AppendFormat(@", Message = @""{0}""", eventData.Message);
     }
     if (eventData.Keywords.Length > 0)
     {
         var items =
             from kw in eventData.Keywords
             let type = _reserverdKeywords.Contains(kw) ? "System.Diagnostics.Tracing.EventKeywords" : "Keywords"
             select $"{type}.{kw}";
         sb.AppendFormat(@", Keywords = {0}", String.Join(" | ", items));
     }
     if (false == String.IsNullOrWhiteSpace(eventData.Opcode))
     {
         string type = _reserverdOpcodes.Contains(eventData.Opcode) ? "System.Diagnostics.Tracing.EventOpcode" : "Opcodes";
         sb.AppendFormat(@", Opcode = {0}.{1}", type, eventData.Opcode);
     }
     if (false == String.IsNullOrWhiteSpace(eventData.Task))
     {
         sb.AppendFormat(@", Task = Tasks.{0}", eventData.Task);
     }
     if (eventData.Level.HasValue)
     {
         sb.AppendFormat(@", Level = EventLevel.{0}", eventData.Level);
     }
     return sb.Append(")").ToString();
 }
 string EventArgsList(EventData eventData, bool includeEventId = false)
 {
     if (ReferenceEquals(eventData, null))
         throw new NullReferenceException();
     var parameters =
         (from p in eventData.Parameters
          select $"{this.EtwParameterName(p)}").ToList();
     if (includeEventId)
         parameters.Insert(0, eventData.EventId.ToString("g"));
     return string.Join(", ", parameters);
 }
 string EventArgsDeclaration(EventData eventData, bool includeEventId = false)
 {
     if (ReferenceEquals(eventData, null))
         throw new NullReferenceException();
     var parameters =
         (from p in eventData.Parameters
          select $"{p.ParameterType} { this.EtwParameterName(p)}").ToList();
     if (includeEventId)
         parameters.Insert(0, "System.Int32 EventId");
     return string.Join(", ", parameters);
 }
        string OnEventArgsList(EventData eventData)
        {
            if (ReferenceEquals(eventData, null))
                throw new NullReferenceException();
            var prefix = $"ETW/{eventData.Source.EventSourceName}/{eventData.Name} {eventData.EventId}";
            string message = eventData.Message;
            if (string.IsNullOrWhiteSpace(message))
            {
                var ph =
                    (from i in Enumerable.Range(0, eventData.Parameters.Length)
                     let p = eventData.Parameters[i]
                     select $"{this.EtwParameterName(p)} = {{{i}}}");
                message = string.Join(", ", ph);
            }

            var fmtString = $"\"{prefix}> {message}\"";
            var args =
                (from p in eventData.Parameters
                 select this.EtwParameterName(p)).ToList();
            args.Insert(0, fmtString);
            return string.Join(", ", args);
        }
        string IsEnabledArgsList(EventData eventData)
        {
            if (ReferenceEquals(eventData, null))
                throw new NullReferenceException();
            if (eventData.Level.HasValue || eventData.Keywords.Any())
            {
                var items =
                        (from kw in eventData.Keywords
                         let type = _reserverdKeywords.Contains(kw) ? "System.Diagnostics.Tracing.EventKeywords" : "Keywords"
                         select $"{type}.{kw}").ToList();

                string keywords = items.Any() ? String.Join(" | ", items) : "System.Diagnostics.Tracing.EventKeywords.All";
                return $"EventLevel.{(eventData.Level.HasValue ? eventData.Level.ToString() : "LogAlaws")}, {keywords}";
            }

            return string.Empty;
        }