The C# compiler (version 7.x+) emits unverifiable code in certain situations. Due to the SecurityTransparent attribute a runtime exception (VerifiableException) will be thrown when the unverifiable code executes (Releated issue: https://github.com/dotnet/roslyn/issues/27382.
This is intended compiler behavior but there is a compiler feature flag that can be used to disable those optimizations (for more info see https://github.com/dotnet/roslyn/pull/22772):
An example of this problem is mentioned in https://github.com/re-motion/Relinq-SqlBackend/pull/7 where SqlContextExpressionVisitor.Visit throws a VerifiableException. This problem boils down to the problem outlined in https://github.com/dotnet/roslyn/issues/22485
Please incorporate patch by as a separate feature branch and integrate before the moq migration.