-
Notifications
You must be signed in to change notification settings - Fork 258
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
Breaking change in version 2.1.0.230 #355
Comments
@herebebeasties probably related to the changes in #352? |
Could we for this use case have an internal parameterless constructor and expose it to Moq/Castle Core via |
Users can probably fix this by giving Moq a A default internal constructor that's visible to DynamicProxyGen2 or whatever it is seems like a reasonable solution to me. Have to be a bit careful about how we signal to people who are implementing these base classes that they shouldn't be using it, though. It might make more sense to make these things into interfaces, but that's an even bigger API break. :-/ I'll have a think and sort out a PR. |
Created a PR for the quick-fix. Long-term we should just do #175 to never again run into issues like these. |
Mocking libraries, like Moq, are based on Castle.Core and rely on its functionality for generating dynamic proxies. This is only possible when there is an accessible parameterless constructor. This changes re-adds such constructors to several base types. They are marked internal and obsolete so that nobody accidentially uses them in "real" code. To allow Castle.Core to access them altough they are internal we expose our internals to the dynamic proxy assembly. Fixes #355
@LinusNoren Could you verify that your problem is fixed in https://www.nuget.org/packages/System.IO.Abstractions/2.1.0.234 and give quick feedback here? |
Closing this. @LinusNoren feel free to re-open if you encounter a problem. |
Sorry @fgreinacher, I've haven't had time to verify it yet. Will try to do that tomorrow. Thanks for the fix! |
It works fine! Thank you for the help. |
Before version 2.1.0.230 you could do this:
_fileSystem = new Mock<IFileSystem>();
_fileSystem.Setup(x => x.Directory.Exists(It.IsAny<string>())).Returns(true);
But that doesn't work any longer, you get this error:
How should you write this code to get this to work now?
The text was updated successfully, but these errors were encountered: