Repository navigation
C-Sharp API related fixes - #1860
Merged
Merged
Conversation
Previously the only time PluginExitPoint was called was when all the plugins were being unloaded (pressing the "Unload Scripts" button). This meant that if a plugin was unloaded on its own (via SynchronousUnload), PluginExitPoint would not be called, which could lead to issues if the plugin was relying on that function to clean up resources.
cimgui was exporting suffixed igGetForegroundDrawList_Nil and igGetBackgroundDrawList_Nil functions, however when attempting to call said functions from C# plugins they wouldn't be found (leading to game crash) due to the correct signature being without the suffixes. To address this I added aliases igGetForegroundDrawList and igGetBackgroundDrawList that call the same underlying c++ functions.
The engine uses negative ref counts to identify thread-local managed objects, but the ABI exposes the value as unsigned. Cast it to int32_t before comparison so local objects bypass the shared wrapper cache and pool, preventing incorrect cross-thread reuse of thread-local objects.
onehoon
added a commit
to onehoon/REFramework
that referenced
this pull request
Oct 11, 2026
* SDK/API: Fix get_ref_count being unsigned (< 0 are local-thread MO) (cherry picked from commit 94a1218) * C-Sharp API related fixes (praydog#1860) * Fixed SynchronousUnload not calling PluginExitPoint Previously the only time PluginExitPoint was called was when all the plugins were being unloaded (pressing the "Unload Scripts" button). This meant that if a plugin was unloaded on its own (via SynchronousUnload), PluginExitPoint would not be called, which could lead to issues if the plugin was relying on that function to clean up resources. * Fixed function signature of exported cimgui functions cimgui was exporting suffixed igGetForegroundDrawList_Nil and igGetBackgroundDrawList_Nil functions, however when attempting to call said functions from C# plugins they wouldn't be found (leading to game crash) due to the correct signature being without the suffixes. To address this I added aliases igGetForegroundDrawList and igGetBackgroundDrawList that call the same underlying c++ functions. * Fix signed ref-count detection for local MOs The engine uses negative ref counts to identify thread-local managed objects, but the ABI exposes the value as unsigned. Cast it to int32_t before comparison so local objects bypass the shared wrapper cache and pool, preventing incorrect cross-thread reuse of thread-local objects. (cherry picked from commit b47842c) * fix: package path should contain autorun (praydog#1863) Signed-off-by: LingSamuel <lingsamuelgrace@gmail.com> (cherry picked from commit d7d59ad) * Preserve the previous session log across restarts (praydog#1846) re2_framework_log.txt was opened with truncate=true, so the previous session's log was destroyed as soon as the framework was loaded. After a crash this made it impossible to inspect the log of the session that crashed: restarting the game, which is the first thing anyone does, had already overwritten it. Rename the existing log to re2_framework_log.prev.txt before creating the logger, so the previous session survives a restart. All filesystem calls use the std::error_code overloads, so a failure (e.g. a locked file) quietly falls back to the old behaviour instead of blocking startup. At most one previous session is kept: an existing .prev.txt is removed before the rename. (cherry picked from commit c36e8c4) * .NET: Add console window display option (cherry picked from commit d052e8f) --------- Signed-off-by: LingSamuel <lingsamuelgrace@gmail.com> Co-authored-by: praydog <praydog@praydog.com> Co-authored-by: Gino <60258854+ZGako@users.noreply.github.com> Co-authored-by: Sarasa Kisaragi <lingsamuelgrace@gmail.com> Co-authored-by: wdre9 <15378433390@163.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'll copy paste the commit messages as they're descriptive enough:
Fixed SynchronousUnload not calling PluginExitPoint
Previously the only time PluginExitPoint was called was when all the plugins were being unloaded (pressing the "Unload Scripts" button).
This meant that if a plugin was unloaded on its own (via SynchronousUnload), PluginExitPoint would not be called, which could lead to issues if the plugin was relying on that function to clean up resources.
Fixed function signature of exported cimgui functions
cimgui was exporting suffixed igGetForegroundDrawList_Nil and igGetBackgroundDrawList_Nil functions,
however when attempting to call said functions from C# plugins they wouldn't be found (leading to game crash) due to the correct signature being
without the suffixes. To address this I added aliases igGetForegroundDrawList and igGetBackgroundDrawList that
call the same underlying c++ functions.
Fix signed ref-count detection for local MOs
The engine uses negative ref counts to identify thread-local managed objects, but the ABI exposes the value as unsigned. Cast it to int32_t before comparison so local objects bypass the shared wrapper cache and pool, preventing incorrect cross-thread reuse of thread-local objects.
In particular this issue would crop up when creating strings inside an UpdateBehavior callback. I assume the C# multi-threading would cause this.
I'm aware cimgui isn't in the csharp-api folder however this fix is related to being able to utilize ImGui properly from the C# plugins.