Skip to content
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: 5 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
Expand All @@ -51,6 +55,7 @@ jobs:
context: .
file: src/WebPlayer/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/textadventures/quest-viva-webplayer:${{ env.VERSION }}
ghcr.io/textadventures/quest-viva-webplayer:latest
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Common.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<Nullable>enable</Nullable>
<LangVersion>default</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/EditorCore/EditorCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>QuestViva.EditorCore</RootNamespace>
<LangVersion>default</LangVersion>
Expand All @@ -12,6 +12,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions src/Engine/Engine.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>QuestViva.Engine</RootNamespace>
<LangVersion>default</LangVersion>
Expand All @@ -22,8 +22,7 @@
<ProjectReference Include="..\Utility\Utility.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="NCalcSync" Version="5.3.1" />
<PackageReference Include="NCalcSync" Version="5.11.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions src/Engine/Expressions/NcalcExpressionEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.Reflection;
using NCalc;
using NCalc.Cache;
using NCalc.Factories;
using NCalc.Handlers;
using NCalc.Services;
using QuestViva.Engine.Functions;
using QuestViva.Engine.Scripts;

Expand All @@ -26,7 +26,7 @@ public NcalcExpressionEvaluator(string expression, ScriptContext scriptContext)
new ExpressionContext(ExpressionOptions.NoStringTypeCoercion, null),
QuestNCalcExpressionFactory.GetInstance(),
LogicalExpressionCache.GetInstance(),
new EvaluationService());
new EvaluationVisitorFactory());

_nCalcExpression.EvaluateFunction += EvaluateFunction;
_nCalcExpression.EvaluateParameter += EvaluateParameter;
Expand All @@ -40,7 +40,7 @@ object IDynamicExpressionEvaluator.Evaluate(Context c)
public T Evaluate(Context c)
{
_context = c;
var result = _nCalcExpression.Evaluate();
var result = CoerceLong(_nCalcExpression.Evaluate());

// Converting ints to generic doubles is fun
if (typeof(T) == typeof(double) && result is int i)
Expand All @@ -51,6 +51,9 @@ public T Evaluate(Context c)
return (T)result;
}

// NCalc returns Int64 for integer literals; coerce to Int32 to match engine expectations.
private static object CoerceLong(object value) => value is long l ? (int)l : value;

private Context _context;

private void EvaluateParameter(string name, ParameterArgs args)
Expand Down Expand Up @@ -165,7 +168,7 @@ private static (bool handled, object? result) EvaluateFunctionFromType(Type type
return (false, null);
}

var evaluatedArgs = parameters.Select(p => p.Evaluate()).ToArray();
var evaluatedArgs = parameters.Select(p => CoerceLong(p.Evaluate())).ToArray();

// First, try to find a method with a params parameter.
var paramsMethods = methods
Expand Down
17 changes: 11 additions & 6 deletions src/Engine/Expressions/QuestNCalcExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#nullable enable
using System;
using System.Globalization;
using System.Threading;
using NCalc;
using NCalc.Domain;
using NCalc.Exceptions;
Expand All @@ -19,21 +21,24 @@ public static QuestNCalcExpressionFactory GetInstance()
return _instance ??= new QuestNCalcExpressionFactory();
}

public LogicalExpression Create(string expression, ExpressionOptions options = ExpressionOptions.None)
public LogicalExpression Create(string expression, ExpressionOptions options = ExpressionOptions.None,
CancellationToken ct = new())
{
try
{
var parserContext = new LogicalExpressionParserContext(expression, options);
var logicalExpression = QuestNCalcLogicalExpressionParser.Parse(parserContext);

if (logicalExpression is null)
throw new ArgumentNullException(nameof(logicalExpression));

return logicalExpression;

return logicalExpression ?? throw new ArgumentNullException(nameof(logicalExpression));
}
catch (Exception exception)
{
throw new NCalcParserException("Error parsing the expression.", exception);
}
}

public LogicalExpression Create(string expression, CultureInfo cultureInfo,
ExpressionOptions options = ExpressionOptions.None,
CancellationToken ct = new())
=> Create(expression, options, ct);
}
2 changes: 1 addition & 1 deletion src/Legacy/Legacy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<RootNamespace>QuestViva.Legacy</RootNamespace>
Expand Down
7 changes: 3 additions & 4 deletions src/PlayerCore/PlayerCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>QuestViva.PlayerCore</RootNamespace>
<LangVersion>default</LangVersion>
Expand Down Expand Up @@ -40,9 +40,8 @@
<EmbeddedResource Include="Resources\playercore.js" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.JSInterop" Version="9.0.1" />
<PackageReference Include="Microsoft.JSInterop" Version="10.0.3" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions src/Utility/Utility.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>QuestViva.Utility</RootNamespace>
<LangVersion>default</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions src/WasmPlayer/WasmPlayer.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>default</LangVersion>
<RootNamespace>QuestViva.WasmPlayer</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.3" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/WebPlayer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/WebPlayer/WebPlayer.csproj", "src/WebPlayer/"]
Expand Down
2 changes: 1 addition & 1 deletion src/WebPlayer/WebPlayer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>default</LangVersion>
Expand Down
9 changes: 6 additions & 3 deletions tests/EditorCoreTests/EditorCoreTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>

Expand All @@ -12,8 +12,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
</ItemGroup>
Expand Down
12 changes: 7 additions & 5 deletions tests/EngineTests/EngineTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>

Expand All @@ -13,8 +13,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
</ItemGroup>
Expand All @@ -38,9 +41,8 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions tests/LegacyTests/LegacyTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>

Expand All @@ -12,8 +12,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/PlayerCoreTests/PlayerCoreTests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>QuestViva.PlayerCoreTests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest" Version="3.7.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/UtilityTests/UtilityTests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>QuestViva.UtilityTests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest" Version="3.7.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down