Skip to content

Commit 3f2bcbf

Browse files
committed
In JavaScriptEngineSwitcher.Msie:
1. MSIE JavaScript Engine was updated to version 3.3.0; 2. Added support for .NET Standard 2.1 and .NET 10.
1 parent 82ce28a commit 3f2bcbf

File tree

12 files changed

+353
-5
lines changed

12 files changed

+353
-5
lines changed

src/JavaScriptEngineSwitcher.Msie/JavaScriptEngineSwitcher.Msie.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Product>JS Engine Switcher: MSIE</Product>
55
<VersionPrefix>3.24.1</VersionPrefix>
6-
<TargetFrameworks>net40-client;net45;netstandard1.3;netstandard2.0</TargetFrameworks>
6+
<TargetFrameworks>net40-client;net45;netstandard1.3;netstandard2.0;netstandard2.1;net10.0</TargetFrameworks>
77
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.3' ">1.6.0</NetStandardImplicitPackageVersion>
88
<OutputType>Library</OutputType>
99
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -23,11 +23,12 @@
2323
<PackageIconFullPath>../../Icons/JavaScriptEngineSwitcher_Msie_Logo128x128.png</PackageIconFullPath>
2424
<Description>JavaScriptEngineSwitcher.Msie contains a `MsieJsEngine` adapter (wrapper for the MSIE JavaScript Engine for .NET).</Description>
2525
<PackageTags>$(PackageCommonTags);MSIE;IE;Chakra</PackageTags>
26-
<PackageReleaseNotes>MSIE JavaScript Engine was updated to version 3.2.5.</PackageReleaseNotes>
26+
<PackageReleaseNotes>1. MSIE JavaScript Engine was updated to version 3.3.0;
27+
2. Added support for .NET Standard 2.1 and .NET 10.</PackageReleaseNotes>
2728
</PropertyGroup>
2829

2930
<ItemGroup>
30-
<PackageReference Include="MsieJavaScriptEngine" Version="3.2.5" />
31+
<PackageReference Include="MsieJavaScriptEngine" Version="3.3.0" />
3132
<PackageReference Include="ResxToCs.MSBuild" Version="1.0.0-alpha7" PrivateAssets="All" />
3233

3334
<ProjectReference Include="../JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj" />

src/JavaScriptEngineSwitcher.Msie/readme.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
--------------------------------------------------------------------------------
77

8-
Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
8+
Copyright (c) 2013-2026 Andrey Taritsyn - http://www.taritsyn.ru
99

1010

1111
===========
@@ -19,7 +19,8 @@
1919
=============
2020
RELEASE NOTES
2121
=============
22-
MSIE JavaScript Engine was updated to version 3.2.5.
22+
1. MSIE JavaScript Engine was updated to version 3.3.0;
23+
2. Added support for .NET Standard 2.1 and .NET 10.
2324

2425
=============
2526
DOCUMENTATION

test/JavaScriptEngineSwitcher.Tests/ChakraCore/InteropTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ private IJsEngine CreateJsEngine(bool allowReflection)
3232

3333
#region Embedding of objects
3434

35+
#region Objects with fields
36+
37+
[Fact]
38+
public override void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
39+
{ }
40+
41+
#endregion
42+
3543
#region Objects with methods
3644

3745
[Fact]
@@ -460,6 +468,14 @@ string TestAllowReflectionSetting(bool allowReflection)
460468

461469
#endregion
462470

471+
#region Types with fields
472+
473+
[Fact]
474+
public override void EmbeddingOfCustomReferenceTypeWithReadonlyFields()
475+
{ }
476+
477+
#endregion
478+
463479
#region Types with methods
464480

465481
[Fact]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
3+
namespace JavaScriptEngineSwitcher.Tests.Interop
4+
{
5+
public struct Age
6+
{
7+
public readonly int Year;
8+
9+
10+
public Age(int year)
11+
{
12+
Year = year;
13+
}
14+
15+
16+
public override string ToString()
17+
{
18+
int age = DateTime.Now.Year - Year;
19+
20+
return age.ToString();
21+
}
22+
}
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace JavaScriptEngineSwitcher.Tests.Interop
2+
{
3+
public static class RuntimeConstants
4+
{
5+
public static object SyncRoot = new object();
6+
7+
8+
public static readonly int MinValue = 0;
9+
public static readonly int MaxValue = 999;
10+
}
11+
}

test/JavaScriptEngineSwitcher.Tests/InteropTestsBase.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,31 @@ public virtual void EmbeddingOfInstanceOfCustomValueTypeWithFields()
5959
Assert.Equal(targetOutput3, output3);
6060
}
6161

