Repository navigation
RazorEngine.NetFramework 4.2.0
-
(NEW) The C# language version of templates can be pinned with
DefaultCompilerServiceFactory.LanguageVersion(also onRoslynCompilerServiceFactory, andCSharpRoslynCompilerService.LanguageVersion). The default stays the newest version the bundled Roslyn supports (C# 14). Pin an older version when a newer C# version changes the meaning of existing templates, see thefieldentry under 4.1.0:config.CompilerServiceFactory = new DefaultCompilerServiceFactory { LanguageVersion = Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp13 };
-
(PERFORMANCE) The Roslyn compiler service caches the metadata references of the loaded assemblies templates are compiled against, per
AppDomain, so Roslyn reuses what it read from them instead of reading and analyzing every referenced assembly on each compile. Each compile after the first is about 35 to 50% faster: in a benchmark, about 25 ms instead of 40 ms with 64 loaded assemblies, and about 48 ms instead of 95 ms with 255. The first compile in a process is unchanged (about 2 s for loading Roslyn). A loaded assembly cannot change, so the cache never goes stale; references given as a file path, stream or byte array (by a customIReferenceResolver) are read on every compile. Templates themselves are not cached by this; changed templates are recompiled as before. -
(BUILD)
dotnet packvalidates the package against the last published version (package validation, baseline 4.1.0) and fails on breaking changes of the public API. -
(DOCS) The README links the documentation pages in
doc(with absolute links, so they also work on nuget.org) instead of the original project's website, and its AppDomain example for cleaning up temporary files uses a fully trusted AppDomain instead of suggesting a partially trusted one. -
(DOCS) New page Caching: how compiled templates are cached (template key and model type), what
RunCompile,Compile,RunandIsTemplateCacheddo, the three caching providers with examples for invalidating, why invalidating does not free memory (each recompile loads a new assembly that stays until itsAppDomainis unloaded) and when temporary files are deleted. -
(DOCS) Roslyn shows how to pin
LanguageVersionwhen RazorEngine is configured inapp.config/web.config: derive a factory that sets it in its constructor and name that type incompilerServiceFactoryType. -
(DOCS) Outdated passages removed from the documentation: links to the original project's website, notes about Mono (the fork targets .NET Framework 4.8 on Windows) and an old Travis CI link.
ReferenceResolver.mdexplains which compiler needs which references. -
(BUILD) Removed files and projects that nothing used or shipped:
RazorEngine.Mvc,RazorEngine.Hosts.Console, the old FSharp.Formatting doc site, the class diagram and an unused ruleset. The tests buildTestHelper.dllinstead of using a checked-in binary.
NuGet: https://www.nuget.org/packages/RazorEngine.NetFramework/4.2.0