adoconnection / RazorEngineCore

.NET6 Razor Template Engine
MIT License
576 stars 85 forks source link

Update referenced NuGet packages to newer versions #43

Closed TheDanielDoyle closed 3 years ago

TheDanielDoyle commented 3 years ago

Hi, would it be possible to update the NuGet packages RazorEngineCore uses? The ones currently in the latest release are quite out of date.

For instance, Microsoft.AspNetCore.Razor.Language is at 5.0.2 at this time.

adoconnection commented 3 years ago

Hi, It's because net core version jumped from 3.1 to 5.0 I will update references but I honestly belive there is no much difference to the engine itself :) so seems like non critical.

If your project is .NET5 then you should be able to use all new fatures right away

namespace ConsoleApp43
{
    public record Person
    {
        public string LastName { get; }
        public string FirstName { get; }

        public Person(string first, string last) => (FirstName, LastName) = (first, last);
    }

    class Program
    {
        static void Main(string[] args)
        {
            IRazorEngine razorEngine = new RazorEngine();
            var template = razorEngine.Compile<RazorEngineTemplateBase<Person>>("Hello @Model.FirstName @Model.LastName");

            string result = template.Run(instance =>
            {
                instance.Model = new Person("Your", "Name");
            });

            Console.WriteLine(result);
            Console.ReadKey();
        }
    }
}
adoconnection commented 3 years ago

done in https://www.nuget.org/packages/RazorEngineCore/2021.3.1

kobruleht commented 3 years ago

This updata produces compiler warning

Warning CS1701: Assuming assembly reference 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' used by 'MyApp' matches identity 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' of 'Microsoft.AspNetCore.Mvc.ViewFeatures', you may need to supply runtime policy

Microsoft.AspNetCore.Mvc.ViewFeatures, Version=5.0.0.0 does not exists in .NET 5