Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace and remove DynDelegate #432

Merged
merged 2 commits into from
May 24, 2024

Commits on Apr 7, 2024

  1. 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`, not `MP.RegisterSyncWorker` calls - which would treat all as having no return type (and 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`.
    SokyranTheDragon committed Apr 7, 2024
    Configuration menu
    Copy the full SHA
    62d53a9 View commit details
    Browse the repository at this point in the history
  2. Apply changes to SyncWorkerEntry

    Those changes were originally applied to a different file, but it got removed/renamed/code was moved so the changes got lost in the rebase.
    SokyranTheDragon committed Apr 7, 2024
    Configuration menu
    Copy the full SHA
    03681dc View commit details
    Browse the repository at this point in the history