or insert some cil code into C# code…
like into the C# file?
not really… why would you? Just write it in C#. CIL is any of the .net supported languages (like C#) compiled into its intermediate form. It’s not intended to be written directly.
If you mean you have some pre-compiled code in a dll (that would be CIL), you can definitely include it in your project.
If you mean you want to generate code on the fly in the form of CIL opcodes, you can do this with the System.Reflection.Emit namespace. As long as you’re not building for AOT, this can be done. I have a couple classes that actually do this (not mine directly, they’re opensource and I’m using them):
https://github.com/lordofduct/spacepuppy-unity-framework/blob/master/SpacepuppyBase/Utils/FastDynamicMemberAccessor/PropertyAccessor.cs
https://github.com/lordofduct/spacepuppy-unity-framework/blob/master/SpacepuppyBase/Utils/FastDynamicMemberAccessor/MemberAccessor.cs
What is this code anyways? Where did you get some CIL code just floating about that you need?
It would likely help, if you could explain a little bit more about your actual use case? Are you still trying to look for a runtime code interpreter?
Oh yeah, JohnSonLi is the person trying to get an interpreter in C#.
Which I already linked several options for that in the previous thread, but that it’s not allowed on iOS (though some people sneak it in).
If that’s what you’re trying to do. The Emit method can assist you in that… BUT, it too is NOT support on iOS. This time in the technical sense, and not just the rules sense. It straight up won’t compile. Unlike the interpreters that work with things like Lua and javascript… which will compile (depending the library you use), but just aren’t allowed on iOS.
Long story short… interpreted code is not allowed on iphone. There is no getting around that, because even if you DID, Apple will take your app down if they find out its in there.
an interpreter might not be a must I have been looking for, but I am new to mono and I want to learn more about it in a low level way…I am just a little bit curious…