62+
[Fact]
63+
public virtual void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
64+
{
65+
// Arrange
66+
var age = new Age(1979);
67+
const string updateCode = "age.Year = 1982;";
68+
69+
const string input = "age.Year";
70+
const int targetOutput = 1979;
71+
72+
// Act
73+
int output;
74+
75+
using (var jsEngine = CreateJsEngine())
76+
{
77+
jsEngine.EmbedHostObject("age", age);
78+
jsEngine.Execute(updateCode);
79+
80+
output = jsEngine.Evaluate<int>(input);
81+
}
82+
83+
// Assert
84+
Assert.Equal(targetOutput, output);
85+
}
86+
6287
[Fact]
6388
public virtual void EmbeddingOfInstanceOfCustomReferenceTypeWithFields()
6489
{
@@ -1174,6 +1199,47 @@ public virtual void EmbeddingOfCustomReferenceTypeWithField()
11741199
Assert.Equal(targetOutput, output);
11751200
}
11761201

1202+
[Fact]
1203+
public virtual void EmbeddingOfCustomReferenceTypeWithReadonlyFields()
1204+
{
1205+
// Arrange
1206+
Type runtimeConstantsType = typeof(RuntimeConstants);
1207+
const string updateCode = @"var oldMinValue = RuntimeConstants.MinValue;
1208+
var oldMaxValue = RuntimeConstants.MaxValue;
1209+
1210+
RuntimeConstants.MinValue = 1;
1211+
RuntimeConstants.MaxValue = 100;";
1212+
const string rollbackCode = @"RuntimeConstants.MinValue = oldMinValue;
1213+
RuntimeConstants.MaxValue = oldMaxValue;";
1214+
1215+
const string input1 = "RuntimeConstants.MinValue";
1216+
const int targetOutput1 = 0;
1217+
1218+
const string input2 = "RuntimeConstants.MaxValue";
1219+
const int targetOutput2 = 999;
1220+
1221+
// Act
1222+
int output1;
1223+
int output2;
1224+
1225+
using (var jsEngine = CreateJsEngine())
1226+
{
1227+
jsEngine.EmbedHostType("RuntimeConstants", runtimeConstantsType);
1228+
1229+
lock (RuntimeConstants.SyncRoot)
1230+
{
1231+
jsEngine.Execute(updateCode);
1232+
output1 = jsEngine.Evaluate<int>(input1);
1233+
output2 = jsEngine.Evaluate<int>(input2);
1234+
jsEngine.Execute(rollbackCode);
1235+
}
1236+
}
1237+
1238+
// Assert
1239+
Assert.Equal(targetOutput1, output1);
1240+
Assert.Equal(targetOutput2, output2);
1241+
}
1242+
11771243
#endregion
11781244

11791245
#region Types with properties

test/JavaScriptEngineSwitcher.Tests/Jint/InteropTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,35 @@ private IJsEngine CreateJsEngine(bool allowReflection)
3232

3333
#region Embedding of objects
3434

35+
#region Objects with fields
36+
37+
[Fact]
38+
public override void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
39+
{
40+
// Arrange
41+
var age = new Age(1979);
42+
const string updateCode = "age.Year = 1982;";
43+
44+
const string input = "age.Year";
45+
const int targetOutput = 1982;
46+
47+
// Act
48+
int output;
49+
50+
using (var jsEngine = CreateJsEngine())
51+
{
52+
jsEngine.EmbedHostObject("age", age);
53+
jsEngine.Execute(updateCode);
54+
55+
output = jsEngine.Evaluate<int>(input);
56+
}
57+
58+
// Assert
59+
Assert.Equal(targetOutput, output);
60+
}
61+
62+
#endregion
63+
3564
#region Objects with methods
3665

3766
[Fact]

test/JavaScriptEngineSwitcher.Tests/Jurassic/InteropTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
using Xunit;
44

