public void InterfaceWithSimilarMethodsFolds() { var manifest = EventSourceManifest.GenerateManifest(typeof(InterfaceThatFolds)); // make sure there is only one keyword Assert.That(manifest.Contains("<keywords>\r\n <keyword name=\"Foo\" message=\"$(string.keyword_Foo)\" mask=\"0x1\"/>\r\n </keywords>")); }
/// <summary> /// Return the manifest of a provider from the assembly and type. /// </summary> /// <param name="assemblyPath">The path to the assembly containing the type.</param> /// <param name="typeName">The full name of the type.</param> /// <returns>The XML manifest content.</returns> private static string GenerateManifest(string assemblyPath, string typeName) { Assembly assembly = Assembly.LoadFrom(assemblyPath); Type type = assembly.GetType(typeName); return(EventSourceManifest.GenerateManifest(type)); }
public void InterfaceWithSimilarMethodsFolds() { var manifest = EventSourceManifest.GenerateManifest(typeof(InterfaceThatFolds)); XDocument manifestXml = XDocument.Parse(manifest); XNamespace instrumentationNamespace = "http://schemas.microsoft.com/win/2004/08/events"; // make sure there is only one keyword (besides the auto-generated SessionX keywords) Assert.That( manifestXml.Root.Descendants(instrumentationNamespace + "keyword").Count(xe => !xe.Attribute("name").Value.StartsWith("Session")), Is.EqualTo(1)); }
public void ThirdEventHasEventId3() { // Arrange const int ExpectedResult = 3; // Act var manifest = new EventSourceManifest(this.lazyManifestXml.Value); var attr = manifest.EventAttributes[nameof(KeywordsEventSource.ThreeKeywordExample)]; // Assert Assert.NotNull(attr); Assert.Equal(ExpectedResult, attr.EventId); }
public void TwoKeywordsYieldCorrectResults() { // Arrange const EventKeywords ExpectedKeywords = KeywordsEventSource.Keywords.SecondKeyword | KeywordsEventSource.Keywords.ThirdKeyword; Assert.NotNull(this.lazyManifestXml); // Act var manifest = new EventSourceManifest(this.lazyManifestXml.Value); var attr = manifest.EventAttributes[nameof(KeywordsEventSource.TwoKeywordExample)]; // Assert Assert.NotNull(attr); Assert.Equal(ExpectedKeywords, attr.Keywords); }
public void InterfaceWithManyMethodsDoesNotBreakKeywords() { // max keyword value in windows 8.1 is 0x0000100000000000 (44 bits) Assert.DoesNotThrow(() => EventSourceManifest.GenerateManifest(typeof(InterfaceWith45Methods))); }
static void Main(string[] args) { for (int i = 0; i < args.Length; i++) { switch (args[i].ToLowerInvariant()) { case "-h": case "--help": case "-?": case "/?": _showHelp = true; break; case "-n": case "-name": _name = args[++i]; _outputGuid = true; break; case "-g": case "-guid": _outputGuid = true; break; case "-a": case "-assembly": _assemblyPath = args[++i]; break; case "-t": case "-type": _typeName = args[++i]; break; default: if (args[i][0] == '-') { throw new ApplicationException(String.Format("Unknown option {0}", args[i])); } else if (_assemblyPath == null) { _assemblyPath = args[i]; } else if (_typeName == null) { _typeName = args[i]; } else { throw new ApplicationException("Too many parameters"); } break; } } if (_showHelp) { Console.WriteLine(@" GenerateProxyManifest - outputs the ETW information for a class. Parameters: -h -help -? /? Shows Help -a [assemblypath] -assembly [assemblypath] The path to the assembly .exe or .dll -t [type full name] -type [type full name] The full name of the type. -g -guid To output the ETW provider GUID rather than the manifest. -n [provider name] -name [provider name] Outputs the ETW provider guid given the provider name. "); } else if (_name != null) { Console.WriteLine(EventSourceManifest.GetGuidFromProviderName(_name)); } else if (_outputGuid) { Console.WriteLine(GetGuid(_assemblyPath, _typeName)); } else { Console.WriteLine(GenerateManifest(_assemblyPath, _typeName)); } }