I'm having trouble deciding how to solve a tricky situation, and I'm hoping for some input. Perhaps I'm missing something.
My situation is that I'm implementing script support in my game through C# code being compiled on the fly. The scripts are not to be trusted, so I'm sandboxing them in a separate AppDomain. The problem is, this AppDomain cannot access the XNA assemblies since XNA demands full trust, and I need at least Vectors, Matrixes and a few other base classes from XNA.
So, I clearly need my own versions of these classes, and no worries there. I'm just not sure how far to use these classes.
My first idea was to get rid of all XNA's versions of the classes and use my own over my whole code base. The idea is sound, and the main benefit is that I may use my math libs, helper functions etc in the scripts too. I'd get rid of some annoying dependencies to XNA. However, there is one big caveat: I need to convert them into their XNA counterparts every time i use XNA's functionality. This comes as a small performance cost, and a (IMO) huge ugliness cost.
The other version is to use the custom Vector, Matrix, etc only for the script and convert to XNA counterparts as soon as I get back the script output. There's the ugliness here too, but contained closely around the interface around the sandbox. I'd have to duplicate any helper functions that I've created - which is in a way nice, since I'd keep the things exposed to the script very strictly separated.
Méh. Any takes on this?
No replies to this topic