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

Make setups for inaccessible internal members fail fast by throwing an exception #455

Merged
merged 4 commits into from
Sep 23, 2017

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Sep 23, 2017

Moq currently does not complain when an attempt is made to Setup an internal method that the proxy won't be able to intercept because the [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] attribute for DynamicProxy is missing. The setup appears to succeed, yet won't take effect when the mock is used.

These commits add checks that verify whether methods that are being set up are accessible to DynamicProxy; if they are not, Setup et al. throw an exception (i.e. fail fast).

This closes #178.

For two reasons:

 1. We will need to have it available inside the `Mock` class.

 2. We don't need several factories, a single one is enough, so
    having it in a generic class means that more factories will get
    instantiated than necessary. This can be avoided by the move
    from `Mock<T>` to `Mock`.
@stakx stakx force-pushed the invisible-internals branch 2 times, most recently from e3d6119 to 642150f Compare September 23, 2017 20:19
@stakx stakx changed the title Make setups for inaccessible internal fail fast Make setups for inaccessible internal members fail fast by throwing an exception Sep 23, 2017
@stakx stakx merged commit c316449 into devlooped:develop Sep 23, 2017
@stakx stakx deleted the invisible-internals branch September 23, 2017 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.

None yet

1 participant