Created
September 5, 2017 23:00
-
-
Save brad-jones/82495e4e3cb3ad3c5b205103f37ad604 to your computer and use it in GitHub Desktop.
Intial setup for RazorLight dotnet 2.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xunit; | |
using Microsoft.AspNetCore.Razor.Language; | |
using Microsoft.AspNetCore.Razor.Language.Extensions; | |
using Microsoft.Extensions.PlatformAbstractions; | |
using Microsoft.AspNetCore.Mvc.Razor.Extensions; | |
namespace Tests.Razor | |
{ | |
public class RazorTests | |
{ | |
[Fact] | |
public void RazorTest() | |
{ | |
var engine = RazorEngine.Create(builder => RazorExtensions.Register(builder)); | |
var project = RazorProject.Create("./Razor/Templates"); | |
var templateEngine = new RazorTemplateEngine(engine, project); | |
var cSharpDocument = templateEngine.GenerateCode("HelloWorld.cshtml"); | |
Console.WriteLine("Code: " + cSharpDocument.GeneratedCode); | |
// next compile with roslyn | |
// see: https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Razor/Internal/CSharpCompiler.cs | |
// see: https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Razor/Internal/RazorViewCompiler.cs | |
// then basically call the generated assembly with reflection | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment