Replace and remove DynDelegate
DynDelegate was required to handle 2 possible signatures for the sync worker delegate:
- Explicit sync worker delegates would have no return type
- Implicit sync worker delegates would return
bool - Those rules only apply to sync workers registered by using
SyncWorkerAttribute, notMP.RegisterSyncWorkercalls - 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 (matching DynDelegate 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.
Merged with and updated to master, now targeting 1.5
Reset before merge, then rebase to master
Looks fine, can you undraft it?
Yep, done.