Project Description
Wrapper around the Roslyn C# Syntax-API. (85%)
Wrapper around the Roslyn C# Semantic-API. (15%)
Interactive Generator (5%)

Also available as NuGet Package:
https://nuget.org/packages/BITS.PreCompiler.CSharp.NET40
Install-Package BITS.PreCompiler.CSharp.NET40

https://nuget.org/packages/BITS.PreCompiler.CSharp.NET45
Install-Package BITS.PreCompiler.CSharp.NET45

Would be nice if the roslyn project could pick up some ideas.
There are even more ideas but currently not sufficient time to develop them.

Semantics
Generator
Features

Example of creating a class with an constructor:
var @class = new Class("BlueITSystems")
{
	new Constructor
	{
		new ThisInitializer
		{
			@"new Object()",
			@"new Object()",
		},

		@"this.Init();",
	},
};

Call to @class.ToString() will result in:
public class BlueITSystems
{
    public BlueITSystems() : this(new Object(), new Object())
    {
        this.Init();
    }
}


Example with some members:
var @class = new Class("BlueITSystems")
{
	new Property("PropertyOne")
		.WithAutoAccessors(),

	new Constructor(),

	new Method("MethodOne"),
};

Call to @class.ToString() will result in:
public class BlueITSystems
{
    private Object PropertyOne { get; set; }

    public BlueITSystems()
    {
    }

    private void MethodOne()
    {
    }
}


Example with mixed definitions:
var @class = new Class("BlueITSystems")
{
	@"public int TestPropertyA { get; set; }",
	
	@"public string TestPropertyB { get; set; }",

	new Property(@return: "NewClass", identifier: "PropertyC")
		.WithAutoAccessors(),

	new Property(@return: "NewClass", identifier: "PropertyD")
	{
		@"get { return new NewClass(); }",
		@"set { return null; }",
	},
	
	@"public int TestMethodA()
	{
		var x = 0;

		return x;
	}",

	new Method(new Class("TypeA"), identifier: "MethodB")
	{
		@"int i = 0; string x;",

		@"return null;",
	},

	new Class("InnerClassAA")
	{
		new Class("TypeA"),
	},

	new Class("TypeA"),
};

Call to @class.ToString() will result in:
public class BlueITSystems
{
    public int TestPropertyA { get; set; }
    public string TestPropertyB { get; set; }
    private NewClass PropertyC { get; set; }

    private NewClass PropertyD
    {
        get
        {
            return new NewClass();
        }

        set
        {
            return null;
        }
    }

    public int TestMethodA()
    {
        var x = 0;

        return x;
    }

    private TypeA MethodB()
    {
        int i = 0; string x;
        return null;
    }

    public class InnerClassAA
    {
        public class TypeA
        {
        }
    }

    public class TypeA
    {
    }
}


Would be nice if Roslyn could make possible somthing like that;
var @class = new Class("BlueITSystems")
{
	new Property("PropertyOne")
		.WithAutoAccessors(),

	new Method("MethodOne")
	{
		(BlueITSystems @this) =>
		{
			var result = @this.PropertyOne;
			Console.WriteLine(result);
		},
	},
};

More examples are in the Test Project in sourcecode.
-
-

Last edited Jun 2, 2013 at 8:26 PM by JavedSaqib, version 10