Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending C# language?

Basically what I would like to know is if there is any way to add new 'statements' to the .net based languages? An example of what I'm looking for would be something like introducing a public class MyClass decoratorOf ClassWithLotsOfMethods and in pre-compile time changing that to be a normal class that overrides everything by default but the methods I define.

Another example would be the .net 3.5 auto properties, or extension methods, etc

This is just for fun, not that I really want to do this, just curious if is possible

Thanks! Seba

like image 252
Sebastian Piu Avatar asked Oct 19 '10 14:10

Sebastian Piu


2 Answers

C# doesn't allow this. You can of course tweak the generated IL with a post-compiler (like CciSharp).

Some alternative .NET languages that allow extensions are Nemerle and Boo.

like image 162
Jordão Avatar answered Sep 24 '22 09:09

Jordão


There is nothing built-in.

You could of course use a PreProcessor but that won't make you popular.

like image 36
Henk Holterman Avatar answered Sep 21 '22 09:09

Henk Holterman