Skip to content

Commit 4ab59a2

Browse files
authored
Updates
2 parents 066b92c + 728926b commit 4ab59a2

File tree

21 files changed

+2632
-2643
lines changed

21 files changed

+2632
-2643
lines changed

GS2Engine.TestApp/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
1+
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
22
WORKDIR /app
33

4-
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
4+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
55
WORKDIR /src
66
COPY ["GS2Engine.TestApp/GS2Engine.TestApp.csproj", "GS2Engine.TestApp/"]
77
RUN dotnet restore "GS2Engine.TestApp/GS2Engine.TestApp.csproj"

GS2Engine.UnitTests/GS2Engine.UnitTests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
13-
<PackageReference Include="xunit" Version="2.5.0" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
13+
<PackageReference Include="xunit" Version="2.7.1" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
<PrivateAssets>all</PrivateAssets>
1717
</PackageReference>
18-
<PackageReference Include="coverlet.collector" Version="6.0.0">
18+
<PackageReference Include="coverlet.collector" Version="6.0.2">
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
<PrivateAssets>all</PrivateAssets>
2121
</PackageReference>

GS2Engine/Enums/StackEntryType.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
namespace GS2Engine.Enums
1+
namespace GS2Engine.Enums;
2+
3+
public enum StackEntryType
24
{
3-
public enum StackEntryType
4-
{
5-
Number,
6-
String,
7-
Variable,
8-
Boolean,
9-
Array,
10-
ArrayStart,
11-
Player,
12-
Function,
13-
}
5+
Number,
6+
String,
7+
Variable,
8+
Boolean,
9+
Array,
10+
ArrayStart,
11+
Player,
12+
Function,
13+
Script,
1414
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using System;
22

3-
namespace GS2Engine.Exceptions
3+
namespace GS2Engine.Exceptions;
4+
5+
public class ScriptException : Exception
46
{
5-
public class ScriptException : Exception
7+
public ScriptException(string message) : base(message)
68
{
7-
public ScriptException(string message) : base(message)
8-
{
9-
}
109
}
1110
}
Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,87 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using GS2Engine.Enums;
55
using GS2Engine.GS2.Script;
66
using GS2Engine.Models;
77

8-
namespace GS2Engine.Extensions
8+
namespace GS2Engine.Extensions;
9+
10+
public static class StackEntryExtensions
911
{
10-
public static class StackEntryExtensions
11-
{
12-
public static StackEntry ToStackEntry(this object? stackObject, bool isVariable = false) =>
13-
new(isVariable ? StackEntryType.Variable : GetStackEntryType(stackObject), FixStackValue(stackObject));
12+
public static StackEntry ToStackEntry(this object? stackObject, bool isVariable = false) =>
13+
new(isVariable ? StackEntryType.Variable : GetStackEntryType(stackObject), FixStackValue(stackObject));
1414

15-
private static object? FixStackValue(object? stackObject)
15+
private static object? FixStackValue(object? stackObject)
16+
{
17+
return stackObject switch
1618
{
17-
return stackObject switch
18-
{
19-
string => (TString)stackObject.ToString(),
20-
TString => stackObject,
21-
int i => (double)i,
22-
double d => d,
23-
float f => (double)f,
24-
decimal o => (double)o,
25-
bool b => b,
26-
_ => stackObject,
27-
};
28-
}
19+
string => (TString)stackObject.ToString(),
20+
TString => stackObject,
21+
int i => (double)i,
22+
double d => d,
23+
float f => (double)f,
24+
decimal o => (double)o,
25+
bool b => b,
26+
_ => stackObject,
27+
};
28+
}
2929

30-
private static StackEntryType GetStackEntryType(object? stackObject)
30+
private static StackEntryType GetStackEntryType(object? stackObject)
31+
{
32+
switch (Type.GetTypeCode(stackObject?.GetType()))
3133
{
32-
switch (Type.GetTypeCode(stackObject?.GetType()))
34+
case TypeCode.Boolean:
35+
return StackEntryType.Boolean;
36+
case TypeCode.Byte:
37+
case TypeCode.Char:
38+
case TypeCode.Decimal:
39+
case TypeCode.Double:
40+
case TypeCode.Int16:
41+
case TypeCode.Int32:
42+
case TypeCode.Int64:
43+
case TypeCode.UInt16:
44+
case TypeCode.UInt32:
45+
case TypeCode.UInt64:
46+
case TypeCode.SByte:
47+
return StackEntryType.Number;
48+
case TypeCode.String:
49+
case TypeCode.DateTime:
50+
return StackEntryType.String;
51+
default:
3352
{
34-
case TypeCode.Boolean:
35-
return StackEntryType.Boolean;
36-
case TypeCode.Byte:
37-
case TypeCode.Char:
38-
case TypeCode.Decimal:
39-
case TypeCode.Double:
40-
case TypeCode.Int16:
41-
case TypeCode.Int32:
42-
case TypeCode.Int64:
43-
case TypeCode.UInt16:
44-
case TypeCode.UInt32:
45-
case TypeCode.UInt64:
46-
case TypeCode.SByte:
47-
return StackEntryType.Number;
48-
case TypeCode.String:
49-
case TypeCode.DateTime:
53+
var stackType = stackObject?.GetType();
54+
if (stackType == typeof(TString))
5055
return StackEntryType.String;
51-
default:
52-
{
53-
Type? stackType = stackObject?.GetType();
54-
if (stackType == typeof(TString))
55-
return StackEntryType.String;
5656

57-
if (stackType == typeof(Script.Command))
58-
return StackEntryType.Function;
57+
if (stackType == typeof(Script.Command))
58+
return StackEntryType.Function;
59+
60+
if (stackType == typeof(Script))
61+
return StackEntryType.Script;
5962

60-
if (stackType != null && stackType.GetInterfaces()
61-
.Any(x => x.Name.Equals("IGuiControl", StringComparison.CurrentCultureIgnoreCase)))
62-
return StackEntryType.Array;
63+
if (stackType != null && stackType.GetInterfaces()
64+
.Any(x => x.Name.Equals("IGuiControl", StringComparison.CurrentCultureIgnoreCase)))
65+
return StackEntryType.Array;
6366

64-
if (stackType == typeof(VariableCollection))
65-
return StackEntryType.Array;
67+
if (stackType == typeof(VariableCollection))
68+
return StackEntryType.Array;
6669

67-
if (stackObject is float)
68-
return StackEntryType.Number;
70+
if (stackObject is float)
71+
return StackEntryType.Number;
6972

70-
if (stackType is { IsGenericType: true } &&
71-
stackType.GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))
72-
return StackEntryType.Array;
73+
if (stackType is { IsGenericType: true } &&
74+
stackType.GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))
75+
return StackEntryType.Array;
7376

74-
throw new ArgumentOutOfRangeException();
75-
}
77+
throw new ArgumentOutOfRangeException();
7678
}
7779
}
80+
}
7881

