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

Way to override returned reference itself #582

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

kohanis
Copy link
Contributor

@kohanis kohanis commented Feb 22, 2024

It is, on the whole, a suggestion. Currently, there is no way to override the reference itself in a method like ref T fn()
This implementation adds an optional parameter out RefResult<T> __resultRef (out is a requirement as it is called immediately after the patch and nulled), where delegate ref T RefResult<T>()
I don't have a user-case for this, but someone might have one

// On second thought, out requirement is unnecessary, ref is okay

@kohanis
Copy link
Contributor Author

kohanis commented Feb 22, 2024

Lack of documentation is intentional until acceptance of feature itself is confirmed

Copy link
Owner

@pardeike pardeike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work. I added two comments, please verify. And beside the comments, I think we can go and add some documentation (make sure you don't edit html files but appropiate markdown in /Harmony/Documentation and all docfx annotations of course.

HarmonyTests/Patching/Specials.cs Outdated Show resolved Hide resolved
Harmony/Internal/MethodPatcher.cs Show resolved Hide resolved
@kohanis
Copy link
Contributor Author

kohanis commented Feb 23, 2024

Added docs(Never been good at it, hope it's understandable), new test + initial reset + restructured. Lifted out requirement

@kohanis kohanis marked this pull request as ready for review February 23, 2024 03:01
@pardeike
Copy link
Owner

I will pull this and clean up any documentation if necessary later. Excellent work, much appreciated and great timing to get this into the next big release.

@pardeike pardeike merged commit b2eb250 into pardeike:master Feb 23, 2024
46 checks passed
@kohanis kohanis deleted the ref-return-patch branch February 23, 2024 13:24
@kohanis
Copy link
Contributor Author

kohanis commented Feb 28, 2024

Actually, I was wrong. This could have been achieved through prefix with skip and/or passthrough postfix. I completely forgot about them. But now it's too late to delete... Apologies

EDIT: Well, I suppose new method is a little more optimal

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