5+
using JavaScriptEngineSwitcher.Tests.Interop;
6+
57
namespace JavaScriptEngineSwitcher.Tests.Jurassic
68
{
79
public class InteropTests : InteropTestsBase
@@ -13,6 +15,34 @@ protected override string EngineName
1315

1416
#region Embedding of objects
1517

18+
#region Objects with fields
19+
20+
public override void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
21+
{
22+
// Arrange
23+
var age = new Age(1979);
24+
const string updateCode = "age.Year = 1982;";
25+
26+
const string input = "age.Year";
27+
const int targetOutput = 1982;
28+
29+
// Act
30+
int output;
31+
32+
using (var jsEngine = CreateJsEngine())
33+
{
34+
jsEngine.EmbedHostObject("age", age);
35+
jsEngine.Execute(updateCode);
36+
37+
output = jsEngine.Evaluate<int>(input);
38+
}
39+
40+
// Assert
41+
Assert.Equal(targetOutput, output);
42+
}
43+
44+
#endregion
45+
1646
#region Objects with properties
1747

1848
public override void EmbeddingOfInstanceOfAnonymousTypeWithProperties()

test/JavaScriptEngineSwitcher.Tests/NiL/InteropTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@ protected override string EngineName
1919

2020
#region Embedding of objects
2121

22+
#region Objects with fields
23+
24+
[Fact]
25+
public override void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
26+
{
27+
// Arrange
28+
var age = new Age(1979);
29+
const string updateCode = "age.Year = 1982;";
30+
31+
const string input = "age.Year";
32+
const int targetOutput = 1982;
33+
34+
// Act
35+
int output;
36+
37+
using (var jsEngine = CreateJsEngine())
38+
{
39+
jsEngine.EmbedHostObject("age", age);
40+
jsEngine.Execute(updateCode);
41+
42+
output = jsEngine.Evaluate<int>(input);
43+
}
44+
45+
// Assert
46+
Assert.Equal(targetOutput, output);
47+
}
48+
49+
#endregion
50+
2251
#region Objects with methods
2352

2453
[Fact]

test/JavaScriptEngineSwitcher.Tests/V8/InteropTests.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,38 @@ private IJsEngine CreateJsEngine(bool allowReflection)
3131

3232
#region Embedding of objects
3333

34+
#region Objects with fields
35+
36+
public override void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
37+
{
38+
// Arrange
39+
var age = new Age(1979);
40+
const string updateCode = "age.Year = 1982;";
41+
42+
// Act
43+
JsRuntimeException exception = null;
44+
45+
using (var jsEngine = CreateJsEngine())
46+
{
47+
try
48+
{
49+
jsEngine.EmbedHostObject("age", age);
50+
jsEngine.Execute(updateCode);
51+
}
52+
catch (JsRuntimeException e)
53+
{
54+
exception = e;
55+
}
56+
}
57+
58+
// Assert
59+
Assert.NotNull(exception);
60+
Assert.Equal("Runtime error", exception.Category);
61+
Assert.Equal("The field is read-only", exception.Description);
62+
}
63+
64+
#endregion
65+
3466
#region Objects with methods
3567

3668
public override void EmbeddingOfInstanceOfCustomValueTypeAndCallingOfItsGetTypeMethod()
@@ -182,6 +214,43 @@ string TestAllowReflectionSetting(bool allowReflection)
182214

183215
#endregion
184216

217+
#region Types with fields
218+
219+
public override void EmbeddingOfCustomReferenceTypeWithReadonlyFields()
220+
{
221+
// Arrange
222+
Type runtimeConstantsType = typeof(RuntimeConstants);
223+
const string updateCode = @"RuntimeConstants.MinValue = 1;
224+
RuntimeConstants.MaxValue = 100;";
225+
226+
// Act
227+
JsRuntimeException exception = null;
228+
229+
using (var jsEngine = CreateJsEngine())
230+
{
231+
try
232+
{
233+
jsEngine.EmbedHostType("RuntimeConstants", runtimeConstantsType);
234+
235+
lock (RuntimeConstants.SyncRoot)
236+
{
237+
jsEngine.Execute(updateCode);
238+
}
239+
}
240+
catch (JsRuntimeException e)
241+
{
242+
exception = e;
243+
}
244+
}
245+
246+
// Assert
247+
Assert.NotNull(exception);
248+
Assert.Equal("Runtime error", exception.Category);
249+
Assert.Equal("The field is read-only", exception.Description);
250+
}
251+
252+
#endregion
253+
185254
#region Types with methods
186255

187256
public override void EmbeddingOfTypeAndCallingOfItsGetTypeMethod()

0 commit comments

Comments
 (0)