From 5a60d5266281de5b5f9ead3387e4d0b2b96b728d Mon Sep 17 00:00:00 2001 From: praydog Date: Sat, 25 May 2024 21:37:41 -0700 Subject: [PATCH] .NET: Add RE4 test script and easier way of adding test projects --- csharp-api/CMakeLists.txt | 218 +++++++++++++------------------- csharp-api/cmake.toml | 214 +++++++++---------------------- csharp-api/make_symlinks.py | 1 + csharp-api/test/Test/TestRE4.cs | 34 +++++ 4 files changed, 184 insertions(+), 283 deletions(-) create mode 100644 csharp-api/test/Test/TestRE4.cs diff --git a/csharp-api/CMakeLists.txt b/csharp-api/CMakeLists.txt index 8bcc8c223..2febd5527 100644 --- a/csharp-api/CMakeLists.txt +++ b/csharp-api/CMakeLists.txt @@ -71,48 +71,56 @@ if(NOT NUGET_PACKAGES_DIR) set(NUGET_PACKAGES_DIR ${DEFAULT_NUGET_PATH}) endif() -# Set a bool if the generated reference assemblies exist in the build/bin folder -set(dd2_systemdll "${CMAKE_BINARY_DIR}/bin/dd2/REFramework.NET._System.dll") -set(dd2_applicationdll "${CMAKE_BINARY_DIR}/bin/dd2/REFramework.NET.application.dll") -set(dd2_viacoredll "${CMAKE_BINARY_DIR}/bin/dd2/REFramework.NET.viacore.dll") - -set(re2_mscorlibdll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET._mscorlib.dll") -set(re2_systemdll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET._System.dll") -set(re2_systemcoredll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET._System.Core.dll") -set(re2_applicationdll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET.application.dll") -set(re2_viacoredll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET.viacore.dll") - -# Initialize a variable to keep track of the existence of all files -set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2 TRUE) -set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2 TRUE) - -# Check if each DLL exists -foreach(dll IN ITEMS ${dd2_systemdll} ${dd2_applicationdll} ${dd2_viacoredll}) - if(NOT EXISTS ${dll}) - set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2 FALSE) - break() # Exit the loop as soon as one file is not found - endif() -endforeach() +# Helper function for setting target properties with custom DLLs +function(set_dotnet_references TARGET DLL_PREFIX DLLS) + foreach(dll IN ITEMS ${DLLS}) + string(REPLACE "REFramework.NET." "" DLL_NAME ${dll}) + string(REPLACE ".dll" "" DLL_NAME ${DLL_NAME}) + set_target_properties(${TARGET} PROPERTIES + VS_DOTNET_REFERENCE_${DLL_NAME} + "${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}/REFramework.NET.${DLL_NAME}.dll" + ) + set_target_properties(${TARGET} PROPERTIES + VS_PACKAGE_REFERENCES "REFramework.NET.${DLL_NAME}" + ) + endforeach() + + set_target_properties(${TARGET} PROPERTIES + VS_DOTNET_REFERENCE_REFramework.NET + "${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" + ) +endfunction() + +# Helper function for checking custom DLL existence +function(check_dlls_exist DLL_PREFIX DLLS VAR_NAME) + message(STATUS "${VAR_NAME} Checking for DLLs in ${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}") + set(${VAR_NAME} TRUE PARENT_SCOPE) + foreach(dll IN ITEMS ${DLLS}) + if(NOT EXISTS "${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}/${dll}") + set(${VAR_NAME} FALSE) + message(STATUS "DLL ${dll} does not exist in ${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}") + break() + endif() + endforeach() -foreach(dll IN ITEMS ${re2_mscorlibdll} ${re2_systemdll} ${re2_systemcoredll} ${re2_applicationdll} ${re2_viacoredll}) - if(NOT EXISTS ${dll}) - set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2 FALSE) - break() # Exit the loop as soon as one file is not found + if (NOT ${${VAR_NAME}}) + message(STATUS "One or more specified DLLs do not exist (${DLL_PREFIX})") + else() + message(STATUS "All specified DLLs exist (${DLL_PREFIX})") endif() -endforeach() +endfunction() -# Use the result -if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2) - message(STATUS "All specified DLLs exist (DD2)") -else() - message(STATUS "One or more specified DLLs do not exist (DD2)") -endif() +# RE2 +set(RE2_DLLS "REFramework.NET._mscorlib.dll;REFramework.NET._System.dll;REFramework.NET._System.Core.dll;REFramework.NET.application.dll;REFramework.NET.viacore.dll") +check_dlls_exist("re2" "${RE2_DLLS}" "REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2") -if (REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2) - message(STATUS "All specified DLLs exist (RE2)") -else() - message(STATUS "One or more specified DLLs do not exist (RE2)") -endif() +# RE4 +set(RE4_DLLS "REFramework.NET._mscorlib.dll;REFramework.NET._System.dll;REFramework.NET._System.Core.dll;REFramework.NET.application.dll;REFramework.NET.viacore.dll") +check_dlls_exist("re4" "${RE4_DLLS}" "REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE4") + +# DD2 +set(DD2_DLLS "REFramework.NET._System.dll;REFramework.NET.application.dll;REFramework.NET.viacore.dll") +check_dlls_exist("dd2" "${DD2_DLLS}" "REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2") # Define a list of NuGet packages and their versions # the last part, the package framework will only be used for copying the files @@ -390,31 +398,7 @@ if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2) # build-csharp-test-dd2 ) set(CMKR_TARGET CSharpAPITest) - set_target_properties(CSharpAPITest PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET - "${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" - ) - -set_target_properties(CSharpAPITest PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET._System - "${dd2_systemdll}" - ) - -set_target_properties(CSharpAPITest PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._System") - -set_target_properties(CSharpAPITest PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.viacore - "${dd2_viacoredll}" - ) - -set_target_properties(CSharpAPITest PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.viacore") - -set_target_properties(CSharpAPITest PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.application - "${dd2_applicationdll}" - ) - -set_target_properties(CSharpAPITest PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.application") + set_dotnet_references(CSharpAPITest "dd2" "${DD2_DLLS}") endif() # Target: CSharpAPITestRE2 @@ -455,45 +439,48 @@ if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2) # build-csharp-test-re2 ) set(CMKR_TARGET CSharpAPITestRE2) - set_target_properties(CSharpAPITestRE2 PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET - "${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" - ) - -set_target_properties(CSharpAPITestRE2 PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET._mscorlib - "${re2_mscorlibdll}" - ) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._mscorlib") - -set_target_properties(CSharpAPITestRE2 PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET._System - "${re2_systemdll}" - ) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._System") - -set_target_properties(CSharpAPITestRE2 PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.System.Core - "${re2_systemcoredll}" + set_dotnet_references(CSharpAPITestRE2 "re2" "${RE2_DLLS}") + +endif() +# Target: CSharpAPITestRE4 +if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE4) # build-csharp-test-re4 + set(CSharpAPITestRE4_SOURCES + "test/Test/TestRE4.cs" + cmake.toml ) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.System.Core") - -set_target_properties(CSharpAPITestRE2 PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.viacore - "${re2_viacoredll}" + + add_library(CSharpAPITestRE4 SHARED) + + target_sources(CSharpAPITestRE4 PRIVATE ${CSharpAPITestRE4_SOURCES}) + source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${CSharpAPITestRE4_SOURCES}) + + target_link_libraries(CSharpAPITestRE4 PUBLIC + csharp-api ) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.viacore") - -set_target_properties(CSharpAPITestRE2 PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.application - "${re2_applicationdll}" + + set_target_properties(CSharpAPITestRE4 PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_RELEASE + "${CMAKE_BINARY_DIR}/bin/" + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO + "${CMAKE_BINARY_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY_DEBUG + "${CMAKE_BINARY_DIR}/bin" + LIBRARY_OUTPUT_DIRECTORY_RELEASE + "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO + "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY_DEBUG + "${CMAKE_BINARY_DIR}/lib" + DOTNET_SDK + Microsoft.NET.Sdk + DOTNET_TARGET_FRAMEWORK + net8.0-windows + VS_CONFIGURATION_TYPE + ClassLibrary ) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.application") + + set(CMKR_TARGET CSharpAPITestRE4) + set_dotnet_references(CSharpAPITestRE4 "re4" "${RE4_DLLS}") endif() # Target: ObjectExplorer @@ -534,37 +521,6 @@ if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2) # build-csharp-test-re2 ) set(CMKR_TARGET ObjectExplorer) - set_target_properties(ObjectExplorer PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET - "${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" - ) - -set_target_properties(ObjectExplorer PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET._mscorlib - "${re2_mscorlibdll}" - ) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._mscorlib") - -set_target_properties(ObjectExplorer PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET._System - "${re2_systemdll}" - ) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._System") - -set_target_properties(ObjectExplorer PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.System.Core - "${re2_systemcoredll}" - ) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.System.Core") - -set_target_properties(ObjectExplorer PROPERTIES - VS_DOTNET_REFERENCE_REFramework.NET.viacore - "${re2_viacoredll}" - ) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.viacore") + set_dotnet_references(ObjectExplorer "re2" "${RE2_DLLS}") endif() diff --git a/csharp-api/cmake.toml b/csharp-api/cmake.toml index 9d4a48eb3..11f7ebe46 100644 --- a/csharp-api/cmake.toml +++ b/csharp-api/cmake.toml @@ -44,48 +44,56 @@ if(NOT NUGET_PACKAGES_DIR) set(NUGET_PACKAGES_DIR ${DEFAULT_NUGET_PATH}) endif() -# Set a bool if the generated reference assemblies exist in the build/bin folder -set(dd2_systemdll "${CMAKE_BINARY_DIR}/bin/dd2/REFramework.NET._System.dll") -set(dd2_applicationdll "${CMAKE_BINARY_DIR}/bin/dd2/REFramework.NET.application.dll") -set(dd2_viacoredll "${CMAKE_BINARY_DIR}/bin/dd2/REFramework.NET.viacore.dll") - -set(re2_mscorlibdll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET._mscorlib.dll") -set(re2_systemdll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET._System.dll") -set(re2_systemcoredll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET._System.Core.dll") -set(re2_applicationdll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET.application.dll") -set(re2_viacoredll "${CMAKE_BINARY_DIR}/bin/re2/REFramework.NET.viacore.dll") - -# Initialize a variable to keep track of the existence of all files -set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2 TRUE) -set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2 TRUE) - -# Check if each DLL exists -foreach(dll IN ITEMS ${dd2_systemdll} ${dd2_applicationdll} ${dd2_viacoredll}) - if(NOT EXISTS ${dll}) - set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2 FALSE) - break() # Exit the loop as soon as one file is not found - endif() -endforeach() +# Helper function for setting target properties with custom DLLs +function(set_dotnet_references TARGET DLL_PREFIX DLLS) + foreach(dll IN ITEMS ${DLLS}) + string(REPLACE "REFramework.NET." "" DLL_NAME ${dll}) + string(REPLACE ".dll" "" DLL_NAME ${DLL_NAME}) + set_target_properties(${TARGET} PROPERTIES + VS_DOTNET_REFERENCE_${DLL_NAME} + "${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}/REFramework.NET.${DLL_NAME}.dll" + ) + set_target_properties(${TARGET} PROPERTIES + VS_PACKAGE_REFERENCES "REFramework.NET.${DLL_NAME}" + ) + endforeach() + + set_target_properties(${TARGET} PROPERTIES + VS_DOTNET_REFERENCE_REFramework.NET + "${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" + ) +endfunction() + +# Helper function for checking custom DLL existence +function(check_dlls_exist DLL_PREFIX DLLS VAR_NAME) + message(STATUS "${VAR_NAME} Checking for DLLs in ${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}") + set(${VAR_NAME} TRUE PARENT_SCOPE) + foreach(dll IN ITEMS ${DLLS}) + if(NOT EXISTS "${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}/${dll}") + set(${VAR_NAME} FALSE) + message(STATUS "DLL ${dll} does not exist in ${CMAKE_BINARY_DIR}/bin/${DLL_PREFIX}") + break() + endif() + endforeach() -foreach(dll IN ITEMS ${re2_mscorlibdll} ${re2_systemdll} ${re2_systemcoredll} ${re2_applicationdll} ${re2_viacoredll}) - if(NOT EXISTS ${dll}) - set(REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2 FALSE) - break() # Exit the loop as soon as one file is not found + if (NOT ${${VAR_NAME}}) + message(STATUS "One or more specified DLLs do not exist (${DLL_PREFIX})") + else() + message(STATUS "All specified DLLs exist (${DLL_PREFIX})") endif() -endforeach() +endfunction() -# Use the result -if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2) - message(STATUS "All specified DLLs exist (DD2)") -else() - message(STATUS "One or more specified DLLs do not exist (DD2)") -endif() +# RE2 +set(RE2_DLLS "REFramework.NET._mscorlib.dll;REFramework.NET._System.dll;REFramework.NET._System.Core.dll;REFramework.NET.application.dll;REFramework.NET.viacore.dll") +check_dlls_exist("re2" "${RE2_DLLS}" "REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2") -if (REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2) - message(STATUS "All specified DLLs exist (RE2)") -else() - message(STATUS "One or more specified DLLs do not exist (RE2)") -endif() +# RE4 +set(RE4_DLLS "REFramework.NET._mscorlib.dll;REFramework.NET._System.dll;REFramework.NET._System.Core.dll;REFramework.NET.application.dll;REFramework.NET.viacore.dll") +check_dlls_exist("re4" "${RE4_DLLS}" "REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE4") + +# DD2 +set(DD2_DLLS "REFramework.NET._System.dll;REFramework.NET.application.dll;REFramework.NET.viacore.dll") +check_dlls_exist("dd2" "${DD2_DLLS}" "REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2") # Define a list of NuGet packages and their versions # the last part, the package framework will only be used for copying the files @@ -111,6 +119,7 @@ endforeach() [conditions] build-csharp-test-dd2 = "REFRAMEWORK_REF_ASSEMBLIES_EXIST_DD2" build-csharp-test-re2 = "REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE2" +build-csharp-test-re4 = "REFRAMEWORK_REF_ASSEMBLIES_EXIST_RE4" [template.CSharpSharedTarget] type = "shared" @@ -206,139 +215,40 @@ set_target_properties(AssemblyGenerator PROPERTIES VS_DOTNET_REFERENCE_REFramework.NET "${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" ) - - """ [target.CSharpAPITest] condition = "build-csharp-test-dd2" type = "CSharpSharedTarget" sources = ["test/Test/Test.cs"] -link-libraries = [ - "csharp-api" -] - +link-libraries = ["csharp-api"] cmake-after = """ -set_target_properties(CSharpAPITest PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET -"${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" -) - -set_target_properties(CSharpAPITest PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET._System -"${dd2_systemdll}" -) - -set_target_properties(CSharpAPITest PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._System") - -set_target_properties(CSharpAPITest PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.viacore -"${dd2_viacoredll}" -) - -set_target_properties(CSharpAPITest PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.viacore") - -set_target_properties(CSharpAPITest PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.application -"${dd2_applicationdll}" -) - -set_target_properties(CSharpAPITest PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.application") - +set_dotnet_references(CSharpAPITest "dd2" "${DD2_DLLS}") """ [target.CSharpAPITestRE2] condition = "build-csharp-test-re2" type = "CSharpSharedTarget" sources = ["test/Test/TestRE2.cs"] -link-libraries = [ - "csharp-api" -] - +link-libraries = ["csharp-api"] cmake-after = """ -set_target_properties(CSharpAPITestRE2 PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET -"${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" -) - -set_target_properties(CSharpAPITestRE2 PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET._mscorlib -"${re2_mscorlibdll}" -) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._mscorlib") - -set_target_properties(CSharpAPITestRE2 PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET._System -"${re2_systemdll}" -) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._System") - -set_target_properties(CSharpAPITestRE2 PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.System.Core -"${re2_systemcoredll}" -) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.System.Core") - -set_target_properties(CSharpAPITestRE2 PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.viacore -"${re2_viacoredll}" -) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.viacore") - -set_target_properties(CSharpAPITestRE2 PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.application -"${re2_applicationdll}" -) - -set_target_properties(CSharpAPITestRE2 PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.application") +set_dotnet_references(CSharpAPITestRE2 "re2" "${RE2_DLLS}") +""" +[target.CSharpAPITestRE4] +condition = "build-csharp-test-re4" +type = "CSharpSharedTarget" +sources = ["test/Test/TestRE4.cs"] +link-libraries = ["csharp-api"] +cmake-after = """ +set_dotnet_references(CSharpAPITestRE4 "re4" "${RE4_DLLS}") """ -# Even though this targets RE2 it is not game specific -# It just uses the System/via DLLs which are game agnostic [target.ObjectExplorer] condition = "build-csharp-test-re2" type = "CSharpSharedTarget" sources = ["test/Test/ObjectExplorer.cs"] -link-libraries = [ - "csharp-api" -] - +link-libraries = ["csharp-api"] cmake-after = """ -set_target_properties(ObjectExplorer PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET -"${REFRAMEWORK_DOT_NET_ASSEMBLY_PATH}" -) - -set_target_properties(ObjectExplorer PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET._mscorlib -"${re2_mscorlibdll}" -) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._mscorlib") - -set_target_properties(ObjectExplorer PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET._System -"${re2_systemdll}" -) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET._System") - -set_target_properties(ObjectExplorer PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.System.Core -"${re2_systemcoredll}" -) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.System.Core") - -set_target_properties(ObjectExplorer PROPERTIES -VS_DOTNET_REFERENCE_REFramework.NET.viacore -"${re2_viacoredll}" -) - -set_target_properties(ObjectExplorer PROPERTIES VS_PACKAGE_REFERENCES "REFramework.NET.viacore") -""" \ No newline at end of file +set_dotnet_references(ObjectExplorer "re2" "${RE2_DLLS}") +""" diff --git a/csharp-api/make_symlinks.py b/csharp-api/make_symlinks.py index be475f8ef..aa5fd72e8 100644 --- a/csharp-api/make_symlinks.py +++ b/csharp-api/make_symlinks.py @@ -28,6 +28,7 @@ def symlink_main(gamedir=None, bindir="build/bin", just_copy=False): source_dir_files = [ "Test/Test/Test.cs", "Test/Test/TestRE2.cs", + "Test/Test/TestRE4.cs", "Test/Test/ObjectExplorer.cs", ] diff --git a/csharp-api/test/Test/TestRE4.cs b/csharp-api/test/Test/TestRE4.cs new file mode 100644 index 000000000..6ddf3e6e5 --- /dev/null +++ b/csharp-api/test/Test/TestRE4.cs @@ -0,0 +1,34 @@ +using System; + +using ImGuiNET; +using REFrameworkNET; +using REFrameworkNET.Callbacks; +using REFrameworkNET.Attributes; +using _; + +public class TestRE4Plugin { + static bool IsRunningRE2 => Environment.ProcessPath.Contains("re4", StringComparison.CurrentCultureIgnoreCase); + + [Callback(typeof(ImGuiRender), CallbackType.Pre)] + public static void ImGuiCallback() { + if (ImGui.Begin("Test Window")) { + ImGui.Text("RE4"); + ImGui.Separator(); + + + if (ImGui.TreeNode("Player")) { + var context = GlobalService.Chainsaw._sCharacterManagerCache.getPlayerContextRef(); + + if (context == null) { + ImGui.Text("Player context is null"); + } else { + ImGui.Text($"Player context: {(context as IObject).Call("ToString", null) as string}"); + } + + ImGui.TreePop(); + } + + ImGui.End(); + } + } +} \ No newline at end of file