diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..51285f3 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,8 @@ + + + $(DefineConstants);DEBUG;GHOST_EDITOR;MHP_ENABLE_SAFETY_CHECKS; + + + $(DefineConstants);GHOST_EDITOR;MHP_ENABLE_SAFETY_CHECKS; + + \ No newline at end of file diff --git a/src/Editor/Ghost.DSL/Ghost.DSL.csproj b/src/Editor/Ghost.DSL/Ghost.DSL.csproj index f06620a..ae3188d 100644 --- a/src/Editor/Ghost.DSL/Ghost.DSL.csproj +++ b/src/Editor/Ghost.DSL/Ghost.DSL.csproj @@ -4,6 +4,7 @@ net10.0 enable enable + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj b/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj index 7f88d42..19c8eb3 100644 --- a/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj +++ b/src/Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj @@ -10,8 +10,7 @@ 10.0.20348.0 enable True - - preview + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/Editor/Ghost.Editor/Ghost.Editor.csproj b/src/Editor/Ghost.Editor/Ghost.Editor.csproj index a56aed0..2be0766 100644 --- a/src/Editor/Ghost.Editor/Ghost.Editor.csproj +++ b/src/Editor/Ghost.Editor/Ghost.Editor.csproj @@ -8,8 +8,7 @@ win-$(Platform).pubxml true true - - preview + Debug;Release;Debug_Editor;Release_Editor @@ -217,15 +216,18 @@ - False + False True - True enable 10.0.20348.0 app.manifest - False - False Ghost.Editor enable + + True + + + True + diff --git a/src/GhostEngine.slnx b/src/GhostEngine.slnx index 87d5a1b..8f9d121 100644 --- a/src/GhostEngine.slnx +++ b/src/GhostEngine.slnx @@ -1,5 +1,9 @@ + + + + @@ -9,12 +13,18 @@ - + + + + - + + + + @@ -45,12 +55,13 @@ - + - + + diff --git a/src/Runtime/Ghost.Core/Ghost.Core.csproj b/src/Runtime/Ghost.Core/Ghost.Core.csproj index 6a2d072..41ec652 100644 --- a/src/Runtime/Ghost.Core/Ghost.Core.csproj +++ b/src/Runtime/Ghost.Core/Ghost.Core.csproj @@ -5,15 +5,7 @@ enable enable True - - - - $(DefineConstants);MHP_ENABLE_SAFETY_CHECKS;MHP_ENABLE_MIMALLOC;MHP_FASTMATH - True - True - - - + Debug;Release;Debug_Editor;Release_Editor $(DefineConstants);MHP_ENABLE_MIMALLOC;MHP_FASTMATH True True diff --git a/src/Runtime/Ghost.Core/TemJobAllocator.cs b/src/Runtime/Ghost.Core/TemJobAllocator.cs index b6a25ac..2115785 100644 --- a/src/Runtime/Ghost.Core/TemJobAllocator.cs +++ b/src/Runtime/Ghost.Core/TemJobAllocator.cs @@ -123,22 +123,19 @@ public unsafe partial struct TempJobAllocator : IAllocator #endif } - public int AdvanceFrame() + public void AdvanceFrame() { - var allocations = Interlocked.Exchange(ref _allocationsPerFrame[_currentFrameIndex], 0); - _currentFrameCount++; _currentFrameIndex = _currentFrameCount % _FRAME_LATENCY; (_pArena + _currentFrameIndex)->Reset(); #if MHP_ENABLE_SAFETY_CHECKS - if (_allocationsPerFrame[_currentFrameIndex] != 0) + var allocations = Interlocked.Exchange(ref _allocationsPerFrame[_currentFrameIndex], 0); + if (allocations != 0) { - Logger.Error($"TempJobAllocator: Detected {_allocationsPerFrame[_currentFrameIndex]} leaked allocations from frame {_currentFrameCount - _FRAME_LATENCY}."); + Logger.Error($"TempJobAllocator: Detected {allocations} leaked allocations from frame {_currentFrameCount - _FRAME_LATENCY}."); } #endif - - return allocations; } } \ No newline at end of file diff --git a/src/Runtime/Ghost.Engine/Ghost.Engine.csproj b/src/Runtime/Ghost.Engine/Ghost.Engine.csproj index 7f068e1..73c3a1e 100644 --- a/src/Runtime/Ghost.Engine/Ghost.Engine.csproj +++ b/src/Runtime/Ghost.Engine/Ghost.Engine.csproj @@ -5,14 +5,7 @@ enable enable True - - - - True - True - - - + Debug;Release;Debug_Editor;Release_Editor True True diff --git a/src/Runtime/Ghost.Entities/Ghost.Entities.csproj b/src/Runtime/Ghost.Entities/Ghost.Entities.csproj index e5b22b5..9f9ceb6 100644 --- a/src/Runtime/Ghost.Entities/Ghost.Entities.csproj +++ b/src/Runtime/Ghost.Entities/Ghost.Entities.csproj @@ -5,6 +5,7 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/Runtime/Ghost.Generator/AssetHandlerRegistrationGenerator.cs b/src/Runtime/Ghost.Generator/AssetHandlerRegistrationGenerator.cs index 001d29d..b8e9c42 100644 --- a/src/Runtime/Ghost.Generator/AssetHandlerRegistrationGenerator.cs +++ b/src/Runtime/Ghost.Generator/AssetHandlerRegistrationGenerator.cs @@ -86,15 +86,18 @@ internal class AssetHandlerRegistrationGenerator : IIncrementalGenerator var registerTypeName = "g_assethandler_registeration"; var code = $@"// +#if GHOST_EDITOR [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] internal static partial class {registerTypeName} {{ + [global::System.Runtime.CompilerServices.ModuleInitializer] internal static void RegisterAssetHandlers() {{ {sb} }} -}}"; +}} +#endif"; context.AddSource($"{registerTypeName}.gen.cs", code); } @@ -156,6 +159,7 @@ internal class IAssetSettingsRegistrationGenerator : IIncrementalGenerator var registerTypeName = "g_iassetsettings_registeration"; var code = $@"// +#if GHOST_EDITOR [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] internal static partial class {registerTypeName} {{ @@ -164,7 +168,8 @@ internal static partial class {registerTypeName} {{ {sb} }} -}}"; +}} +#endif"; context.AddSource($"{registerTypeName}.gen.cs", code); } diff --git a/src/Runtime/Ghost.Generator/Ghost.Generator.csproj b/src/Runtime/Ghost.Generator/Ghost.Generator.csproj index 1813c5d..89a65fa 100644 --- a/src/Runtime/Ghost.Generator/Ghost.Generator.csproj +++ b/src/Runtime/Ghost.Generator/Ghost.Generator.csproj @@ -4,6 +4,7 @@ netstandard2.0 14.0 true + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/Runtime/Ghost.Generator/ShaderPropertiesGenerator.cs b/src/Runtime/Ghost.Generator/ShaderPropertiesGenerator.cs index dff39b5..f4d2323 100644 --- a/src/Runtime/Ghost.Generator/ShaderPropertiesGenerator.cs +++ b/src/Runtime/Ghost.Generator/ShaderPropertiesGenerator.cs @@ -176,7 +176,7 @@ namespace {info.TypeSymbol.ContainingNamespace.ToDisplayString()} [global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 4)] {info.TypeSymbol.DeclaredAccessibility.ToString().ToLower()} partial struct {info.TypeSymbol.Name} {{ -#if DEBUG || GHOST_EDITOR +#if GHOST_EDITOR public const string HLSL_SOURCE = @"" # ifndef {definedSymbol} # define {definedSymbol} @@ -199,17 +199,17 @@ struct {info.Name} var registerTypeName = "g_shaderproperty_registeration"; var registerCode = $@"// +#if GHOST_EDITOR [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] internal static partial class {registerTypeName} {{ -#if DEBUG || GHOST_EDITOR [global::System.Runtime.CompilerServices.ModuleInitializer] internal unsafe static void RegisterShaderProperties() {{ {registerBuilder} }} -#endif -}}"; +}} +#endif"; context.AddSource($"{registerTypeName}.gen.cs", registerCode); } diff --git a/src/Runtime/Ghost.Graphics.D3D12/Ghost.Graphics.D3D12.csproj b/src/Runtime/Ghost.Graphics.D3D12/Ghost.Graphics.D3D12.csproj index 9d7316f..ca71383 100644 --- a/src/Runtime/Ghost.Graphics.D3D12/Ghost.Graphics.D3D12.csproj +++ b/src/Runtime/Ghost.Graphics.D3D12/Ghost.Graphics.D3D12.csproj @@ -6,14 +6,9 @@ enable true true - - - - True - - - + Debug;Release;Debug_Editor;Release_Editor True + True diff --git a/src/Runtime/Ghost.Graphics.RHI/Ghost.Graphics.RHI.csproj b/src/Runtime/Ghost.Graphics.RHI/Ghost.Graphics.RHI.csproj index 6e00f76..a06e55b 100644 --- a/src/Runtime/Ghost.Graphics.RHI/Ghost.Graphics.RHI.csproj +++ b/src/Runtime/Ghost.Graphics.RHI/Ghost.Graphics.RHI.csproj @@ -5,14 +5,9 @@ enable enable True - - - - True - - - + Debug;Release;Debug_Editor;Release_Editor True + True diff --git a/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj b/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj index 5d4e2da..267929f 100644 --- a/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj +++ b/src/Runtime/Ghost.Graphics/Ghost.Graphics.csproj @@ -5,16 +5,17 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor + True + True embedded - True - - True - True + + embedded diff --git a/src/Test/Ghost.Entities.Test/EntityQueryTest.cs b/src/Test/Ghost.Entities.Test/EntityQueryTest.cs index ab4db53..6d29ca3 100644 --- a/src/Test/Ghost.Entities.Test/EntityQueryTest.cs +++ b/src/Test/Ghost.Entities.Test/EntityQueryTest.cs @@ -1,4 +1,4 @@ -using Ghost.Test.Core; +using Ghost.TestCore; using Misaki.HighPerformance.Jobs; using Misaki.HighPerformance.LowLevel.Buffer; using Misaki.HighPerformance.Mathematics; diff --git a/src/Test/Ghost.Entities.Test/Ghost.Entities.Test.csproj b/src/Test/Ghost.Entities.Test/Ghost.Entities.Test.csproj index 7221375..48dc116 100644 --- a/src/Test/Ghost.Entities.Test/Ghost.Entities.Test.csproj +++ b/src/Test/Ghost.Entities.Test/Ghost.Entities.Test.csproj @@ -6,6 +6,7 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor @@ -15,7 +16,7 @@ - + diff --git a/src/Test/Ghost.Entities.Test/SerializationTest.cs b/src/Test/Ghost.Entities.Test/SerializationTest.cs index 5fcd99e..36d29d8 100644 --- a/src/Test/Ghost.Entities.Test/SerializationTest.cs +++ b/src/Test/Ghost.Entities.Test/SerializationTest.cs @@ -1,4 +1,4 @@ -using Ghost.Test.Core; +using Ghost.TestCore; using Misaki.HighPerformance.LowLevel.Buffer; using Misaki.HighPerformance.Mathematics; using System.Runtime.InteropServices; diff --git a/src/Test/Ghost.Entities.Test/SystemTest.cs b/src/Test/Ghost.Entities.Test/SystemTest.cs index acd12c8..5ea974a 100644 --- a/src/Test/Ghost.Entities.Test/SystemTest.cs +++ b/src/Test/Ghost.Entities.Test/SystemTest.cs @@ -1,4 +1,4 @@ -using Ghost.Test.Core; +using Ghost.TestCore; namespace Ghost.Entities.Test; diff --git a/src/Test/Ghost.Graphics.Test/Ghost.Graphics.Test.csproj b/src/Test/Ghost.Graphics.Test/Ghost.Graphics.Test.csproj index eefd10e..8c075fb 100644 --- a/src/Test/Ghost.Graphics.Test/Ghost.Graphics.Test.csproj +++ b/src/Test/Ghost.Graphics.Test/Ghost.Graphics.Test.csproj @@ -11,6 +11,7 @@ true true enable + Debug;Release;Debug_Editor;Release_Editor @@ -50,7 +51,7 @@ - + @@ -68,6 +69,7 @@ False + False True 10.0.20348.0 enable @@ -76,10 +78,19 @@ embedded + + embedded + embedded + + embedded + embedded + + embedded + diff --git a/src/Test/Ghost.MicroTest/DXCBindingTest.cs b/src/Test/Ghost.MicroTest/DXCBindingTest.cs new file mode 100644 index 0000000..45409f0 --- /dev/null +++ b/src/Test/Ghost.MicroTest/DXCBindingTest.cs @@ -0,0 +1,171 @@ +using Ghost.DXC; +using Ghost.TestCore; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using static Ghost.DXC.UUID; + +namespace Ghost.MicroTest; + +internal unsafe class DXCBindingTest : ITest +{ + private static ReadOnlySpan ShaderCode => @" +struct VSInput +{ + float3 position : POSITION; + float3 normal : NORMAL; +}; + +struct PSInput +{ + float4 position : SV_POSITION; + float3 normal : NORMAL; +}; + +PSInput main(VSInput input) +{ + PSInput output; + output.position = float4(input.position, 1.0); + output.normal = input.normal; + return output; +}"u8; + + private IDxcCompiler3* _compiler; + private IDxcUtils* _utils; + + public void Setup() + { + IDxcCompiler3* pCompiler = default; + IDxcUtils* pUtils = default; + var hr = Api.DxcCreateInstance((Guid*)Unsafe.AsPointer(in Api.CLSID_DxcCompiler), __uuidof(pCompiler), (void**)&pCompiler); + if (hr < 0) + { + throw new InvalidOperationException($"Failed to create DXC compiler instance. HRESULT: 0x{hr:X8}"); + } + + hr = Api.DxcCreateInstance((Guid*)Unsafe.AsPointer(in Api.CLSID_DxcUtils), __uuidof(pUtils), (void**)&pUtils); + if (hr < 0) + { + pCompiler->Release(); + throw new InvalidOperationException($"Failed to create DXC utils instance. HRESULT: 0x{hr:X8}"); + } + + _compiler = pCompiler; + _utils = pUtils; + } + + private static List GetCompilerArguments() + { + return new List + { + "-T", "vs_6_6", // Target profile (vs_6_6 for vertex shader) + "-E", "main", // Entry point + "-HV", "2021", // HLSL version 2021 + "-enable-16bit-types" // Enable 16-bit types + }; + } + + public void Run() + { + IDxcIncludeHandler* includeHandler = default; + IDxcBlobEncoding* sourceBlob = default; + try + { + var hr = _utils->CreateDefaultIncludeHandler(&includeHandler); + Assert.AreEqual(0, hr, $"Failed to create default include handler. HRESULT: 0x{hr:X8}"); + + fixed (byte* pCode = ShaderCode) + { + hr = _utils->CreateBlobFromPinned(pCode, (uint)ShaderCode.Length, Api.DXC_CP_UTF8, &sourceBlob); + Assert.AreEqual(0, hr, $"Failed to create blob from shader code. HRESULT: 0x{hr:X8}"); + } + + var argsArray = GetCompilerArguments(); + var argPtrs = stackalloc char*[argsArray.Count]; + for (var i = 0; i < argsArray.Count; i++) + { + argPtrs[i] = (char*)Marshal.StringToHGlobalUni(argsArray[i]); + } + + IDxcResult* result = default; + IDxcBlob* bytecodeBlob = default; + + try + { + // Compile shader + var buffer = new DxcBuffer + { + Ptr = sourceBlob->GetBufferPointer(), + Size = sourceBlob->GetBufferSize(), + Encoding = Api.DXC_CP_UTF8 + }; + + hr = _compiler->Compile(&buffer, argPtrs, (uint)argsArray.Count, includeHandler, __uuidof(result), (void**)&result); + Assert.AreEqual(0, hr, $"Failed to compile shader. HRESULT: 0x{hr:X8}"); + + // Check compilation result + int hrStatus; + result->GetStatus(&hrStatus); + if (hrStatus < 0) + { + // Get error messages + IDxcBlobEncoding* pErrorBlob = default; + result->GetErrorBuffer(&pErrorBlob); + + if (pErrorBlob != null) + { + var errorMessage = Marshal.PtrToStringUTF8((IntPtr)pErrorBlob->GetBufferPointer()); + pErrorBlob->Release(); + + throw new InvalidOperationException($"DXC shader compilation failed:\n{errorMessage}"); + } + else + { + throw new InvalidOperationException("DXC shader compilation failed with unknown error."); + } + } + + // Get compiled bytecode + hr = result->GetResult(&bytecodeBlob); + Assert.AreEqual(0, hr, $"Failed to get compiled shader bytecode. HRESULT: 0x{hr:X8}"); + + var bytecodeSize = bytecodeBlob->GetBufferSize(); + Assert.IsTrue(bytecodeSize > 0, "Compiled shader bytecode is empty."); + } + finally + { + if (result != null) + { + result->Release(); + } + + if (bytecodeBlob != null) + { + bytecodeBlob->Release(); + } + + for (var i = 0; i < argsArray.Count; i++) + { + Marshal.FreeHGlobal((nint)argPtrs[i]); + } + } + } + finally + { + if (includeHandler != null) + { + includeHandler->Release(); + } + + if (sourceBlob != null) + { + sourceBlob->Release(); + } + } + } + + public void Cleanup() + { + _compiler->Release(); + _utils->Release(); + } +} diff --git a/src/Test/Ghost.MicroTest/Ghost.MicroTest.csproj b/src/Test/Ghost.MicroTest/Ghost.MicroTest.csproj index 49c01df..541a52e 100644 --- a/src/Test/Ghost.MicroTest/Ghost.MicroTest.csproj +++ b/src/Test/Ghost.MicroTest/Ghost.MicroTest.csproj @@ -7,6 +7,7 @@ enable true True + Debug;Release;Debug_Editor;Release_Editor @@ -15,7 +16,8 @@ - + + diff --git a/src/Test/Ghost.MicroTest/NvttBindingTest.cs b/src/Test/Ghost.MicroTest/NvttBindingTest.cs index 2622d92..69e159a 100644 --- a/src/Test/Ghost.MicroTest/NvttBindingTest.cs +++ b/src/Test/Ghost.MicroTest/NvttBindingTest.cs @@ -1,5 +1,5 @@ using Ghost.Nvtt; -using Ghost.Test.Core; +using Ghost.TestCore; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; diff --git a/src/Test/Ghost.MicroTest/Program.cs b/src/Test/Ghost.MicroTest/Program.cs index c1a3965..d3f817a 100644 --- a/src/Test/Ghost.MicroTest/Program.cs +++ b/src/Test/Ghost.MicroTest/Program.cs @@ -1,4 +1,4 @@ using Ghost.MicroTest; -using Ghost.Test.Core; +using Ghost.TestCore; -TestRunner.Run(); \ No newline at end of file +TestRunner.Run(); \ No newline at end of file diff --git a/src/Test/Ghost.MicroTest/StbIBindingTest.cs b/src/Test/Ghost.MicroTest/StbIBindingTest.cs index f0d1523..a928006 100644 --- a/src/Test/Ghost.MicroTest/StbIBindingTest.cs +++ b/src/Test/Ghost.MicroTest/StbIBindingTest.cs @@ -1,5 +1,5 @@ using Ghost.StbI; -using Ghost.Test.Core; +using Ghost.TestCore; namespace Ghost.MicroTest; diff --git a/src/Test/Ghost.MicroTest/UfbxBindingTest.cs b/src/Test/Ghost.MicroTest/UfbxBindingTest.cs index 29d9f43..d3ed0b1 100644 --- a/src/Test/Ghost.MicroTest/UfbxBindingTest.cs +++ b/src/Test/Ghost.MicroTest/UfbxBindingTest.cs @@ -1,4 +1,4 @@ -using Ghost.Test.Core; +using Ghost.TestCore; using Ghost.Ufbx; namespace Ghost.MicroTest; diff --git a/src/Test/Ghost.Shader.Test/Ghost.Shader.Test.csproj b/src/Test/Ghost.Shader.Test/Ghost.Shader.Test.csproj index f5a7f87..7484fd5 100644 --- a/src/Test/Ghost.Shader.Test/Ghost.Shader.Test.csproj +++ b/src/Test/Ghost.Shader.Test/Ghost.Shader.Test.csproj @@ -6,6 +6,7 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/Test/Ghost.Test.Core/TestRunner.cs b/src/Test/Ghost.Test.Core/TestRunner.cs deleted file mode 100644 index 9e5bebc..0000000 --- a/src/Test/Ghost.Test.Core/TestRunner.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ghost.Test.Core; - -public class TestRunner -{ - public static void Run() - where T : ITest, new() - { - var test = new T(); - test.Setup(); - test.Run(); - test.Cleanup(); - } - - public static void Run(int iteration) - where T : ITest, new() - { - var test = new T(); - test.Setup(); - - iteration = iteration < 1 ? 1 : iteration; - for (var i = 0; i < iteration; i++) - { - test.Run(); - } - - test.Cleanup(); - } -} \ No newline at end of file diff --git a/src/Test/Ghost.TestCore/Assert.cs b/src/Test/Ghost.TestCore/Assert.cs new file mode 100644 index 0000000..960e457 --- /dev/null +++ b/src/Test/Ghost.TestCore/Assert.cs @@ -0,0 +1,33 @@ +namespace Ghost.TestCore; + +public static class Assert +{ + public static void AreEqual(T expected, T actual, string message = "") + { + if (!EqualityComparer.Default.Equals(expected, actual)) + { + throw new AssertFailedException($"Assert.AreEqual failed. Expected: {expected}, Actual: {actual}. {message}"); + } + } + + public static void IsTrue(bool condition, string message = "") + { + if (!condition) + { + throw new AssertFailedException($"Assert.IsTrue failed. {message}"); + } + } + + public static void IsFalse(bool condition, string message = "") + { + if (condition) + { + throw new AssertFailedException($"Assert.IsFalse failed. {message}"); + } + } + + public static void Fail(string message = "") + { + throw new AssertFailedException($"Assert.Fail: {message}"); + } +} diff --git a/src/Test/Ghost.TestCore/AssertFailedException.cs b/src/Test/Ghost.TestCore/AssertFailedException.cs new file mode 100644 index 0000000..451c540 --- /dev/null +++ b/src/Test/Ghost.TestCore/AssertFailedException.cs @@ -0,0 +1,17 @@ +namespace Ghost.TestCore; + +[Serializable] +internal class AssertFailedException : Exception +{ + public AssertFailedException() + { + } + + public AssertFailedException(string? message) : base(message) + { + } + + public AssertFailedException(string? message, Exception? innerException) : base(message, innerException) + { + } +} \ No newline at end of file diff --git a/src/Test/Ghost.Test.Core/Ghost.Test.Core.csproj b/src/Test/Ghost.TestCore/Ghost.TestCore.csproj similarity index 72% rename from src/Test/Ghost.Test.Core/Ghost.Test.Core.csproj rename to src/Test/Ghost.TestCore/Ghost.TestCore.csproj index 9ed914b..4c9be6c 100644 --- a/src/Test/Ghost.Test.Core/Ghost.Test.Core.csproj +++ b/src/Test/Ghost.TestCore/Ghost.TestCore.csproj @@ -4,6 +4,7 @@ net10.0 enable enable + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/Test/Ghost.Test.Core/ITest.cs b/src/Test/Ghost.TestCore/ITest.cs similarity index 75% rename from src/Test/Ghost.Test.Core/ITest.cs rename to src/Test/Ghost.TestCore/ITest.cs index 60a0f9e..25f4bca 100644 --- a/src/Test/Ghost.Test.Core/ITest.cs +++ b/src/Test/Ghost.TestCore/ITest.cs @@ -1,4 +1,4 @@ -namespace Ghost.Test.Core; +namespace Ghost.TestCore; public interface ITest { diff --git a/src/Test/Ghost.TestCore/TestRunner.cs b/src/Test/Ghost.TestCore/TestRunner.cs new file mode 100644 index 0000000..d69b303 --- /dev/null +++ b/src/Test/Ghost.TestCore/TestRunner.cs @@ -0,0 +1,49 @@ +namespace Ghost.TestCore; + +public class TestRunner +{ + public static void Run() + where T : ITest, new() + { + var test = new T(); + + try + { + test.Setup(); + test.Run(); + test.Cleanup(); + } + catch (Exception ex) + { + Console.WriteLine($"Test failed with exception: {ex.Message}"); + } + + Console.WriteLine("Test completed."); + } + + public static void Run(int iteration) + where T : ITest, new() + { + var test = new T(); + var i = 0; + + try + { + test.Setup(); + + iteration = iteration < 1 ? 1 : iteration; + for (i = 0; i < iteration; i++) + { + test.Run(); + } + + test.Cleanup(); + } + catch (Exception ex) + { + Console.WriteLine($"Test failed at iteration {i} with exception: {ex.Message}"); + } + + Console.WriteLine($"Test completed after {iteration} iterations."); + } +} \ No newline at end of file diff --git a/src/Test/Ghost.UnitTest/AssetSystem/ImportCoordinatorTests.cs b/src/Test/Ghost.UnitTest/AssetSystem/ImportCoordinatorTests.cs index de0bab5..bba000a 100644 --- a/src/Test/Ghost.UnitTest/AssetSystem/ImportCoordinatorTests.cs +++ b/src/Test/Ghost.UnitTest/AssetSystem/ImportCoordinatorTests.cs @@ -46,7 +46,7 @@ public class ImportCoordinatorTests [TestMethod] public async Task TestImportCoordinator_BasicImport() { - using var catalog = new AssetCatalog(_dbPath); + var catalog = new AssetCatalog(_dbPath); using var coordinator = new ImportCoordinator(catalog); var assetGuid = Guid.NewGuid(); diff --git a/src/Test/Ghost.UnitTest/Ghost.UnitTest.csproj b/src/Test/Ghost.UnitTest/Ghost.UnitTest.csproj index 31f656a..decb949 100644 --- a/src/Test/Ghost.UnitTest/Ghost.UnitTest.csproj +++ b/src/Test/Ghost.UnitTest/Ghost.UnitTest.csproj @@ -8,6 +8,7 @@ x64;x86;ARM64 win-x86;win-x64;win-arm64 True + Debug;Release;Debug_Editor;Release_Editor diff --git a/src/ThridParty/Ghost.DXC/Ghost.DXC.csproj b/src/ThridParty/Ghost.DXC/Ghost.DXC.csproj index 938d41c..d2c9c1c 100644 --- a/src/ThridParty/Ghost.DXC/Ghost.DXC.csproj +++ b/src/ThridParty/Ghost.DXC/Ghost.DXC.csproj @@ -5,12 +5,17 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor True + + True + + True diff --git a/src/ThridParty/Ghost.FMOD/Ghost.FMOD.csproj b/src/ThridParty/Ghost.FMOD/Ghost.FMOD.csproj index cdb3e27..05499ce 100644 --- a/src/ThridParty/Ghost.FMOD/Ghost.FMOD.csproj +++ b/src/ThridParty/Ghost.FMOD/Ghost.FMOD.csproj @@ -4,12 +4,17 @@ net10.0 enable enable + Debug;Release;Debug_Editor;Release_Editor True + + True + + True diff --git a/src/ThridParty/Ghost.MeshOptimizer/Ghost.MeshOptimizer.csproj b/src/ThridParty/Ghost.MeshOptimizer/Ghost.MeshOptimizer.csproj index 22722a5..3d23682 100644 --- a/src/ThridParty/Ghost.MeshOptimizer/Ghost.MeshOptimizer.csproj +++ b/src/ThridParty/Ghost.MeshOptimizer/Ghost.MeshOptimizer.csproj @@ -5,12 +5,17 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor True + + True + + True diff --git a/src/ThridParty/Ghost.Nvtt/Ghost.Nvtt.csproj b/src/ThridParty/Ghost.Nvtt/Ghost.Nvtt.csproj index 0bfa179..cb9003f 100644 --- a/src/ThridParty/Ghost.Nvtt/Ghost.Nvtt.csproj +++ b/src/ThridParty/Ghost.Nvtt/Ghost.Nvtt.csproj @@ -5,12 +5,17 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor True + + True + + True diff --git a/src/ThridParty/Ghost.StbI/Ghost.StbI.csproj b/src/ThridParty/Ghost.StbI/Ghost.StbI.csproj index e1b2f6b..e1b7c35 100644 --- a/src/ThridParty/Ghost.StbI/Ghost.StbI.csproj +++ b/src/ThridParty/Ghost.StbI/Ghost.StbI.csproj @@ -5,12 +5,17 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor True + + True + + True diff --git a/src/ThridParty/Ghost.Ufbx/Ghost.Ufbx.csproj b/src/ThridParty/Ghost.Ufbx/Ghost.Ufbx.csproj index ea2e8a3..7ea49b2 100644 --- a/src/ThridParty/Ghost.Ufbx/Ghost.Ufbx.csproj +++ b/src/ThridParty/Ghost.Ufbx/Ghost.Ufbx.csproj @@ -5,12 +5,17 @@ enable enable True + Debug;Release;Debug_Editor;Release_Editor True + + True + + True diff --git a/src/Tools/Ghost.NativeWrapperGen/Ghost.NativeWrapperGen.csproj b/src/Tools/Ghost.NativeWrapperGen/Ghost.NativeWrapperGen.csproj index 3c5b9b6..f49661d 100644 --- a/src/Tools/Ghost.NativeWrapperGen/Ghost.NativeWrapperGen.csproj +++ b/src/Tools/Ghost.NativeWrapperGen/Ghost.NativeWrapperGen.csproj @@ -5,6 +5,7 @@ net10.0 enable enable + Debug;Release;Debug_Editor;Release_Editor