Skip to content

Commit

Permalink
Update to PR #141
Browse files Browse the repository at this point in the history
  • Loading branch information
adoconnection committed Apr 16, 2024
1 parent 12fbe72 commit cca0f47
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Pack.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dotnet build -c Release
dotnet test
dotnet pack -c Release -o artifacts RazorEngineCore\RazorEngineCore.csproj -p:symbolPackageFormat=snupkg --include-symbols
dotnet nuget push artifacts\RazorEngineCore.2023.11.2.nupkg --source https://www.nuget.org/api/v2/package -k KEY
dotnet nuget push artifacts\RazorEngineCore.2024.4.1.nupkg --source https://www.nuget.org/api/v2/package -k KEY
2 changes: 1 addition & 1 deletion RazorEngineCore.Tests/RazorEngineCore.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
15 changes: 9 additions & 6 deletions RazorEngineCore.Tests/TestCompileAndRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void TestCompileAndRun_NullablePropertyWithValue()

string actual = template.Run(instance => instance.Model = new TestModel()
{
DateTime = dateTime
DateTime = dateTime
});

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

string actual = template.Run(instance => instance.Model = new TestModel()
{
DateTime = dateTime
DateTime = dateTime
});

Assert.AreEqual("DateTime: " + dateTime, actual);
Expand Down Expand Up @@ -538,7 +538,7 @@ Hello @Model.Decorator(Model.C)
{
instance.Model = new TestModel
{
C = "Alex"
C = "Alex"
};
});

Expand Down Expand Up @@ -635,7 +635,7 @@ public void TestCompileAndRun_DynamicModelLinq()
";
string actual = template.Run(new
{
Numbers = new List<object>() {2, 1, 3}
Numbers = new List<object>() { 2, 1, 3 }
});

Assert.AreEqual(expected, actual);
Expand Down Expand Up @@ -911,12 +911,15 @@ public void TestCompileAndRun_IncludeDebuggingForTypedAnonymous_EnabledDebugging
[TestMethod]
public void TestCompileAndRun_ProjectEngineBuilderAction_IsInvoked()
{
var builderActionIsInvoked = false;
var builderActionIsInvoked = false;
RazorEngine razorEngine = new RazorEngine();
IRazorEngineCompiledTemplate template = razorEngine.Compile("<h1>Hello @Model.Name</h1>", builder =>
{
builder.IncludeDebuggingInfo();
builder.Options.ProjectEngineBuilderAction = (x) => builderActionIsInvoked = true;
builder.ConfigureRazorEngineProject(engineBuilder =>
{
builderActionIsInvoked = true;
});
});

template.EnableDebugging();
Expand Down
7 changes: 7 additions & 0 deletions RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis;

namespace RazorEngineCore
Expand Down Expand Up @@ -56,5 +57,11 @@ public interface IRazorEngineCompilationOptionsBuilder
/// Enables debug info
/// </summary>
void IncludeDebuggingInfo();

/// <summary>
/// Access RazorProjectEngineBuilder to register new Features etc
/// </summary>
/// <param name="configure"></param>
void ConfigureRazorEngineProject(Action<RazorProjectEngineBuilder> configure);
}
}
2 changes: 1 addition & 1 deletion RazorEngineCore/RazorEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected virtual RazorEngineCompiledTemplateMeta CreateAndCompileToStream(strin
(builder) =>
{
builder.SetNamespace(options.TemplateNamespace);
options.ProjectEngineBuilderAction?.Invoke(builder);
options.ProjectEngineBuilder?.Invoke(builder);
});

RazorSourceDocument document = RazorSourceDocument.Create(templateSource, fileName);
Expand Down
2 changes: 1 addition & 1 deletion RazorEngineCore/RazorEngineCompilationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RazorEngineCompilationOptions
"System.Collections",
"System.Collections.Generic"
};
public Action<RazorProjectEngineBuilder> ProjectEngineBuilderAction { get; set; }
public Action<RazorProjectEngineBuilder> ProjectEngineBuilder { get; set; }

public RazorEngineCompilationOptions()
{
Expand Down
9 changes: 9 additions & 0 deletions RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis;

namespace RazorEngineCore
Expand Down Expand Up @@ -134,5 +135,13 @@ public void IncludeDebuggingInfo()
this.Options.IncludeDebuggingInfo = true;
}

/// <summary>
/// Enables debug info
/// </summary>
public void ConfigureRazorEngineProject(Action<RazorProjectEngineBuilder> configure)
{
this.Options.ProjectEngineBuilder = configure;
}

}
}
10 changes: 5 additions & 5 deletions RazorEngineCore/RazorEngineCore.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netstandard2.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2023.11.2</Version>
<Authors>Alexander Selishchev, Simon Mourier, William David Cossey, Benjamin Smith, Dag H. Baardsen, krmr, jddj007-hydra, shehrozeee, TheAtomicOption</Authors>
<Version>2024.4.1</Version>
<Authors>Alexander Selishchev, Simon Mourier, William David Cossey, Benjamin Smith, Dag H. Baardsen, krmr, jddj007-hydra, shehrozeee, TheAtomicOption, ItWorksOnMyMachine</Authors>
<PackageProjectUrl>https://github.com/adoconnection/RazorEngineCore</PackageProjectUrl>
<Description>NET6 Razor Template Engine</Description>
<AssemblyVersion>2023.11.2</AssemblyVersion>
<FileVersion>2023.11.2</FileVersion>
<AssemblyVersion>2024.4.1</AssemblyVersion>
<FileVersion>2024.4.1</FileVersion>
<PackageReleaseNotes></PackageReleaseNotes>
<Company>Alexander Selishchev</Company>
<SignAssembly>true</SignAssembly>
Expand Down

0 comments on commit cca0f47

Please sign in to comment.