Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Jint 3.1.0 #95

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>AngleSharp.Js.Tests</RootNamespace>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net462;net472;net6.0;net7.0;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<IsPackable>false</IsPackable>
<LangVersion>7.1</LangVersion>
<AssemblyName>AngleSharp.Js.Tests</AssemblyName>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5 -->
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/AngleSharp.Js.Tests/Mocks/MockHttpClientRequester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MockHttpClientRequester(Dictionary<string, string> mockResponses) : base(
_mockResponses = mockResponses;
}

protected override async Task<IResponse> PerformRequestAsync(Request request, CancellationToken cancel)
protected override Task<IResponse> PerformRequestAsync(Request request, CancellationToken cancel)
{
var response = new DefaultResponse();

Expand All @@ -36,7 +36,7 @@ protected override async Task<IResponse> PerformRequestAsync(Request request, Ca
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty));
}

return response;
return Task.FromResult<IResponse>(response);
}
}
}
16 changes: 6 additions & 10 deletions src/AngleSharp.Js/AngleSharp.Js.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>AngleSharp.Js</AssemblyName>
<RootNamespace>AngleSharp.Js</RootNamespace>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard2.0;net462;net472;net6.0;net7.0;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
FlorianRappl marked this conversation as resolved.
Show resolved Hide resolved
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net472</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>7.1</LangVersion>
<RepositoryUrl>https://github.com/AngleSharp/AngleSharp.Js</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.1.0" />
<PackageReference Include="Jint" Version="3.0.1" />
<PackageReference Include="AngleSharp" Version="1.1.2" />
<PackageReference Include="Jint" Version="3.1.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
Expand Down
23 changes: 10 additions & 13 deletions src/AngleSharp.Js/Extensions/EngineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,18 @@ private static JsValue[] ExpandInitDict(JsValue[] arguments, ParameterInfo[] par
newArgs[i] = arguments[i];
}

if (obj != null)
for (var i = end + offset; i < max; i++)
{
for (var i = end + offset; i < max; i++)
{
var p = parameters[i];
var name = p.Name;
var p = parameters[i];
var name = p.Name;

if (obj.HasProperty(name))
{
newArgs[i - offset] = obj.GetProperty(name).Value;
}
else
{
newArgs[i - offset] = JsValue.Undefined;
}
if (obj.HasProperty(name))
{
newArgs[i - offset] = obj.Get(name);
}
else
{
newArgs[i - offset] = JsValue.Undefined;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/AngleSharp.Js/Proxies/DomNodeInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public override PropertyDescriptor GetOwnProperty(JsValue property)
{
return descriptor;
}
else if (prototype.HasProperty(property))

var prototypeProperty = prototype.GetOwnProperty(property);
if (prototypeProperty != PropertyDescriptor.Undefined)
{
return prototype.GetProperty(property);
return prototypeProperty;
}
}

Expand Down
24 changes: 9 additions & 15 deletions src/AngleSharp.Js/Proxies/DomPrototypeInstance.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace AngleSharp.Js
{
using AngleSharp.Attributes;
using AngleSharp.Dom;
using AngleSharp.Text;
using Jint.Native;
using Jint.Native.Object;
using Jint.Native.Symbol;
using Jint.Runtime.Descriptors;
Expand Down Expand Up @@ -55,7 +53,7 @@ public Boolean TryGetFromIndex(Object value, String index, out PropertyDescripto
{
if (ex.InnerException is ArgumentOutOfRangeException)
{
result = new PropertyDescriptor(JsValue.Undefined, false, false, false);
result = PropertyDescriptor.Undefined;
return true;
}

Expand Down Expand Up @@ -104,12 +102,9 @@ private void SetNormalEvents(IEnumerable<EventInfo> eventInfos)
{
foreach (var eventInfo in eventInfos)
{
var names = eventInfo.GetCustomAttributes<DomNameAttribute>()
.Select(m => m.OfficialName);

foreach (var name in names)
foreach (var m in eventInfo.GetCustomAttributes<DomNameAttribute>())
{
SetEvent(name, eventInfo.AddMethod, eventInfo.RemoveMethod);
SetEvent(m.OfficialName, eventInfo.AddMethod, eventInfo.RemoveMethod);
}
}
}
Expand All @@ -123,6 +118,7 @@ private void SetExtensionMethods(IEnumerable<MethodInfo> methods)

if (HasProperty(name))
{
// skip
}
else if (value.Adder != null && value.Remover != null)
{
Expand All @@ -148,9 +144,10 @@ private void SetNormalProperties(IEnumerable<PropertyInfo> properties)
var putsForward = property.GetCustomAttribute<DomPutForwardsAttribute>();
var names = property
.GetCustomAttributes<DomNameAttribute>()
.Select(m => m.OfficialName);
.Select(m => m.OfficialName)
.ToArray();

if (index != null || names.Any(m => m.Is("item")))
if (index != null || Array.Exists(names, m => m.Is("item")))
{
SetIndexer(property, indexParameters);
}
Expand All @@ -166,12 +163,9 @@ private void SetNormalMethods(IEnumerable<MethodInfo> methods)
{
foreach (var method in methods)
{
var names = method.GetCustomAttributes<DomNameAttribute>()
.Select(m => m.OfficialName);

foreach (var name in names)
foreach (var m in method.GetCustomAttributes<DomNameAttribute>())
{
SetMethod(name, method);
SetMethod(m.OfficialName, method);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Version>1.0.0</Version>
<LangVersion>latest</LangVersion>
<SignAssembly>true</SignAssembly>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
FlorianRappl marked this conversation as resolved.
Show resolved Hide resolved
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\Key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
</Project>
Loading