toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.5k stars 259 forks source link

RazorLight template fails when System.Runtime.Experimental NuGet included #505

Closed CurtisFulton closed 1 year ago

CurtisFulton commented 1 year ago

Describe the bug When trying to use RazorLight with System.Runtime.Experimental (v6.0.2) it errors with the 'is defined in an assembly that is not referenced' exception.

To Reproduce Create a blank Console Application, add System.Runtime.Experimental and RazorLight NuGet packages. Then add the following code to the Program.cs:

using RazorLight;

var engine = new RazorLightEngineBuilder()
                .AddDynamicTemplates(new Dictionary<string, string>
                {
                    { "Test", "Hello @Model.Test, welcome to RazorLight!" }
                })
                .UseMemoryCachingProvider()
                .Build();

var model = new { Test = "Blah" };

var result = await engine.CompileRenderAsync("Test", model);

It works if you just uninstall the System.Runtime.Experimental NuGet package, but not when it is installed.

Expected behavior I can understand if this doesn't work, but it would be nice if it does. I'm not sure what the System.Runtime.Experimental NuGet does under the covers so it might make it hard to work around.

If it isn't possible for this to work though, potentially a warning/information in the readme to say it's not supported would be nice, it took a while to backtrack to find this was the cause.

Apologies if there's already information about this, I couldn't find anything through google or a quick look through the issues.

Information (please complete the following information):

jzabroski commented 1 year ago

This isn't a RazorLight issue. Figure out your dependency tree and resolve it.