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">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
@ -9,14 +9,15 @@
<RootNamespace>SimAntics.Tests</RootNamespace>
</PropertyGroup>
<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.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</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>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

View file

@ -1,7 +1,8 @@
using System.Diagnostics;
using SimAI;
using Xunit;
namespace SimAI.Tests;
namespace SimAntics.Tests;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI;
namespace SimAntics;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
using SimAI;
namespace SimAntics.Engine.Entities;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI.Engine;
namespace SimAntics.Engine;
public class VMMemory
{

View file

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

View file

@ -3,8 +3,9 @@
// http://mozilla.org/MPL/2.0/.
using SimAntics.Engine.Entities;
using SimAntics.Marshals;
namespace SimAI.Engine;
namespace SimAntics.Engine;
/// <summary>
/// Holds information about the execution of a routine

View file

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

View file

@ -1,2 +1,3 @@
global using SimAI.Engine;
global using SimAI.Marshals;
global using SimAntics.Engine;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI;
namespace SimAntics;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI.Interfaces;
namespace SimAntics.Interfaces;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI.Interfaces;
namespace SimAntics.Interfaces;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI.Marshals;
namespace SimAntics.Marshals;
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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI.Marshals;
namespace SimAntics.Marshals;
public class VMStackFrameMarshal
{
@ -56,7 +56,7 @@ public class VMStackFrameMarshal
writer.Write(Callee);
writer.Write(StackObject);
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));
//writer.Write((Args == null) ? -1 : Args.Length);
//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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
using SimAI;
using SimAntics.Engine;
using SimAntics.Engine.Entities;
namespace SimAI;
namespace SimAntics;
/// <summary>
/// VM is an abstract class that contains the
@ -130,7 +132,7 @@ public abstract class VM : IVM
if (Entities.Contains(entity))
{
// Context.ObjectQueries.RemoveObject(entity);
this.Entities.Remove(entity);
Entities.Remove(entity);
ObjectsById.Remove(entity.ObjectID);
// Scheduler.DescheduleTick(entity);
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
// http://mozilla.org/MPL/2.0/.
namespace SimAI;
namespace SimAntics;
public class VMClock
{
@ -19,7 +19,7 @@ public class VMClock
public int FirePercent { get; set; }
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 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.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
namespace SimAI;
namespace SimAntics;
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
// http://mozilla.org/MPL/2.0/.
using System.Text;
using SimAntics.Engine;
namespace SimAI;
namespace SimAntics;
public class VMSimanticsException : Exception
{