Skip to content

Commit

Permalink
Updated dependencies and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishamm committed Feb 14, 2024
1 parent 2fecc1c commit 03ddf8f
Show file tree
Hide file tree
Showing 22 changed files with 1,047 additions and 1,044 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ To ensure flawless operation of the most critical components, Duet Software Fram
## Known incompatibilities

- G-Code checksums and M998 are not supported
- `exists()` may be used in meta G-code expressions only for fields that are managed by RRF

## Reporting issues

Expand Down
7 changes: 0 additions & 7 deletions src/Documentation/Documentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,4 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="docfx.console" Version="2.59.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/DuetAPI/DuetAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="6.0.8" />
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class EvaluateExpression : DuetAPI.Commands.EvaluateExpression
}

// Attempt to evaluate the expression internally and pass it on to RRF otherwise
return await Model.Expressions.EvaluateExpressionRaw(new Code() { Channel = Channel }, Expression, false, false);
return await Model.Expressions.EvaluateExpressionRaw(new Code() { Channel = Channel }, Expression, false);
}
}
}
4 changes: 2 additions & 2 deletions src/DuetControlServer/DuetControlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

<ItemGroup>
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="NLog" Version="5.2.5" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageReference Include="System.Threading.Channels" Version="6.0.0" />
</ItemGroup>

Expand Down
26 changes: 12 additions & 14 deletions src/DuetControlServer/Model/Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,15 @@ public static bool IsSbcExpression(string expression, bool isFunction)
/// </summary>
private static readonly object _nullResult = new();

// Encode a string
private static string encodeString(string value)
{
return '"' + value.Replace("\"", "\"\"").Replace("'", "''") + '"';
}

// Convert an object to a string value
#warning This function cannot output empty arrays yet

Check warning on line 382 in src/DuetControlServer/Model/Expressions.cs

View workflow job for this annotation

GitHub Actions / build

#warning: 'This function cannot output empty arrays yet'

Check warning on line 382 in src/DuetControlServer/Model/Expressions.cs

View workflow job for this annotation

GitHub Actions / build

#warning: 'This function cannot output empty arrays yet'
private static string objectToString(object? obj, bool wantsCount, bool encodeStrings, Code code)
private static string ObjectToString(object? obj, bool wantsCount, bool encodeStrings, Code code)
{
static string encodeString(string value)
{
return '"' + value.Replace("\"", "\"\"").Replace("'", "''") + '"';
}

if (obj is null)
{
return "null";
Expand Down Expand Up @@ -462,7 +461,7 @@ private static string objectToString(object? obj, bool wantsCount, bool encodeSt
}
if (obj is object[] objectArray)
{
return '{' + string.Join(',', objectArray.Select(objectValue => objectToString(objectValue, false, true, code))) + (objectArray.Length == 1 ? ",}" : "}");
return '{' + string.Join(',', objectArray.Select(objectValue => ObjectToString(objectValue, false, true, code))) + (objectArray.Length == 1 ? ",}" : "}");
}
if (!wantsCount && obj is IList)
{
Expand All @@ -481,10 +480,9 @@ private static string objectToString(object? obj, bool wantsCount, bool encodeSt
/// <param name="code">Code holding the expression(s)</param>
/// <param name="expression">Expression(s) to replace</param>
/// <param name="onlySbcFields">Whether to replace only SBC fields</param>
/// <param name="encodeResult">Whether the final result shall be encoded</param>
/// <returns>Replaced expression(s)</returns>
/// <exception cref="CodeParserException">Failed to parse expression(s)</exception>
public static async Task<object?> EvaluateExpressionRaw(Code code, string expression, bool onlySbcFields, bool encodeResult)
public static async Task<object?> EvaluateExpressionRaw(Code code, string expression, bool onlySbcFields)
{
int i = 0;

Expand Down Expand Up @@ -576,7 +574,7 @@ async Task appendToken(StringBuilder result, StringBuilder lastToken)
{
if (Filter.GetSpecific(filterString, true, out object? sbcField))
{
string subResult = objectToString(sbcField, wantsCount, true, code);
string subResult = ObjectToString(sbcField, wantsCount, true, code);
result.Append(subResult);
}
else
Expand Down Expand Up @@ -753,7 +751,7 @@ async Task<string> eatExpression(char brace, bool raw = false)
}
fnResult = await fn!(code.Channel, functionName, arguments.ToArray());
}
result.Append(objectToString(fnResult, wantsCount, true, code));
result.Append(ObjectToString(fnResult, wantsCount, true, code));
}
else
{
Expand Down Expand Up @@ -875,8 +873,8 @@ async Task<string> eatExpression(char brace, bool raw = false)
/// <exception cref="CodeParserException">Failed to parse expression(s)</exception>
public static async Task<string> EvaluateExpression(Code code, string expression, bool onlySbcFields, bool encodeResult)
{
object? result = await EvaluateExpressionRaw(code, expression, onlySbcFields, encodeResult);
return (onlySbcFields && result is string resultString) ? resultString : objectToString(result, false, encodeResult, code);
object? result = await EvaluateExpressionRaw(code, expression, onlySbcFields);
return (onlySbcFields && result is string resultString) ? resultString : ObjectToString(result, false, encodeResult, code);
}
}
}
2 changes: 1 addition & 1 deletion src/DuetPluginService/DuetPluginService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="NLog" Version="5.2.5" />
<PackageReference Include="NLog" Version="5.2.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 03ddf8f

Please sign in to comment.