After the weekend stack updates all of my builds are failing. Doing some research into this it seems to be a known issue with Mono 5.4.
The issue is that some unit tests are failing with an assertion failure and reflection exception.
NUnit Console Runner 3.4.1
Copyright © 2016 Charlie Poole
OS Version: MacOSX 18.104.22.168
CLR Version: 4.0.30319.42000
- Assertion at dynamic-image.c:209, condition `prev == MONO_HANDLE_RAW (obj)’ not met
at (wrapper managed-to-native) System.Reflection.Emit.ModuleBuilder.getToken (System.Reflection.Emit.ModuleBuilder,object,bool) [0x0000b] in :0
at System.Reflection.Emit.ModuleBuilder.GetToken (System.Reflection.MemberInfo,bool) [0x00061] in :0
All our unit tests ran fine under the previous version of Vs for Mac and Mono 5.2.
We’re using MOQ for mocking in our unit tests and this issue was reported in their repo a few weeks ago: https://github.com/moq/moq4/issues/449
But, they’re referring to it as a mono bug.
The issue has also been reported on the Xamarin bugzilla:
Its for IronPython but the bug is the same.
It appears to be fixed in Mono master https://github.com/mono/mono/commit/0f76c2acec24cd45b71d6e21c450b51ecdfe96f0
But the root cause is the version that Vs for Mac is pulling in.
I recommend rolling back the Vs for mac patch until Microsoft pull in a later version of Mono.
Can I also suggest that you include a unit test in your test suite that uses Moq to test for this issue?
var obj = new Mock<Object>().Object;
var stream = new Mock<Stream>().Object;