Skip to content

Fix ReturnValue for InterceptSynchronous#205

Open
PMExtra wants to merge 2 commits intoJSkimming:masterfrom
PMExtra:master
Open

Fix ReturnValue for InterceptSynchronous#205
PMExtra wants to merge 2 commits intoJSkimming:masterfrom
PMExtra:master

Conversation

@PMExtra
Copy link
Copy Markdown

@PMExtra PMExtra commented Aug 16, 2023

No description provided.

@PMExtra
Copy link
Copy Markdown
Author

PMExtra commented Aug 16, 2023

abpframework/abp#9164

@JSkimming
Copy link
Copy Markdown
Owner

Hi @PMExtra, I don't know what problem is resolved by this. Can you explain further? Please provide tests that demonstrate the issue and how the change fixes it.

Generally, a transition from async to sync is fraught and best avoided.

@PMExtra
Copy link
Copy Markdown
Author

PMExtra commented Aug 16, 2023

We have invocation.ReturnValue = InterceptAsync(...) for async methods:
https://github.com/JSkimming/Castle.Core.AsyncInterceptor/blob/v2.1.0/src/Castle.Core.AsyncInterceptor/AsyncInterceptorBase.cs#L49-L67

But we ignored the InterceptAsync result for sync methods.

@PMExtra
Copy link
Copy Markdown
Author

PMExtra commented Aug 16, 2023

That means we cannot modify the return value for synchronous methods.

@JSkimming
Copy link
Copy Markdown
Owner

@PMExtra Can you provide tests as part of your changes that demonstrate the issue?

@PMExtra
Copy link
Copy Markdown
Author

PMExtra commented Aug 17, 2023

After the patch:
image

Without the patch:
image
image

@PMExtra
Copy link
Copy Markdown
Author

PMExtra commented Aug 17, 2023

It is also fixed if we want to change the original return value for the synchronous method.

@JSkimming
Copy link
Copy Markdown
Owner

@PMExtra, thank you for this. I understand the issue better now. I still want to give this further investigation, and I won't be able to do that for a couple of weeks. I'll be returning to this when I can.

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