Java's apt tool allows you to execute code at compile time based upon the annotations you place in your code. C# has attributes, which work like Java's annotations, but try as I might I can't seem to find a ready-made tool (ideally an open source one) that provides the same functionality for C# as apt does for Java. Does such a tool exist?
There are some. Such as:
The google search I used was:
https://www.google.com/search?q=.net+aop+attributes&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
I have had a look at PostSharp quickly before and it looks very tidy. Sprint.Net is a port from the java Sprint library I believe. There are also numerous code generation libraries out there that you could leverage by reflecting over your assembiles and performing your logic.
The short answer is No.
But if you are willing to do your own tool, take a look at Mono.Cecil for instance. It allows to inspect and modify an assembly. If are using Visual Studio (or similar) you can setup a project so that it executes commands after building (i.e. executes your Mono.Cecil based tool).
take a look af fody, a extensible tool for weaving .net assemblies: https://github.com/Fody/Fody
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