Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Add support for meta programming #39

Closed
davidfowl opened this issue Mar 5, 2014 · 0 comments
Closed

Add support for meta programming #39

davidfowl opened this issue Mar 5, 2014 · 0 comments

Comments

@davidfowl
Copy link
Member

Everything under Compilers/Preprocess/*/.cs will become an independent assembly. The assembly needs to implement an ICompileModule:

[AssemblyNeutral]
public interface ICompileModule
{
    void BeforeCompile(IBeforeCompileContext context);
    void AfterCompile(IAfterCompileContext context);
}

[AssemblyNeutral]
public interface IBeforeCompileContext
{
    CSharpCompilation CSharpCompilation { get; set; }
    IList<ResourceDescription> Resources { get; }
    IList<Diagnostic> Diagnostics { get; }
}

[AssemblyNeutral]
public interface IAfterCompileContext
{
    CSharpCompilation CSharpCompilation { get; set; }

    IList<Diagnostic> Diagnostics { get; }
}

The current compilation context will be passed into the process method and a compilation will be expected in return.

  • This will be called at runtime, build time and design time (in the DTH)
  • It will use the application's dependencies as well as development dependencies (see Add support for development dependencies #38)
  • This is the same interface that will be discovered when you want to write a nuget package that wants to meta program assemblies. For example the razor precompiled views will be a standalone nuget package that will be able to turn razor files into C# files precompiled as part of the application assembly.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants