Is this possible to use PostSharp or any other AOP library for Unity3d games? Has anyone done this successfully or otherwise? There are similar questions on the Internet but no definite answer.
PostSharp for Unity3d game engine
2.3k Views Asked by Vladimir At
2
There are 2 best solutions below
0

You can use PostSharp in Unity (but not in a regular way).
You have to implement your code in regular Visual Studio Class Library projects, build them in VS, put them into Unity project (you can automate this step via VS build events in project properties).
Now, in those VS Class Libraries (DLL projects) you can use PostSharp as much as you can. You can also use latest C# version too!! (Like C# 7 which is not supported by Unity yet).
Please see my answer here: http://answers.unity3d.com/questions/504525/can-you-use-postsharp-in-unity.html
Short answer: probably not.
Unity runs with the Mono runtime for the sake of cross-platform support.
PostSharp's version history indicates they had experimental or partial support for Mono in versions 1.5 and 2.0, but that it has been removed in 3.0. Partial quote:
Further, depending on which specific platform(s) you're targeting, certain language features may be restricted (for example, iOS requires that all code is compiled "AOT" or ahead-of-time, which will cause any use of reflection or other JIT-compiled code to fail).
Some of these libraries may be able to work if you can compile them to DLLs which you link with your Unity project. Otherwise, it's going to be quite a challenge.