I'm writing code that will execute a series of test steps, these test steps will align to test steps manually captured in a test case, here is an example:

The above screenshot shows 3 steps for a sample test case (This is viewed using Microsoft Test Manager).
Please also keep in mind this is a primitive example, simplified for this question, in reality it's not uncommon to have 50 test steps and vastly more complicated scenarios, also I've omitted cleanup and entry code in the below function.
Now the code that runs this looks something like this: (Pay attention to the try/catch mechanism which allows the test to fail on a particular step) :
[TestMethod] public void LinksPageOpensFromClick() { int step = 0; try { step++; // Code to Open the page } catch (Exception ex ) { Assert.Fail(AppManager.RaiseError(step, "Open the page", ex)); } try { step++; // Code to Click links button } catch (Exception ex) { Assert.Fail(AppManager.RaiseError(step, "Click links button", ex)); } try { step++; // Code to Assert links page opened } catch (Exception ex) { Assert.Fail(AppManager.RaiseError(step, "Assert links page opened ", ex)); } } First observation is, I used to just hard code in the value of step like this:
Assert.Fail(AppManager.RaiseError(3, "Assert links page opened ", ex)); But this means that should the test change later, and test steps added or reordered, it means manually changing a vast number of steps.
Having steps as an incremented variable too isn't ideal, firstly it's not exactly elegant, and it's too error prone if you forget to increment the step. In addition you can't pattern scan the code and see what step you're on without adding additional comments.
What I'm really looking for is a solution like this:
[StepDesc="Assert links page opened"] Step { // Code to exec } Error (Exception ex) { Assert.Fail(AppManager.RaiseError(Step.Count, Step.Desc, ex)); } Failing that, a cleaner way to increment step count or make it more dynamic without having to manually increment it.
Also if C# cannot handle this, perhaps I could put all my front facing test cases in another project which might not be C# but is MSIL compliant?
Dictionary<int,string>with # of step to error text