CInterpreter is a C# .NET library to run additional code during runtime.
CInterpreter is a C# .NET library to run additional code during runtime.
The C Sharp (C#) programming language is a widely used language. One of the key features of C# is that it is a compiled language, meaning a program - called a compiler - reads through the code and converts it to a machine language. On the other hand, an interpreted language (for example, Python) is read by the computer as plain text as a program runs. In a compiled language, new code cannot be compiled and ran after the application is published, which is why the C# Interpreter library was created.
The C# Interpreter was designed to be attachable to existing .NET projects and, with minimal setup required, allow users or developers to modify or view variables, invoke methods with needed parameters, run scripts, choose actions, and more. Modern tools like Microsoft Visual Studio include features such as just-in-time compiling or running immediates, and while this project performs a similar function, it does so without the need to recompile, switch applications, or even have a debugger open.
The main purpose of the C# Interpreter is to save time or provide extra features that come with being an interpreted language such as Python's exec() function. Note that the C# Interpreter is not designed for speed or security, and as such there is no system for defining classes.
There are also situations in testing where a simple unit test is not sufficient, for instance optimizing a parameter to a function. The C# Interpreter allows running functions with custom parameters as the program is running. Modern development kits have features that can perform similar actions, such as Visual Studio's Just In Time Compiling, but they require breaking or just having the kit in the first place. The C# Interpreter has the advantage that it works anywhere and can be used on the fly to investigate subtle or hard to reproduce errors.
Want to install? Check out Setup Tutorial or Administrator Documentation
Details about the environment can be found in Comparison with C# and User Documentation
Inspiration for this project came in high school when I was fine tuning and debugging some of my code where the setup in the application was complicated and the parameters needed to be different each time. I asked my teacher if there was a better way than pausing, changing some code, trying again, observing, and repeating, and the best I ended up with was a command line interface that could recognize a few commands, parse some integers or other types, and send them through a predefined function. But I did not want to have to remake that system every time I wanted to debug something complicated, so once I learned more about C#, I solved it for the general case and ended up with a system that could nearly execute C# code during runtime as though it were compiled.