I am currently working on a project that is accessing a piece of hardware using tons of hard coded memory locations. These locations can change based upon the electrical engineer's whim, so I'm looking to generate code from the engineer's memory map. Let's say the map is a simple text file like:
Name, Type, Address, Description
Foo, int, A001, Foo integer variable
Bar, float, A002, Bar float variable
I would like to automatically generate code (not IL) similar to:
class MachineMap
{
/// <summary>
/// Foo integer variable
/// </summary>
public readonly Addressable<int> Foo = new Addressable<int>("A001");
/// <summary>
/// Bar float variable
/// </summary>
public readonly Addressable<float> Bar = new Addressable<float>("A002");
}
Does anyone have ideas on tools that would make this task easy, or easier?
Have a look at the built-in code generation ability of Visual Studio called T4. Or another option might be commercial product such as CodeSmith.
Have a look at this article from Scott Hanselman:
T4 (Text Template Transformation Toolkit) Code Generation - Best Kept Visual Studio Secret
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With