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.
DynDelegate
was required to handle 2 possible signatures for the sync worker delegate:bool
SyncWorkerAttribute
, notMP.RegisterSyncWorker
calls - which only support no return types (and are handled in a different location than the one being changed here)DynDelegate
was used here as when it changed it took a method with no return type - it would return true (il.Emit(OpCodes.Ldc_I4_1)
).My solution here is to have 2 delegates - one of which has no return type. I then create the appropriate delegate with a call to
Delegate.CreateDelegate
. For delegates that already return a boolean - I pass it further. However, delegates with no return value are first wrapped with a delegate that will then return true (matchingDynDelegate
behaviour.From my initial testing everything seems to work fine as-is. However, I believe some extra testing should be done before applying those changes - specifically with existing mods using
SyncWorkerAttribute
. Since there could be something obvious I'm missing here I'll be marking this PR as a draft.