79-
public static IStackEntry ToStackEntry(this IEnumerable<string> stackObject) =>
80-
new StackEntry(StackEntryType.Array, stackObject.ToList());
82+
public static IStackEntry ToStackEntry(this IEnumerable<string> stackObject) =>
83+
new StackEntry(StackEntryType.Array, stackObject.ToList());
8184

82-
public static IStackEntry ToStackEntry(this IEnumerable<int> stackObject) =>
83-
new StackEntry(StackEntryType.Array, stackObject.ToList());
84-
}
85+
public static IStackEntry ToStackEntry(this IEnumerable<int> stackObject) =>
86+
new StackEntry(StackEntryType.Array, stackObject.ToList());
8587
}

GS2Engine/Extensions/StackExtensions.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
using System.Diagnostics.Contracts;
33
using System.Linq;
44

5-
namespace GS2Engine.Extensions
5+
namespace GS2Engine.Extensions;
6+
7+
public static class StackExtensions
68
{
7-
public static class StackExtensions
9+
public static Stack<T> Clone<T>(this Stack<T> stack)
810
{
9-
public static Stack<T> Clone<T>(this Stack<T> stack)
10-
{
11-
Contract.Requires(stack != null);
12-
return new(stack.Reverse());
13-
}
11+
Contract.Requires(stack != null);
12+
return new(stack.Reverse());
1413
}
1514
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
namespace GS2Engine.GS2.ByteCode
1+
namespace GS2Engine.GS2.ByteCode;
2+
3+
public enum BytecodeSegment
24
{
3-
public enum BytecodeSegment
4-
{
5-
Gs1EventFlags = 1,
6-
FunctionNames = 2,
7-
Strings = 3,
8-
Bytecode = 4,
9-
}
5+
Gs1EventFlags = 1,
6+
FunctionNames = 2,
7+
Strings = 3,
8+
Bytecode = 4,
109
}

0 commit comments

Comments
 (0)