[Mono-dev] Using Mono C# compiler for dynamic compilation of scripts

Nikita Tsukanov keks9n at gmail.com
Fri Feb 14 15:23:12 UTC 2014


http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.compileassemblyfromsource%28v=vs.110%29.aspx-
it's not 'in-memory', but it's well-documented and you can delete temp
file after loading it's contents (if you use Assembly.Load
(File.ReadAllBytes (path)) Mono won't try to access the file after loading
it).

Regards,
Nikita


2014-02-14 15:58 GMT+04:00 Rafal Gwizdala <rafal.gwizdala at gmail.com>:

> Hi guys,
>
> Sorry if this question shows my complete ignorance, but I'm stuck and
> don't know where to go next.
> I'm trying to use Mono C# compiler api for dynamic compilation of code
> blocks. I was trying to use the Mono.CSharp.Evaluator class, but it's
> rather suitable for evaling expressions or compiling simple code snippets
> into methods, and I'd like to do few different things:
> - compile whole class definition from a source file into an in-memory
> assembly
> - dynamically create a class by inheriting from an abstract base class and
> implementing / overriding a single abstract method in it with script code
>
> The second case is particularly interesting to me. What i'd like to to is
> write the method body in the script file, and then convert it into a
> derived class during compilation, so the script would not contain all the
> boilerplate code (namespace references, class and method declarations) -
> only the overridden method body. This is quite similar to what 'Rhino.DSL'
> does in Boo - a script is converted into overridden method body in a
> dynamically created class that inherits from some specified base type.
> Can you point me to some examples?
> Thanks a lot
> RG
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20140214/50fb8647/attachment.html>


More information about the Mono-devel-list mailing list