Roslyn, deux qui la tiennent...

Roslyn September CTP is out, despite rumors of it  being dead, and although there is no redist, it solves all the issues I had with type dependency (Mono's terrible API really does not help) and opens-up the road for VS.Net integration.

This is very exiting news for C#ylon!

using Roslyn.Compilers;
using Roslyn.Compilers.CSharp;

namespace RoslynTest
    class Program
        static void Main(string[] args)

            var comp = Compilation.Create("Test.dll"
                , syntaxTrees: new[] { CreateTree("Foo", "Bar"), CreateTree("Bar", "Foo") }
                , references: new[] { new MetadataFileReference("mscorlib.dll") }
                                   , options: new CompilationOptions(OutputKind.DynamicallyLinkedLibrary)

            EmitResult a = comp.Emit("Test.dll");

        private static SyntaxTree CreateTree(string a, string b)
            return SyntaxTree.Create(Syntax.CompilationUnit()
                                         .WithMembers(Syntax.List(CreateCoDep(a, b))));

        private static MemberDeclarationSyntax CreateCoDep(string typeName, string fieldName)
            return Syntax.ClassDeclaration(typeName)

Back to hacking  tonight!

No comments:

Post a Comment

Please leave your comments in English or French and I will be pleased to answer them if you have any questions.

Spammers will be walked down the plank matey. Arrr!