Fix Unity static state resetting for generic types - #5738
Open
ImDreamerDev wants to merge 4 commits into
Open
Conversation
Removed ResetStaticFields since [RuntimeInitializeOnLoadMethod] cannot be used on methods within generic classes. DbConnectionBase.IsTesting is the only field reset by this mechanism, and leaving it uncleared should not affect Unity. Signed-off-by: Vanessa Vinther <7903603+ImDreamerDev@users.noreply.github.com>
Provides a mechanism for registering and resetting static fields during Unity's subsystem registration phase. Unity's RuntimeInitializeOnLoadMethod can't be used in generic classes. Signed-off-by: Vanessa Vinther <7903603+ImDreamerDev@users.noreply.github.com>
Updated the static constructor documentation for RemoteTableHandleBase to clarify its functionality regarding Unity's domain reloading. Removed the older ResetStaticFields method that was specific to older Unity versions. Signed-off-by: Vanessa Vinther <7903603+ImDreamerDev@users.noreply.github.com>
Signed-off-by: Vanessa Vinther <7903603+ImDreamerDev@users.noreply.github.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.
Description of Changes
After more testing and experimentation with Domain Reload in Unity, I found that we get the Error:
Both for RemoteTableHandleBase and DbConnectionBase
This fixes the static state resetting for both of these in Unity.
The existing
ResetStaticFieldsmethod was also removed fromDbConnectionBase.DbConnectionBase.IsTestingwas the only field being reset by this mechanism, and leaving it uncleared should not affect Unity.I've also updated documentation for
RemoteTableHandleBaseto clarify how its static state interacts with Unity domain reloading.API and ABI breaking changes
No API or ABI breaking changes.
The changes are internal implementation details of the Unity SDK and do not change the public API.
Expected complexity level and risk
2/5 — Low complexity and low risk.
The changes are limited to Unity-specific static state initialization and reset behavior. The main interaction is with Unity's subsystem registration lifecycle and the static state of
RemoteTableHandle.Testing