Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Allow modifying method invocation return values #61

Closed
kzu opened this issue Dec 19, 2020 · 3 comments · Fixed by #67
Closed

Allow modifying method invocation return values #61

kzu opened this issue Dec 19, 2020 · 3 comments · Fixed by #67
Labels
enhancement New feature or request

Comments

@kzu
Copy link
Member

kzu commented Dec 19, 2020

It would be useful to be able to modify the returned values from a call to the base method implementation or the subsequent behaviors in the pipeline before returning to caller.

Currently, IMethodReturn has no public implementation and no mutating members that can be used for that, so it's pretty much forbidden (unless you implement the interface yourself).

We could either make the internal MethodReturn implementation public (like we do for MethodInvocation itself and/or add mutating methods like WithArguments, WithReturnValue and WithException. Since almost all our interface implementations are public, maybe that's the simplest approach here too?

From feedback by @stakx in #56

@kzu kzu added the enhancement New feature or request label Dec 19, 2020
@stakx
Copy link
Contributor

stakx commented Dec 21, 2020

I originally voted towards With... methods, but didn't consider that some implementation types are already public... so yes, making MethodReturn public too is perhaps indeed easiest... esp. if user implementations would end up being near identical anyway.

I was wondering whether it could be implemented as a record? That might give us with syntax for free...?

@kzu
Copy link
Member Author

kzu commented Dec 21, 2020

Yeah, making it a record sounds good. I'll see how that looks 👍. Will need IsExternalInit to keep it NS2, but it should just work...

@kzu
Copy link
Member Author

kzu commented Dec 21, 2020

Works like a charm :)

image

kzu added a commit that referenced this issue Dec 21, 2020
Otherwise extenders would need to implement the (mostly trivial) class themselves, which doesn't add value and is just friction. All our other interfaces have public implementations anyway.

We make the class a record too, so it can easily be modified on the fly with `result with { Exception = ..., ReturnValue = ... }`, for example.

Fixes #61.
kzu added a commit that referenced this issue Dec 21, 2020
Otherwise extenders would need to implement the (mostly trivial) class themselves, which doesn't add value and is just friction. All our other interfaces have public implementations anyway.

We make the class a record too, so it can easily be modified on the fly with `result with { Exception = ..., ReturnValue = ... }`, for example.

Fixes #61.
kzu added a commit that referenced this issue Dec 21, 2020
Otherwise extenders would need to implement the (mostly trivial) class themselves, which doesn't add value and is just friction. All our other interfaces have public implementations anyway.

We make the class a record too, so it can easily be modified on the fly with `result with { Exception = ..., ReturnValue = ... }`, for example.

Fixes #61.
kzu added a commit that referenced this issue Dec 21, 2020
Otherwise extenders would need to implement the (mostly trivial) class themselves, which doesn't add value and is just friction. All our other interfaces have public implementations anyway.

We make the class a record too, so it can easily be modified on the fly with `result with { Exception = ..., ReturnValue = ... }`, for example.

Fixes #61.
@kzu kzu closed this as completed in #67 Dec 21, 2020
kzu added a commit that referenced this issue Dec 21, 2020
Otherwise extenders would need to implement the (mostly trivial) class themselves, which doesn't add value and is just friction. All our other interfaces have public implementations anyway.

We make the class a record too, so it can easily be modified on the fly with `result with { Exception = ..., ReturnValue = ... }`, for example.

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

Successfully merging a pull request may close this issue.

2 participants