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

Add internal, parameterless ctors for generated proxies #359

Merged
merged 5 commits into from
Oct 8, 2018
Merged

Add internal, parameterless ctors for generated proxies #359

merged 5 commits into from
Oct 8, 2018

Conversation

fgreinacher
Copy link
Contributor

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.

Long-term we should expose interfaces instead of
abstract classes at IFileSystem.

Fixes #355

@fgreinacher
Copy link
Contributor Author

@herebebeasties This is my take on #355. It's ugly but it works :/

Copy link
Contributor

@herebebeasties herebebeasties left a comment

Choose a reason for hiding this comment

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

LGTM. The obsolete-as-error is a good solution here. 👍

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.

Long-term we should expose interfaces instead of
abstract classes at `IFileSystem`.
@fgreinacher
Copy link
Contributor Author

I added some tests to ensure that all properties exposed at IFileSystem can be mocked to prevent running into this problem again. Doing this I found that one of them was missing, but now it seems to be complete.

@marvinderksen
Copy link

Long-term we should expose interfaces instead of
abstract classes at IFileSystem.

yes! I absolutely agree on this one

@fgreinacher fgreinacher merged commit 933ae30 into TestableIO:master Oct 8, 2018
@fgreinacher fgreinacher deleted the mockability branch October 8, 2018 20:27
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.

3 participants