Class generation is common technique that empowers tools like LINQPad and SvcPerf. Here are the steps to build a simple console tool for class generation:
- In VS, create console application called EtwEventTypeGen
- Remove all references except System
- Click Add References, Manage NuGet packages
- Search for Tx.*
Install Tx.Windows.TypeGeneration
Copy HTTP_Server.man to bin\Debug and type the following code:
The component ManifestParser can read:
- Self contained .etl files produced when you use EventSource for tracing
- Manifests generated from assemblies like the above
- Manually written manifests
- Manifests exported with tracerpt.exe
example: tracerpt -export m.manHTTP_Server.etl)
- Manifests for Classic providers, exported as above (here the authoritative metadata was WMI)
Here is example of the class that gets generated for EventId = 2:
Here:
- The type system is simplified: e.g. both Unicode and ASCII strings are both mapped to "string"
- The extra mapping details are encoded in the attribute
Finally, to get more useful tool that handles command arguments you can copy the code for EtwEventTypeGen