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.*
InstallTypeGen.JPG

Install Tx.Windows.TypeGeneration

Copy HTTP_Server.man from the Tx sample traces and manifests in bin\Debug and type the following code:
EtwTypeGenCode.jpg

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.man 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:

ClassGeneration.jpg
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






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

Comments

No comments yet.