Closed siblount closed 1 year ago
I don't know how any of this works, but there is also the possibility that whatever was not configured correctly, I also made an issue on NSub's repo: https://github.com/nsubstitute/NSubstitute/issues/730
This issue seems to be about C# 9 covariant return types, which DynamicProxy should support since version 5.1.0. (See #619.)
Can you please check which version of NSubstitute (and Castle.Core) you are using? Also, which version of .NET are you running your code on?
Ah...It would seem that the latest NSubstitute release is using Castle.Core version 5.0.0.* according to the csproj.
I am also using .NET 6.0 Windows.
OK, in that case there's not much to be done on DynamicProxy's side. NSubstitute should probably upgrade their Castle.Core dependency... I've seen in the linked issue that they've already done so.
I'm going to close this issue as it'll likely be resolved after the upgrade. If not, let us know again here and we'll reopen.
Yup, verified that the problem is solved by updating Castle.Core version. Thanks @stakx !
Describe the bug Castle proxy fails to create a substitute for a concrete class that derives from an abstract class and virtual members.
To Reproduce Here's an example of what I am talking about: Setup classes
Test code:
Running the above returns this error message...
and stack trace...
As it turns out, it seems that there is an issue with the proxy when the
ConcreteIOContext
has the return typeXDirectoryInfo
, which does implementIDirectoryInfo
, but not stated explicitly. If stated explicitly, the issue goes away.The code above now makes it work without any issue.