Skip to content

Commit cca0f47

Browse files
committed
Update to PR #141
1 parent 12fbe72 commit cca0f47

8 files changed

+34
-15
lines changed

Pack.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dotnet build -c Release
22
dotnet test
33
dotnet pack -c Release -o artifacts RazorEngineCore\RazorEngineCore.csproj -p:symbolPackageFormat=snupkg --include-symbols
4-
dotnet nuget push artifacts\RazorEngineCore.2023.11.2.nupkg --source https://www.nuget.org/api/v2/package -k KEY
4+
dotnet nuget push artifacts\RazorEngineCore.2024.4.1.nupkg --source https://www.nuget.org/api/v2/package -k KEY

RazorEngineCore.Tests/RazorEngineCore.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

RazorEngineCore.Tests/TestCompileAndRun.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void TestCompileAndRun_NullablePropertyWithValue()
241241

242242
string actual = template.Run(instance => instance.Model = new TestModel()
243243
{
244-
DateTime = dateTime
244+
DateTime = dateTime
245245
});
246246

247247
Assert.AreEqual("DateTime: " + dateTime, actual);
@@ -258,7 +258,7 @@ public void TestCompileAndRun_NullablePropertyWithoutValue()
258258

259259
string actual = template.Run(instance => instance.Model = new TestModel()
260260
{
261-
DateTime = dateTime
261+
DateTime = dateTime
262262
});
263263

264264
Assert.AreEqual("DateTime: " + dateTime, actual);
@@ -538,7 +538,7 @@ Hello @Model.Decorator(Model.C)
538538
{
539539
instance.Model = new TestModel
540540
{
541-
C = "Alex"
541+
C = "Alex"
542542
};
543543
});
544544

@@ -635,7 +635,7 @@ public void TestCompileAndRun_DynamicModelLinq()
635635
";
636636
string actual = template.Run(new
637637
{
638-
Numbers = new List<object>() {2, 1, 3}
638+
Numbers = new List<object>() { 2, 1, 3 }
639639
});
640640

641641
Assert.AreEqual(expected, actual);
@@ -911,12 +911,15 @@ public void TestCompileAndRun_IncludeDebuggingForTypedAnonymous_EnabledDebugging
911911
[TestMethod]
912912
public void TestCompileAndRun_ProjectEngineBuilderAction_IsInvoked()
913913
{
914-
var builderActionIsInvoked = false;
914+
var builderActionIsInvoked = false;
915915
RazorEngine razorEngine = new RazorEngine();
916916
IRazorEngineCompiledTemplate template = razorEngine.Compile("<h1>Hello @Model.Name</h1>", builder =>
917917
{
918918
builder.IncludeDebuggingInfo();
919-
builder.Options.ProjectEngineBuilderAction = (x) => builderActionIsInvoked = true;
919+
builder.ConfigureRazorEngineProject(engineBuilder =>
920+
{
921+
builderActionIsInvoked = true;
922+
});
920923
});
921924

922925
template.EnableDebugging();

RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Reflection;
3+
using Microsoft.AspNetCore.Razor.Language;
34
using Microsoft.CodeAnalysis;
45

56
namespace RazorEngineCore
@@ -56,5 +57,11 @@ public interface IRazorEngineCompilationOptionsBuilder
5657
/// Enables debug info
5758
/// </summary>
5859
void IncludeDebuggingInfo();
60+
61+
/// <summary>
62+
/// Access RazorProjectEngineBuilder to register new Features etc
63+
/// </summary>
64+
/// <param name="configure"></param>
65+
void ConfigureRazorEngineProject(Action<RazorProjectEngineBuilder> configure);
5966
}
6067
}

RazorEngineCore/RazorEngine.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected virtual RazorEngineCompiledTemplateMeta CreateAndCompileToStream(strin
6767
(builder) =>
6868
{
6969
builder.SetNamespace(options.TemplateNamespace);
70-
options.ProjectEngineBuilderAction?.Invoke(builder);
70+
options.ProjectEngineBuilder?.Invoke(builder);
7171
});
7272

7373
RazorSourceDocument document = RazorSourceDocument.Create(templateSource, fileName);

RazorEngineCore/RazorEngineCompilationOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class RazorEngineCompilationOptions
2323
"System.Collections",
2424
"System.Collections.Generic"
2525
};
26-
public Action<RazorProjectEngineBuilder> ProjectEngineBuilderAction { get; set; }
26+
public Action<RazorProjectEngineBuilder> ProjectEngineBuilder { get; set; }
2727

2828
public RazorEngineCompilationOptions()
2929
{

RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5+
using Microsoft.AspNetCore.Razor.Language;
56
using Microsoft.CodeAnalysis;
67

78
namespace RazorEngineCore
@@ -134,5 +135,13 @@ public void IncludeDebuggingInfo()
134135
this.Options.IncludeDebuggingInfo = true;
135136
}
136137

138+
/// <summary>
139+
/// Enables debug info
140+
/// </summary>
141+
public void ConfigureRazorEngineProject(Action<RazorProjectEngineBuilder> configure)
142+
{
143+
this.Options.ProjectEngineBuilder = configure;
144+
}
145+
137146
}
138147
}

RazorEngineCore/RazorEngineCore.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netstandard2.0</TargetFrameworks>
44
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
5-
<Version>2023.11.2</Version>
6-
<Authors>Alexander Selishchev, Simon Mourier, William David Cossey, Benjamin Smith, Dag H. Baardsen, krmr, jddj007-hydra, shehrozeee, TheAtomicOption</Authors>
5+
<Version>2024.4.1</Version>
6+
<Authors>Alexander Selishchev, Simon Mourier, William David Cossey, Benjamin Smith, Dag H. Baardsen, krmr, jddj007-hydra, shehrozeee, TheAtomicOption, ItWorksOnMyMachine</Authors>
77
<PackageProjectUrl>https://github.com/adoconnection/RazorEngineCore</PackageProjectUrl>
88
<Description>NET6 Razor Template Engine</Description>
9-
<AssemblyVersion>2023.11.2</AssemblyVersion>
10-
<FileVersion>2023.11.2</FileVersion>
9+
<AssemblyVersion>2024.4.1</AssemblyVersion>
10+
<FileVersion>2024.4.1</FileVersion>
1111
<PackageReleaseNotes></PackageReleaseNotes>
1212
<Company>Alexander Selishchev</Company>
1313
<SignAssembly>true</SignAssembly>

0 commit comments

Comments
 (0)