Add Editor configs, refactor test core, DXC test
Added Debug_Editor/Release_Editor configs to all projects and solution. Refactored test utilities into Ghost.TestCore and updated references. Introduced DXCBindingTest for shader compilation. Updated conditional compilation to use GHOST_EDITOR. Improved platform mappings and performed minor code cleanup.
This commit is contained in:
8
src/Directory.Build.props
Normal file
8
src/Directory.Build.props
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<Project>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Debug_Editor'">
|
||||||
|
<DefineConstants>$(DefineConstants);DEBUG;GHOST_EDITOR;MHP_ENABLE_SAFETY_CHECKS;</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release_Editor'">
|
||||||
|
<DefineConstants>$(DefineConstants);GHOST_EDITOR;MHP_ENABLE_SAFETY_CHECKS;</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<!-- in .net 10, field keyword is not preview anymore, but we are still waiting roslyn team to update their code analyzer packages -->
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
<langversion>preview</langversion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="Assets\MeshNode.cs" />
|
<Content Remove="Assets\MeshNode.cs" />
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
|
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
|
||||||
<UseWinUI>true</UseWinUI>
|
<UseWinUI>true</UseWinUI>
|
||||||
<EnableMsixTooling>true</EnableMsixTooling>
|
<EnableMsixTooling>true</EnableMsixTooling>
|
||||||
<!-- in .net 10, field keyword is not preview anymore, but we are still waiting roslyn team to update their code analyzer packages -->
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
<langversion>preview</langversion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Views\Controls\Hierarchy.xaml" />
|
<None Remove="Views\Controls\Hierarchy.xaml" />
|
||||||
@@ -217,15 +216,18 @@
|
|||||||
|
|
||||||
<!-- Publish Properties -->
|
<!-- Publish Properties -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
<PublishReadyToRun Condition="'$(Configuration)'=='Debug_Editor'">False</PublishReadyToRun>
|
||||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||||
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<PublishAot>False</PublishAot>
|
|
||||||
<PublishTrimmed>False</PublishTrimmed>
|
|
||||||
<RootNamespace>Ghost.Editor</RootNamespace>
|
<RootNamespace>Ghost.Editor</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Editor|x64'">
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Editor|ARM64'">
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<Solution>
|
<Solution>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
|
<BuildType Name="Debug" />
|
||||||
|
<BuildType Name="Debug_Editor" />
|
||||||
|
<BuildType Name="Release" />
|
||||||
|
<BuildType Name="Release_Editor" />
|
||||||
<Platform Name="ARM64" />
|
<Platform Name="ARM64" />
|
||||||
<Platform Name="x64" />
|
<Platform Name="x64" />
|
||||||
<Platform Name="x86" />
|
<Platform Name="x86" />
|
||||||
@@ -9,12 +13,18 @@
|
|||||||
<Project Path="Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj">
|
<Project Path="Editor/Ghost.Editor.Core/Ghost.Editor.Core.csproj">
|
||||||
<Platform Solution="*|ARM64" Project="ARM64" />
|
<Platform Solution="*|ARM64" Project="ARM64" />
|
||||||
<Platform Solution="*|x64" Project="x64" />
|
<Platform Solution="*|x64" Project="x64" />
|
||||||
<Platform Solution="*|x86" Project="x86" />
|
<Platform Solution="Debug_Editor|x86" Project="x64" />
|
||||||
|
<Platform Solution="Debug|x86" Project="x86" />
|
||||||
|
<Platform Solution="Release_Editor|x86" Project="x64" />
|
||||||
|
<Platform Solution="Release|x86" Project="x86" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project Path="Editor/Ghost.Editor/Ghost.Editor.csproj">
|
<Project Path="Editor/Ghost.Editor/Ghost.Editor.csproj">
|
||||||
<Platform Solution="*|ARM64" Project="ARM64" />
|
<Platform Solution="*|ARM64" Project="ARM64" />
|
||||||
<Platform Solution="*|x64" Project="x64" />
|
<Platform Solution="*|x64" Project="x64" />
|
||||||
<Platform Solution="*|x86" Project="x86" />
|
<Platform Solution="Debug_Editor|x86" Project="x64" />
|
||||||
|
<Platform Solution="Debug|x86" Project="x86" />
|
||||||
|
<Platform Solution="Release_Editor|x86" Project="x64" />
|
||||||
|
<Platform Solution="Release|x86" Project="x86" />
|
||||||
<Deploy />
|
<Deploy />
|
||||||
</Project>
|
</Project>
|
||||||
</Folder>
|
</Folder>
|
||||||
@@ -45,12 +55,13 @@
|
|||||||
</Project>
|
</Project>
|
||||||
<Project Path="Test/Ghost.MicroTest/Ghost.MicroTest.csproj" Id="8c8ffa4b-e1e4-46a1-9221-7b508a109edd" />
|
<Project Path="Test/Ghost.MicroTest/Ghost.MicroTest.csproj" Id="8c8ffa4b-e1e4-46a1-9221-7b508a109edd" />
|
||||||
<Project Path="Test/Ghost.Shader.Test/Ghost.Shader.Test.csproj" />
|
<Project Path="Test/Ghost.Shader.Test/Ghost.Shader.Test.csproj" />
|
||||||
<Project Path="Test/Ghost.Test.Core/Ghost.Test.Core.csproj" />
|
<Project Path="Test/Ghost.TestCore/Ghost.TestCore.csproj" />
|
||||||
<Project Path="Test/Ghost.UnitTest/Ghost.UnitTest.csproj" Id="4da45668-456b-4dcc-acd8-6bfe154e6837">
|
<Project Path="Test/Ghost.UnitTest/Ghost.UnitTest.csproj" Id="4da45668-456b-4dcc-acd8-6bfe154e6837">
|
||||||
<Platform Solution="*|ARM64" Project="ARM64" />
|
<Platform Solution="*|ARM64" Project="ARM64" />
|
||||||
<Platform Solution="*|x64" Project="x64" />
|
<Platform Solution="*|x64" Project="x64" />
|
||||||
<Platform Solution="*|x86" Project="x86" />
|
<Platform Solution="*|x86" Project="x86" />
|
||||||
<Deploy />
|
<Deploy Solution="Debug|*" />
|
||||||
|
<Deploy Solution="Release|*" />
|
||||||
</Project>
|
</Project>
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Tools/">
|
<Folder Name="/Tools/">
|
||||||
|
|||||||
@@ -5,15 +5,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<DefineConstants>$(DefineConstants);MHP_ENABLE_SAFETY_CHECKS;MHP_ENABLE_MIMALLOC;MHP_FASTMATH</DefineConstants>
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
|
||||||
<IsTrimmable>True</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<DefineConstants>$(DefineConstants);MHP_ENABLE_MIMALLOC;MHP_FASTMATH</DefineConstants>
|
<DefineConstants>$(DefineConstants);MHP_ENABLE_MIMALLOC;MHP_FASTMATH</DefineConstants>
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
<IsTrimmable>True</IsTrimmable>
|
<IsTrimmable>True</IsTrimmable>
|
||||||
|
|||||||
@@ -123,22 +123,19 @@ public unsafe partial struct TempJobAllocator : IAllocator
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AdvanceFrame()
|
public void AdvanceFrame()
|
||||||
{
|
{
|
||||||
var allocations = Interlocked.Exchange(ref _allocationsPerFrame[_currentFrameIndex], 0);
|
|
||||||
|
|
||||||
_currentFrameCount++;
|
_currentFrameCount++;
|
||||||
_currentFrameIndex = _currentFrameCount % _FRAME_LATENCY;
|
_currentFrameIndex = _currentFrameCount % _FRAME_LATENCY;
|
||||||
|
|
||||||
(_pArena + _currentFrameIndex)->Reset();
|
(_pArena + _currentFrameIndex)->Reset();
|
||||||
|
|
||||||
#if MHP_ENABLE_SAFETY_CHECKS
|
#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
|
#endif
|
||||||
|
|
||||||
return allocations;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
|
||||||
<IsTrimmable>True</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
<IsTrimmable>True</IsTrimmable>
|
<IsTrimmable>True</IsTrimmable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
|||||||
@@ -86,15 +86,18 @@ internal class AssetHandlerRegistrationGenerator : IIncrementalGenerator
|
|||||||
var registerTypeName = "g_assethandler_registeration";
|
var registerTypeName = "g_assethandler_registeration";
|
||||||
var code = $@"// <auto-generated />
|
var code = $@"// <auto-generated />
|
||||||
|
|
||||||
|
#if GHOST_EDITOR
|
||||||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
internal static partial class {registerTypeName}
|
internal static partial class {registerTypeName}
|
||||||
{{
|
{{
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.ModuleInitializer]
|
[global::System.Runtime.CompilerServices.ModuleInitializer]
|
||||||
internal static void RegisterAssetHandlers()
|
internal static void RegisterAssetHandlers()
|
||||||
{{
|
{{
|
||||||
{sb}
|
{sb}
|
||||||
}}
|
}}
|
||||||
}}";
|
}}
|
||||||
|
#endif";
|
||||||
|
|
||||||
context.AddSource($"{registerTypeName}.gen.cs", code);
|
context.AddSource($"{registerTypeName}.gen.cs", code);
|
||||||
}
|
}
|
||||||
@@ -156,6 +159,7 @@ internal class IAssetSettingsRegistrationGenerator : IIncrementalGenerator
|
|||||||
var registerTypeName = "g_iassetsettings_registeration";
|
var registerTypeName = "g_iassetsettings_registeration";
|
||||||
var code = $@"// <auto-generated />
|
var code = $@"// <auto-generated />
|
||||||
|
|
||||||
|
#if GHOST_EDITOR
|
||||||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
internal static partial class {registerTypeName}
|
internal static partial class {registerTypeName}
|
||||||
{{
|
{{
|
||||||
@@ -164,7 +168,8 @@ internal static partial class {registerTypeName}
|
|||||||
{{
|
{{
|
||||||
{sb}
|
{sb}
|
||||||
}}
|
}}
|
||||||
}}";
|
}}
|
||||||
|
#endif";
|
||||||
|
|
||||||
context.AddSource($"{registerTypeName}.gen.cs", code);
|
context.AddSource($"{registerTypeName}.gen.cs", code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<LangVersion>14.0</LangVersion>
|
<LangVersion>14.0</LangVersion>
|
||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace {info.TypeSymbol.ContainingNamespace.ToDisplayString()}
|
|||||||
[global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 4)]
|
[global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 4)]
|
||||||
{info.TypeSymbol.DeclaredAccessibility.ToString().ToLower()} partial struct {info.TypeSymbol.Name}
|
{info.TypeSymbol.DeclaredAccessibility.ToString().ToLower()} partial struct {info.TypeSymbol.Name}
|
||||||
{{
|
{{
|
||||||
#if DEBUG || GHOST_EDITOR
|
#if GHOST_EDITOR
|
||||||
public const string HLSL_SOURCE = @""
|
public const string HLSL_SOURCE = @""
|
||||||
# ifndef {definedSymbol}
|
# ifndef {definedSymbol}
|
||||||
# define {definedSymbol}
|
# define {definedSymbol}
|
||||||
@@ -199,17 +199,17 @@ struct {info.Name}
|
|||||||
var registerTypeName = "g_shaderproperty_registeration";
|
var registerTypeName = "g_shaderproperty_registeration";
|
||||||
var registerCode = $@"// <auto-generated/>
|
var registerCode = $@"// <auto-generated/>
|
||||||
|
|
||||||
|
#if GHOST_EDITOR
|
||||||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
internal static partial class {registerTypeName}
|
internal static partial class {registerTypeName}
|
||||||
{{
|
{{
|
||||||
#if DEBUG || GHOST_EDITOR
|
|
||||||
[global::System.Runtime.CompilerServices.ModuleInitializer]
|
[global::System.Runtime.CompilerServices.ModuleInitializer]
|
||||||
internal unsafe static void RegisterShaderProperties()
|
internal unsafe static void RegisterShaderProperties()
|
||||||
{{
|
{{
|
||||||
{registerBuilder}
|
{registerBuilder}
|
||||||
}}
|
}}
|
||||||
#endif
|
}}
|
||||||
}}";
|
#endif";
|
||||||
|
|
||||||
context.AddSource($"{registerTypeName}.gen.cs", registerCode);
|
context.AddSource($"{registerTypeName}.gen.cs", registerCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,9 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<PublishAot>true</PublishAot>
|
<PublishAot>true</PublishAot>
|
||||||
</PropertyGroup>
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
<IsTrimmable>True</IsTrimmable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -5,14 +5,9 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
<IsTrimmable>True</IsTrimmable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -5,16 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
<IsTrimmable>True</IsTrimmable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<DebugType>embedded</DebugType>
|
||||||
<IsTrimmable>True</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
using Misaki.HighPerformance.Jobs;
|
using Misaki.HighPerformance.Jobs;
|
||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.Mathematics;
|
using Misaki.HighPerformance.Mathematics;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Runtime\Ghost.Entities\Ghost.Entities.csproj" />
|
<ProjectReference Include="..\..\Runtime\Ghost.Entities\Ghost.Entities.csproj" />
|
||||||
<ProjectReference Include="..\..\Test\Ghost.Test.Core\Ghost.Test.Core.csproj" />
|
<ProjectReference Include="..\..\Test\Ghost.TestCore\Ghost.TestCore.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.Mathematics;
|
using Misaki.HighPerformance.Mathematics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
|
|
||||||
namespace Ghost.Entities.Test;
|
namespace Ghost.Entities.Test;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<UseWinUI>true</UseWinUI>
|
<UseWinUI>true</UseWinUI>
|
||||||
<EnableMsixTooling>true</EnableMsixTooling>
|
<EnableMsixTooling>true</EnableMsixTooling>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Runtime\Ghost.Engine\Ghost.Engine.csproj" />
|
<ProjectReference Include="..\..\Runtime\Ghost.Engine\Ghost.Engine.csproj" />
|
||||||
<ProjectReference Include="..\..\Test\Ghost.Test.Core\Ghost.Test.Core.csproj" />
|
<ProjectReference Include="..\..\Test\Ghost.TestCore\Ghost.TestCore.csproj" />
|
||||||
<ProjectReference Include="..\..\Runtime\Ghost.Graphics\Ghost.Graphics.csproj" />
|
<ProjectReference Include="..\..\Runtime\Ghost.Graphics\Ghost.Graphics.csproj" />
|
||||||
<ProjectReference Include="..\..\Editor\Ghost.DSL\Ghost.DSL.csproj" />
|
<ProjectReference Include="..\..\Editor\Ghost.DSL\Ghost.DSL.csproj" />
|
||||||
<ProjectReference Include="..\..\ThridParty\Ghost.Ufbx\Ghost.Ufbx.csproj" />
|
<ProjectReference Include="..\..\ThridParty\Ghost.Ufbx\Ghost.Ufbx.csproj" />
|
||||||
@@ -68,6 +69,7 @@
|
|||||||
<!-- Publish Properties -->
|
<!-- Publish Properties -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||||
|
<PublishReadyToRun Condition="'$(Configuration)'=='Debug_Editor'">False</PublishReadyToRun>
|
||||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||||
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
@@ -76,10 +78,19 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|x86'">
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|x64'">
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|ARM64'">
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
171
src/Test/Ghost.MicroTest/DXCBindingTest.cs
Normal file
171
src/Test/Ghost.MicroTest/DXCBindingTest.cs
Normal file
@@ -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<byte> 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<string> GetCompilerArguments()
|
||||||
|
{
|
||||||
|
return new List<string>
|
||||||
|
{
|
||||||
|
"-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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<PublishAot>True</PublishAot>
|
<PublishAot>True</PublishAot>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -15,7 +16,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Runtime\Ghost.Core\Ghost.Core.csproj" />
|
<ProjectReference Include="..\..\Runtime\Ghost.Core\Ghost.Core.csproj" />
|
||||||
<ProjectReference Include="..\..\Test\Ghost.Test.Core\Ghost.Test.Core.csproj" />
|
<ProjectReference Include="..\Ghost.TestCore\Ghost.TestCore.csproj" />
|
||||||
|
<ProjectReference Include="..\..\ThridParty\Ghost.DXC\Ghost.DXC.csproj" />
|
||||||
<ProjectReference Include="..\..\ThridParty\Ghost.Nvtt\Ghost.Nvtt.csproj" />
|
<ProjectReference Include="..\..\ThridParty\Ghost.Nvtt\Ghost.Nvtt.csproj" />
|
||||||
<ProjectReference Include="..\..\ThridParty\Ghost.StbI\Ghost.StbI.csproj" />
|
<ProjectReference Include="..\..\ThridParty\Ghost.StbI\Ghost.StbI.csproj" />
|
||||||
<ProjectReference Include="..\..\ThridParty\Ghost.Ufbx\Ghost.Ufbx.csproj" />
|
<ProjectReference Include="..\..\ThridParty\Ghost.Ufbx\Ghost.Ufbx.csproj" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Ghost.Nvtt;
|
using Ghost.Nvtt;
|
||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Ghost.MicroTest;
|
using Ghost.MicroTest;
|
||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
|
|
||||||
TestRunner.Run<UfbxBindingTest>();
|
TestRunner.Run<DXCBindingTest>();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Ghost.StbI;
|
using Ghost.StbI;
|
||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
|
|
||||||
namespace Ghost.MicroTest;
|
namespace Ghost.MicroTest;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Ghost.Test.Core;
|
using Ghost.TestCore;
|
||||||
using Ghost.Ufbx;
|
using Ghost.Ufbx;
|
||||||
|
|
||||||
namespace Ghost.MicroTest;
|
namespace Ghost.MicroTest;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<PublishAot>True</PublishAot>
|
<PublishAot>True</PublishAot>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
namespace Ghost.Test.Core;
|
|
||||||
|
|
||||||
public class TestRunner
|
|
||||||
{
|
|
||||||
public static void Run<T>()
|
|
||||||
where T : ITest, new()
|
|
||||||
{
|
|
||||||
var test = new T();
|
|
||||||
test.Setup();
|
|
||||||
test.Run();
|
|
||||||
test.Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Run<T>(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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
33
src/Test/Ghost.TestCore/Assert.cs
Normal file
33
src/Test/Ghost.TestCore/Assert.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
namespace Ghost.TestCore;
|
||||||
|
|
||||||
|
public static class Assert
|
||||||
|
{
|
||||||
|
public static void AreEqual<T>(T expected, T actual, string message = "")
|
||||||
|
{
|
||||||
|
if (!EqualityComparer<T>.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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/Test/Ghost.TestCore/AssertFailedException.cs
Normal file
17
src/Test/Ghost.TestCore/AssertFailedException.cs
Normal file
@@ -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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Ghost.Test.Core;
|
namespace Ghost.TestCore;
|
||||||
|
|
||||||
public interface ITest
|
public interface ITest
|
||||||
{
|
{
|
||||||
49
src/Test/Ghost.TestCore/TestRunner.cs
Normal file
49
src/Test/Ghost.TestCore/TestRunner.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
namespace Ghost.TestCore;
|
||||||
|
|
||||||
|
public class TestRunner
|
||||||
|
{
|
||||||
|
public static void Run<T>()
|
||||||
|
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<T>(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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,7 +46,7 @@ public class ImportCoordinatorTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task TestImportCoordinator_BasicImport()
|
public async Task TestImportCoordinator_BasicImport()
|
||||||
{
|
{
|
||||||
using var catalog = new AssetCatalog(_dbPath);
|
var catalog = new AssetCatalog(_dbPath);
|
||||||
using var coordinator = new ImportCoordinator(catalog);
|
using var coordinator = new ImportCoordinator(catalog);
|
||||||
|
|
||||||
var assetGuid = Guid.NewGuid();
|
var assetGuid = Guid.NewGuid();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<Platforms>x64;x86;ARM64</Platforms>
|
<Platforms>x64;x86;ARM64</Platforms>
|
||||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -4,12 +4,17 @@
|
|||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Editor|AnyCPU'">
|
||||||
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<IsAotCompatible>True</IsAotCompatible>
|
<IsAotCompatible>True</IsAotCompatible>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Configurations>Debug;Release;Debug_Editor;Release_Editor</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user