Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 577 forks source link

Compatibility with Razor 4 #322

Open clementguillot opened 8 years ago

clementguillot commented 8 years ago

The latest version of Razor 4.0.0 beta7 introduces a breaking change:

MissingMethodException: Method not found: "Void Microsoft.AspNet.Razor.CodeGenerators.GeneratedClassContext.set_ResolveUrlMethodName(System.String)". in RazorEngine.Compilation.CompilerServiceBase.CreateHost(Type templateType, Type modelType, String className)

The breaking commit is the following: https://github.com/aspnet/Razor/commit/48a6b567d6d2194ce390599c37ef1e1b7c9c5a9e And involved code: https://github.com/Antaris/RazorEngine/blob/590b79cfb6253d6aa5e83863994ce12ae6178a34/src/source/RazorEngine.Core/Compilation/CompilerServiceBase.cs#L255

All credits go to hypercodeplace and N. Taylor Mullen: http://stackoverflow.com/questions/32558941/razorengine-and-mvc-6-beta-7

matthid commented 8 years ago

It's really hard to keep up with the new betas, a PR is very welcome.

matthid commented 8 years ago

Note for anyone who wants to contribute this:

  1. clone
  2. build.cmd (build.sh on linux/git bash)
  3. .paket/paket.exe update (mono .paket/paket.exe update on linux)
  4. Fix build errors and make sure all unit tests pass.
  5. Commit, Push and send a PR
danieljsummers commented 8 years ago

Is this still open? I forked and cloned, but the code I was going to try was already in there.

On a related note, build.cmd bombed out trying to build RazorEngine.Mvc for .NET 4.5, due to not being able to resolve the reference System.Web.Mvc. Am I missing something simple?

clementguillot commented 8 years ago

Maybe this could help you: http://stackoverflow.com/questions/32558941/render-razor-view-to-string-in-asp-net-core/37296765#37296765

I tried to build the project and I had to manually add some Nuget packages for non-ASP.NET Core assemblies. Now that I've update the project latest RC2 (including all renaming and fixing dependencies), I'm stucked with unit tests that do not pass.

campersau commented 8 years ago

I think this was fixed by https://github.com/Antaris/RazorEngine/commit/f9ff03f6dfeaff30f66733b0cfb26498a92c51b7#diff-24148d0c5a96b5e47e787da26f876378R256

farshid3003 commented 6 years ago

Is there any update ? I'm not going to render a view to a string. I need to compile and render in memory text templates with dynamic JObject models so I cannot use RazorLight(no support for dynamic models) or asp.net view engine which need file path and view not text My templates are in mongoDB