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

Add RuntimeInitializeOnLoadMethodAttribute snippet automatically somehow(? #5

Open
EvaisaDev opened this issue Dec 31, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@EvaisaDev
Copy link
Owner

idk how i would go about doing this tbh

@Lordfirespeed
Copy link
Collaborator

I think this is doable with some Cecil magic, but it will be tricky to avoid breaking compatibility with existing mods that have that snippet 🤔

@Lordfirespeed Lordfirespeed added the enhancement New feature or request label Jan 8, 2024
@EvaisaDev
Copy link
Owner Author

I think this is doable with some Cecil magic, but it will be tricky to avoid breaking compatibility with existing mods that have that snippet 🤔

I was wondering more where to add it, but true would also have to avoid breaking existing mods. I think using cecil to detect it should be possible, unless people manually call their init functions in which case it no longer works.

@EvaisaDev
Copy link
Owner Author

Actually maybe thats not a problem because we can just tell people they no longer need the snippet, since they would have to manually update netcode patcher for this behaviour to be a thing anyway.

Alternatively adding the snippet could be an option rather than a default

@Lordfirespeed
Copy link
Collaborator

Good points.

I think probably the way to go is

  1. make it an option, but the default is to add the snippet
  2. attempt to search for the existing snippet? I'm not sure how to implement that.
  3. Increment version to 4.0 as this is breaking

@Lordfirespeed
Copy link
Collaborator

Lordfirespeed commented Jan 10, 2024

We could alternatively provide a package containing compile resources, ie the snippet as a static method, and have people either package reference it + call it from an appropriate place or add snippet manually.

I think that would be a cleaner solution tbh

@EvaisaDev
Copy link
Owner Author

EvaisaDev commented Jan 11, 2024

We could alternatively provide a package containing compile resources, ie the snippet as a static method, and have people either package reference it + call it from an appropriate place or add snippet manually.

I think that would be a cleaner solution tbh

Well my issue is that i would like netcode patcher to behave as close as native unity as possible.
And in unity you do not need to make any manual calls in order for functions marked with [RuntimeInitializeOnLoadMethodAttribute] to run.
Those functions are intended to run automatically when the assembly(? is loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants