C# unfortunately does not allow for extra user-defined syntax. But I was wondering whether it was possible to surpass this limitation by tapping into the visual studio onbuild-event.
Suppose I have some syntactic sugar which could be easily translated into actual C# code. If I were to automatically translate a cs document containing this new syntax into a valid cs document, right before a C#-project is built, then the project could build succesfully. Overall this would function as if I had extended the C# language, because I started with an invalid cs document containing unoffical syntax, but it compiled anyway.
I realize that this has a few problems, such as that this translation is permanent. This could perhaps be circumvented by restoring the original cs(which should be restored after the debugging has ended, otherwise some IDE functionality would be lost). But these are secondary problems.
Please let me know what you think of this idea. Is this possible, and if so, could someone direct me to some useful tutorials so achieve this? In specific the tapping-into-a-onbuild-event. I've searched MSDN, but the topic(http://msdn.microsoft.com/en-us/library/hthab0h8.aspx) didn't help me.
:)
– Grounderstring.Format("My name is {0} and I am {1} years old.", Name, Age)
, don't you? – Grounder"Replace this: {0}".FormatWith(42)
. – Eccrine