This is a mirror of official site: http://jasper-net.blogspot.com/

C# Compiler as a Service Update

| Sunday, February 27, 2011
Our C# compiler-as-a-service library can now process any C# construct, it is no longer limited to expressions and statements.

This means, that you can now enter entire class definitions in the command line:

csharp> class Demo {
     >     public int Add (int a, int b)
     >     {
     >          return a + b;
     >     }
     > }
csharp> new Demo ().Add (1, 3);
4


csharp>

This work was done by the amazing Marek and is now available on Mono's master branch in github.

This functionality can also be used for scripts, in particular in Unix, you can now create C# "source executable" files, like this:

bash$ cat demo.cs
#!/usr/bin/csharp
class Demo {
public dynamic Add (dynamic a, dynamic b)
{
return a + b;
}
}
Console.WriteLine (new Demo ().Add ("this is", " cute"));

bash$ chmod +x demo.cs
bash$ ./demo.cs
this is cute

bash$

Multiple Compiler Instances

In addition, we turned the static API Evalutor.Eval (string expression), into an instance API. The instance API allows developers that are embedding the C# compiler-as-a-service in their application to have different contexts.

Read more: Personal blog of Miguel de Icaza

Posted via email from Jasper-net

0 comments: