Add SerializeField private field support
This commit is contained in:
@@ -8,24 +8,70 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace XCEngine::Scripting;
|
||||
|
||||
namespace {
|
||||
|
||||
std::filesystem::path GetExecutableDirectory() {
|
||||
#ifdef _WIN32
|
||||
std::wstring buffer(MAX_PATH, L'\0');
|
||||
const DWORD length = GetModuleFileNameW(nullptr, buffer.data(), static_cast<DWORD>(buffer.size()));
|
||||
if (length == 0 || length >= buffer.size()) {
|
||||
return std::filesystem::current_path();
|
||||
}
|
||||
|
||||
buffer.resize(length);
|
||||
return std::filesystem::path(buffer).parent_path();
|
||||
#else
|
||||
return std::filesystem::current_path();
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path ResolveProjectManagedOutputDirectory() {
|
||||
constexpr const char* configuredDirectory = XCENGINE_TEST_PROJECT_MANAGED_OUTPUT_DIR;
|
||||
if (configuredDirectory[0] != '\0') {
|
||||
return std::filesystem::path(configuredDirectory);
|
||||
}
|
||||
|
||||
return (GetExecutableDirectory() / ".." / ".." / "managed" / "ProjectScriptAssemblies").lexically_normal();
|
||||
}
|
||||
|
||||
std::filesystem::path ResolveProjectScriptCoreDllPath() {
|
||||
constexpr const char* configuredPath = XCENGINE_TEST_PROJECT_SCRIPT_CORE_DLL;
|
||||
if (configuredPath[0] != '\0') {
|
||||
return std::filesystem::path(configuredPath);
|
||||
}
|
||||
|
||||
return ResolveProjectManagedOutputDirectory() / "XCEngine.ScriptCore.dll";
|
||||
}
|
||||
|
||||
std::filesystem::path ResolveProjectGameScriptsDllPath() {
|
||||
constexpr const char* configuredPath = XCENGINE_TEST_PROJECT_GAME_SCRIPTS_DLL;
|
||||
if (configuredPath[0] != '\0') {
|
||||
return std::filesystem::path(configuredPath);
|
||||
}
|
||||
|
||||
return ResolveProjectManagedOutputDirectory() / "GameScripts.dll";
|
||||
}
|
||||
|
||||
MonoScriptRuntime::Settings CreateProjectMonoSettings() {
|
||||
MonoScriptRuntime::Settings settings;
|
||||
settings.assemblyDirectory = XCENGINE_TEST_PROJECT_MANAGED_OUTPUT_DIR;
|
||||
settings.corlibDirectory = XCENGINE_TEST_PROJECT_MANAGED_OUTPUT_DIR;
|
||||
settings.coreAssemblyPath = XCENGINE_TEST_PROJECT_SCRIPT_CORE_DLL;
|
||||
settings.appAssemblyPath = XCENGINE_TEST_PROJECT_GAME_SCRIPTS_DLL;
|
||||
settings.assemblyDirectory = ResolveProjectManagedOutputDirectory();
|
||||
settings.corlibDirectory = settings.assemblyDirectory;
|
||||
settings.coreAssemblyPath = ResolveProjectScriptCoreDllPath();
|
||||
settings.appAssemblyPath = ResolveProjectGameScriptsDllPath();
|
||||
return settings;
|
||||
}
|
||||
|
||||
class ProjectScriptAssemblyTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ASSERT_TRUE(std::filesystem::exists(XCENGINE_TEST_PROJECT_SCRIPT_CORE_DLL));
|
||||
ASSERT_TRUE(std::filesystem::exists(XCENGINE_TEST_PROJECT_GAME_SCRIPTS_DLL));
|
||||
ASSERT_TRUE(std::filesystem::exists(ResolveProjectScriptCoreDllPath()));
|
||||
ASSERT_TRUE(std::filesystem::exists(ResolveProjectGameScriptsDllPath()));
|
||||
|
||||
runtime = std::make_unique<MonoScriptRuntime>(CreateProjectMonoSettings());
|
||||
ASSERT_TRUE(runtime->Initialize()) << runtime->GetLastError();
|
||||
@@ -36,8 +82,8 @@ protected:
|
||||
|
||||
TEST_F(ProjectScriptAssemblyTest, InitializesFromProjectScriptAssemblyDirectory) {
|
||||
EXPECT_TRUE(runtime->IsInitialized());
|
||||
EXPECT_EQ(runtime->GetSettings().assemblyDirectory, std::filesystem::path(XCENGINE_TEST_PROJECT_MANAGED_OUTPUT_DIR));
|
||||
EXPECT_EQ(runtime->GetSettings().appAssemblyPath, std::filesystem::path(XCENGINE_TEST_PROJECT_GAME_SCRIPTS_DLL));
|
||||
EXPECT_EQ(runtime->GetSettings().assemblyDirectory, ResolveProjectManagedOutputDirectory());
|
||||
EXPECT_EQ(runtime->GetSettings().appAssemblyPath, ResolveProjectGameScriptsDllPath());
|
||||
}
|
||||
|
||||
TEST_F(ProjectScriptAssemblyTest, DiscoversProjectAssetMonoBehaviourClassesAndFieldMetadata) {
|
||||
|
||||
Reference in New Issue
Block a user