Slight refractor

- Bumped unit tests to .NET 8
This commit is contained in:
Tony Bark 2025-02-18 08:17:56 -05:00
parent 3e3958c67f
commit e7184729df
19 changed files with 617 additions and 614 deletions

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
@ -9,14 +9,15 @@
<RootNamespace>SimAntics.Tests</RootNamespace> <RootNamespace>SimAntics.Tests</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.1"> <PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View file

@ -1,7 +1,8 @@
using System.Diagnostics; using System.Diagnostics;
using SimAI;
using Xunit; using Xunit;
namespace SimAI.Tests; namespace SimAntics.Tests;
public class VMClockTest public class VMClockTest
{ {

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI; namespace SimAntics;
public enum Direction public enum Direction
{ {

View file

@ -1,8 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
using SimAI;
namespace SimAntics.Engine.Entities; namespace SimAntics.Engine.Entities;
public class VMEntityRTTI public class VMEntityRTTI

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI.Engine; namespace SimAntics.Engine;
public class VMMemory public class VMMemory
{ {

View file

@ -3,7 +3,7 @@
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
using SimAntics.Engine.Entities; using SimAntics.Engine.Entities;
namespace SimAI.Engine; namespace SimAntics.Engine;
public class VMScheduler public class VMScheduler
{ {

View file

@ -3,14 +3,15 @@
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
using SimAntics.Engine.Entities; using SimAntics.Engine.Entities;
using SimAntics.Marshals;
namespace SimAI.Engine; namespace SimAntics.Engine;
/// <summary> /// <summary>
/// Holds information about the execution of a routine /// Holds information about the execution of a routine
/// </summary> /// </summary>
public class VMStackFrame public class VMStackFrame
{ {
public VMStackFrame() { } public VMStackFrame() { }
/** Thread executing this routine **/ /** Thread executing this routine **/

View file

@ -5,9 +5,7 @@
#define IDE_COMPAT #define IDE_COMPAT
#endif #endif
using SimAntics.Engine.Entities; namespace SimAntics.Engine;
namespace SimAI.Engine;
/// <summary> /// <summary>
/// Compatibility class /// Compatibility class

View file

@ -1,2 +1,3 @@
global using SimAI.Engine; global using SimAntics.Engine;
global using SimAI.Marshals; global using SimAntics.Marshals;
global using SimAntics.Engine.Entities;

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI; namespace SimAntics;
public interface IVM public interface IVM
{ {

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI.Interfaces; namespace SimAntics.Interfaces;
public interface VMIMotiveDecay : VMSerializable public interface VMIMotiveDecay : VMSerializable
{ {

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI.Interfaces; namespace SimAntics.Interfaces;
public interface VMSerializable public interface VMSerializable
{ {

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI.Marshals; namespace SimAntics.Marshals;
public class VMMarshal public class VMMarshal
{ {

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI.Marshals; namespace SimAntics.Marshals;
public class VMStackFrameMarshal public class VMStackFrameMarshal
{ {
@ -56,7 +56,7 @@ public class VMStackFrameMarshal
writer.Write(Callee); writer.Write(Callee);
writer.Write(StackObject); writer.Write(StackObject);
writer.Write(CodeOwnerGUID); writer.Write(CodeOwnerGUID);
writer.Write((Locals == null) ? -1 : Locals.Length); writer.Write(Locals == null ? -1 : Locals.Length);
//if (Locals != null) writer.Write(VMSerializableUtils.ToByteArray(Locals)); //if (Locals != null) writer.Write(VMSerializableUtils.ToByteArray(Locals));
//writer.Write((Args == null) ? -1 : Args.Length); //writer.Write((Args == null) ? -1 : Args.Length);
//if (Args != null) writer.Write(VMSerializableUtils.ToByteArray(Args)); //if (Args != null) writer.Write(VMSerializableUtils.ToByteArray(Args));

View file

@ -1,9 +1,11 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
using SimAI;
using SimAntics.Engine;
using SimAntics.Engine.Entities; using SimAntics.Engine.Entities;
namespace SimAI; namespace SimAntics;
/// <summary> /// <summary>
/// VM is an abstract class that contains the /// VM is an abstract class that contains the
@ -130,7 +132,7 @@ public abstract class VM : IVM
if (Entities.Contains(entity)) if (Entities.Contains(entity))
{ {
// Context.ObjectQueries.RemoveObject(entity); // Context.ObjectQueries.RemoveObject(entity);
this.Entities.Remove(entity); Entities.Remove(entity);
ObjectsById.Remove(entity.ObjectID); ObjectsById.Remove(entity.ObjectID);
// Scheduler.DescheduleTick(entity); // Scheduler.DescheduleTick(entity);
if (entity.ObjectID < ObjectId) ObjectId = entity.ObjectID; //this id is now the smallest free object id. if (entity.ObjectID < ObjectId) ObjectId = entity.ObjectID; //this id is now the smallest free object id.

View file

@ -2,7 +2,7 @@
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI; namespace SimAntics;
public class VMClock public class VMClock
{ {
@ -19,7 +19,7 @@ public class VMClock
public int FirePercent { get; set; } public int FirePercent { get; set; }
public long UTCStart = DateTime.UtcNow.Ticks; public long UTCStart = DateTime.UtcNow.Ticks;
public int TimeOfDay => (Hours >= 6 && Hours < 18) ? 0 : 1; public int TimeOfDay => Hours >= 6 && Hours < 18 ? 0 : 1;
public int Seconds => MinuteFractions * 60 / TicksPerMinute; public int Seconds => MinuteFractions * 60 / TicksPerMinute;
public DateTime UTCNow => new DateTime(UTCStart).AddSeconds(Ticks / 30.0); public DateTime UTCNow => new DateTime(UTCStart).AddSeconds(Ticks / 30.0);

View file

@ -1,7 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
namespace SimAI; namespace SimAntics;
public class VMContext public class VMContext
{ {

View file

@ -2,8 +2,9 @@
// If a copy of the MPL was not distributed with this file, You can obtain one at // If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/. // http://mozilla.org/MPL/2.0/.
using System.Text; using System.Text;
using SimAntics.Engine;
namespace SimAI; namespace SimAntics;
public class VMSimanticsException : Exception public class VMSimanticsException : Exception
{ {