예제 #1
0
        internal EtwEvent(XmlReader reader, EtwProvider provider, int lineNum)
        {
            this.lineNum     = lineNum;
            this.etwProvider = provider;

            this.LineNum = ((IXmlLineInfo)reader).LineNumber;

            for (bool doMore = reader.MoveToFirstAttribute(); doMore; doMore = reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "symbol":
                    this.Symbol = reader.Value;
                    break;

                case "version":
                    this.Version = (byte)EtwProvider.ParseNumber(reader.Value);
                    break;

                case "value":
                    this.Id = (ushort)EtwProvider.ParseNumber(reader.Value);
                    break;

                case "task":
                    this.taskId = reader.Value;
                    break;

                case "opcode":
                    this.opcodeId = reader.Value;
                    break;

                case "keyword":
                    this.keywordsId = reader.Value;
                    break;

                case "level":
                    this.Level = ParseLevel(reader.Value);
                    break;

                case "template":
                    this.TemplateName = reader.Value;
                    break;

                case "message":
                    this.Message = reader.Value;
                    break;

                case "channel":
                    this.Channel = reader.Value;
                    break;

                default:
                    break;
                }
            }
        }
예제 #2
0
        internal void UpdateStrings(Dictionary <string, string> stringMap)
        {
            var keys = new List <int>(this.values.Keys);

            foreach (var key in keys)
            {
                var value = this.values[key];
                if (EtwProvider.Replace(ref value, stringMap))
                {
                    value = EtwEvent.MakeCamelCase(value);
                    value = Regex.Replace(value, @"[^\w\d_]", "");
                    if (value.Length == 0)
                    {
                        value = "_";
                    }
                    this.values[key] = value;
                }
            }
        }
예제 #3
0
        internal void UpdateStrings(Dictionary <string, string> stringMap)
        {
            var message = this.Message;

            if (EtwProvider.Replace(ref message, stringMap))
            {
                this.Message = message;
            }

            if (this.Fields != null)
            {
                foreach (var parameter in this.Fields)
                {
                    if (parameter.Enumeration != null)
                    {
                        parameter.Enumeration.UpdateStrings(stringMap);
                    }
                }
            }
        }
예제 #4
0
        public static void Validate(string filesDirectory)
        {
            if (!Directory.Exists(filesDirectory))
            {
                throw new DirectoryNotFoundException(filesDirectory);
            }

            // Get details on all the Trace Records we have defined in assembly.
            var typesAndMetadataMap = GetAllTraceRecordsTypes(filesDirectory);

            var fullPathToManifest = Path.Combine(filesDirectory, ManifestFileName);

            if (!File.Exists(fullPathToManifest))
            {
                throw new FileNotFoundException(fullPathToManifest);
            }

            // Load Manifests.
            List <EtwProvider> providers = EtwProvider.LoadProviders(fullPathToManifest);

            int counter = 0;

            foreach (var kvp in typesAndMetadataMap)
            {
                var matchingEventFromManifest = GetEventFromManifest(providers, kvp.Key);
                if (matchingEventFromManifest == null)
                {
                    throw new TraceManifestMismatchException(
                              kvp.Key,
                              MismatchKind.EventMissingInManifest,
                              string.Format("Event ID: {0} missing in manifest", kvp.Key.Identity.TraceId));
                }

                MatchEvents(matchingEventFromManifest, kvp.Key, kvp.Value);
                counter++;
            }

            Console.WriteLine("{0} events validated", counter);
        }