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

MethodDelegate: allow for swapping value type with object, and allow ref for arg 0 on value type #633

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

Eddio0141
Copy link
Contributor

This changes AccessTools.MethodDelegate to let you use object where a value type exists

Also lets you use ref for the first argument with value types, since currently you can't mutate structs from dynamic methods generated when open instance without boxing, so this lets you use delegates such as void MyFunc(ref UnityEngine.Resolution res);

@pardeike
Copy link
Owner

That’s nice work!

@pardeike
Copy link
Owner

Maybe you can add some tests too?

@Eddio0141 Eddio0141 force-pushed the master branch 2 times, most recently from 921e1e7 to d6fb93f Compare November 16, 2024 16:15
repeat mutation to see effect

fixed bind error

restore missing test
@Eddio0141
Copy link
Contributor Author

Thanks! Also sorry for the messy commits, I've squashed them to two commits to try make it clean
I've added 2 tests which should test the exact code, it is all done now and should be passing

Also I just realised, this fix would only apply for virtualCall: false, since delegates is incompatible normally, and this fixes just the dmd to handle these things

@pardeike pardeike merged commit 899a3cd into pardeike:master Dec 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants