This project is read-only.

C# Type Generation

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
  • Select "Include Prerelease" for the dropdown and search for Tx.*

Install Tx.Windows.TypeGeneration

Copy from the Tx sample traces and manifests in 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 HTTP_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:

  • 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

Last edited Aug 5, 2013 at 7:42 PM by georgis, version 5


No comments yet.