Skip to content

Commit 9dab9f4

Browse files
committed
In test and sample projects added support of .NET 7
1 parent 1323d5f commit 9dab9f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2419
-30
lines changed

JavaScriptEngineSwitcher.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JavaScriptEngineSwitcher.Sa
114114
EndProject
115115
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5", "samples\JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5\JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.csproj", "{189376C9-49DA-4A12-9C78-CE39E8EC7731}"
116116
EndProject
117-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6", "samples\JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6\JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.csproj", "{58321699-3715-4CA7-8036-A9F26E4C93F3}"
117+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6", "samples\JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6\JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.csproj", "{58321699-3715-4CA7-8036-A9F26E4C93F3}"
118+
EndProject
119+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7", "samples\JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7\JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.csproj", "{923B1463-910F-4542-8E68-29F36A9DB508}"
118120
EndProject
119121
Global
120122
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -246,6 +248,10 @@ Global
246248
{58321699-3715-4CA7-8036-A9F26E4C93F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
247249
{58321699-3715-4CA7-8036-A9F26E4C93F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
248250
{58321699-3715-4CA7-8036-A9F26E4C93F3}.Release|Any CPU.Build.0 = Release|Any CPU
251+
{923B1463-910F-4542-8E68-29F36A9DB508}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
252+
{923B1463-910F-4542-8E68-29F36A9DB508}.Debug|Any CPU.Build.0 = Debug|Any CPU
253+
{923B1463-910F-4542-8E68-29F36A9DB508}.Release|Any CPU.ActiveCfg = Release|Any CPU
254+
{923B1463-910F-4542-8E68-29F36A9DB508}.Release|Any CPU.Build.0 = Release|Any CPU
249255
EndGlobalSection
250256
GlobalSection(SolutionProperties) = preSolution
251257
HideSolutionNode = FALSE
@@ -284,6 +290,7 @@ Global
284290
{D0127B5A-E66B-4DA2-8C57-A8BA2A0163F4} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
285291
{189376C9-49DA-4A12-9C78-CE39E8EC7731} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
286292
{58321699-3715-4CA7-8036-A9F26E4C93F3} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
293+
{923B1463-910F-4542-8E68-29F36A9DB508} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
287294
EndGlobalSection
288295
GlobalSection(ExtensibilityGlobals) = postSolution
289296
SolutionGuid = {8184BE59-ACBC-4CD1-9419-D59A0FAC6131}

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "6.0.402"
3+
"version": "7.0.100"
44
}
55
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"registry": "https://registry.bower.io",
3+
"directory": "wwwroot/lib"
4+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System.Diagnostics;
2+
using System.Threading.Tasks;
3+
4+
using Microsoft.AspNetCore.Hosting;
5+
using Microsoft.AspNetCore.Html;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.Extensions.Configuration;
8+
9+
using JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Models;
10+
using JavaScriptEngineSwitcher.Sample.Logic.Models;
11+
using JavaScriptEngineSwitcher.Sample.Logic.Services;
12+
13+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Controllers
14+
{
15+
public class HomeController : Controller
16+
{
17+
private readonly FileContentService _fileContentService;
18+
private readonly JsEvaluationService _jsEvaluationService;
19+
20+
21+
public HomeController(
22+
IConfigurationRoot configuration,
23+
IWebHostEnvironment hostingEnvironment,
24+
JsEvaluationService jsEvaluationService)
25+
{
26+
string textContentDirectoryPath = configuration
27+
.GetSection("jsengineswitcher")
28+
.GetSection("Samples")["TextContentDirectoryPath"]
29+
;
30+
31+
_fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
32+
_jsEvaluationService = jsEvaluationService;
33+
}
34+
35+
36+
[ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
37+
public IActionResult Index()
38+
{
39+
ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
40+
41+
return View();
42+
}
43+
44+
[HttpGet]
45+
[ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
46+
public IActionResult Demo()
47+
{
48+
var model = _jsEvaluationService.GetInitializationData();
49+
50+
return View(model);
51+
}
52+
53+
[HttpPost]
54+
public async Task<IActionResult> Demo(JsEvaluationViewModel editedModel)
55+
{
56+
var model = _jsEvaluationService.GetInitializationData();
57+
await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
58+
59+
if (ModelState.IsValid)
60+
{
61+
model = _jsEvaluationService.Evaluate(model);
62+
63+
ModelState.Clear();
64+
}
65+
66+
return View(model);
67+
}
68+
69+
[ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
70+
public IActionResult Contact()
71+
{
72+
ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
73+
74+
return View();
75+
}
76+
77+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
78+
public IActionResult Error()
79+
{
80+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
81+
}
82+
}
83+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Text.RegularExpressions;
2+
3+
using Microsoft.AspNetCore.Html;
4+
using Microsoft.AspNetCore.Mvc.Rendering;
5+
6+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Infrastructure.Helpers
7+
{
8+
public static class CommonExtensions
9+
{
10+
public static HtmlString EncodedReplace(this IHtmlHelper htmlHelper, string input,
11+
string pattern, string replacement)
12+
{
13+
return new HtmlString(Regex.Replace(htmlHelper.Encode(input), pattern, replacement));
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
3+
using Microsoft.AspNetCore.Razor.TagHelpers;
4+
5+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Infrastructure.TagHelpers
6+
{
7+
[HtmlTargetElement("conditional-comment")]
8+
public class ConditionalCommentTagHelper : TagHelper
9+
{
10+
[HtmlAttributeName("type")]
11+
public ConditionalCommentType CommentType { get; set; }
12+
13+
[HtmlAttributeName("expression")]
14+
public string Expression { get; set; }
15+
16+
17+
public override void Process(TagHelperContext context, TagHelperOutput output)
18+
{
19+
output.TagName = null;
20+
21+
ConditionalCommentType type = CommentType;
22+
23+
string ifCommentStartPart;
24+
string ifCommentEndPart;
25+
26+
switch (type)
27+
{
28+
case ConditionalCommentType.Hidden:
29+
ifCommentStartPart = "<!--[if ";
30+
ifCommentEndPart = "]>";
31+
32+
break;
33+
case ConditionalCommentType.RevealedValidating:
34+
ifCommentStartPart = "<!--[if ";
35+
ifCommentEndPart = "]><!-->";
36+
37+
break;
38+
case ConditionalCommentType.RevealedValidatingSimplified:
39+
ifCommentStartPart = "<!--[if ";
40+
ifCommentEndPart = "]>-->";
41+
42+
break;
43+
case ConditionalCommentType.Revealed:
44+
ifCommentStartPart = "<![if ";
45+
ifCommentEndPart = "]>";
46+
47+
break;
48+
default:
49+
throw new NotSupportedException();
50+
}
51+
52+
TagHelperContent preContent = output.PreContent;
53+
preContent.AppendHtml(ifCommentStartPart);
54+
preContent.AppendHtml(Expression);
55+
preContent.AppendHtml(ifCommentEndPart);
56+
57+
string endIfComment;
58+
59+
switch (type)
60+
{
61+
case ConditionalCommentType.Hidden:
62+
endIfComment = "<![endif]-->";
63+
break;
64+
case ConditionalCommentType.RevealedValidating:
65+
case ConditionalCommentType.RevealedValidatingSimplified:
66+
endIfComment = "<!--<![endif]-->";
67+
break;
68+
case ConditionalCommentType.Revealed:
69+
endIfComment = "<![endif]>";
70+
break;
71+
default:
72+
throw new NotSupportedException();
73+
}
74+
75+
output.PostContent.AppendHtml(endIfComment);
76+
}
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Infrastructure.TagHelpers
2+
{
3+
public enum ConditionalCommentType
4+
{
5+
Hidden,
6+
Revealed,
7+
RevealedValidating,
8+
RevealedValidatingSimplified
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<Product>JS Engine Switcher: Sample ASP.NET Core 7.0 MVC 7 Site</Product>
5+
<VersionPrefix>3.20.5</VersionPrefix>
6+
<TargetFramework>net7.0</TargetFramework>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<OutputType>Exe</OutputType>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<PreserveCompilationContext>true</PreserveCompilationContext>
11+
<IsPackable>false</IsPackable>
12+
</PropertyGroup>
13+
14+
<Import Project="../../build/common.props" />
15+
16+
<ItemGroup>
17+
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64" Version="3.20.5" />
18+
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64" Version="3.20.5" />
19+
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-arm" Version="3.20.5" />
20+
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64" Version="3.20.5" />
21+
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.20.5" />
22+
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x86" Version="3.20.5" />
23+
<PackageReference Include="Microsoft.ClearScript.V8.Native.linux-arm" Version="7.3.4" />
24+
<PackageReference Include="Microsoft.ClearScript.V8.Native.linux-arm64" Version="7.3.4" />
25+
<PackageReference Include="Microsoft.ClearScript.V8.Native.linux-x64" Version="7.3.4" />
26+
<PackageReference Include="Microsoft.ClearScript.V8.Native.osx-arm64" Version="7.3.4" />
27+
<PackageReference Include="Microsoft.ClearScript.V8.Native.osx-x64" Version="7.3.4" />
28+
<PackageReference Include="Microsoft.ClearScript.V8.Native.win-arm64" Version="7.3.4" />
29+
<PackageReference Include="Microsoft.ClearScript.V8.Native.win-x64" Version="7.3.4" />
30+
<PackageReference Include="Microsoft.ClearScript.V8.Native.win-x86" Version="7.3.4" />
31+
32+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.ChakraCore/JavaScriptEngineSwitcher.ChakraCore.csproj" />
33+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection.csproj" />
34+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj" />
35+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.Jurassic/JavaScriptEngineSwitcher.Jurassic.csproj" />
36+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.Msie/JavaScriptEngineSwitcher.Msie.csproj" />
37+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.NiL/JavaScriptEngineSwitcher.NiL.csproj" />
38+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.Node/JavaScriptEngineSwitcher.Node.csproj" />
39+
<ProjectReference Include="../JavaScriptEngineSwitcher.Sample.Logic/JavaScriptEngineSwitcher.Sample.Logic.csproj" />
40+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj" />
41+
<ProjectReference Include="../../src/JavaScriptEngineSwitcher.Vroom/JavaScriptEngineSwitcher.Vroom.csproj" />
42+
</ItemGroup>
43+
44+
<Target Name="NodePackageInstallation" BeforeTargets="BeforeBuild;BeforeClean">
45+
<Exec Command="npm install" ConsoleToMsBuild="true" />
46+
</Target>
47+
<Target Name="BowerPackagesInstallation" AfterTargets="AfterBuild">
48+
<Exec Command="bower install" ConsoleToMsBuild="true" />
49+
</Target>
50+
<Target Name="GulpClean" AfterTargets="AfterClean">
51+
<Exec Command="gulp cleanBuildedAssets" ConsoleToMsBuild="true" />
52+
</Target>
53+
<Target Name="GulpBuild" AfterTargets="BowerPackagesInstallation">
54+
<Exec Command="gulp buildAssets" ConsoleToMsBuild="true" />
55+
</Target>
56+
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
57+
<Exec Command="npm install" />
58+
<Exec Command="bower install" />
59+
<Exec Command="gulp" />
60+
</Target>
61+
62+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}

0 commit comments

Comments
 (0)