fsprojects / Foq

A unit testing framework for F#
http://www.slideshare.net/ptrelford/foq-17062247
Apache License 2.0
79 stars 31 forks source link

Foq error is very unhelpful for internal types #32

Open Frassle opened 3 years ago

Frassle commented 3 years ago

Description

When using an internal type in a mock Foq can crash with incredibly confusing System.MethodAccessException errors. This can be fixed by either making the type public or adding InternalsVisbleTo("Foq.Dynamic"). But this bug is not that an error occurs but that the error is unhelpful for working out what's actually wrong.

Repro steps

Please provide the steps required to reproduce the problem

  1. Add an internal type to an assembly

  2. Use that internal type as part of an Mock<_>

Expected behavior

Foq should crash with an error explict about the fact an internal type has been used that Foq can't see.

Actual behavior

Foq crashes with a MethodAccessException.

Known workarounds

Just know that MethodAccessException could mean a visibility issue.