After some minor refactoring, a codebase began experiencing unexpected test failures via the ncrunch runner, that were not also failures when using other runners.
System.InvalidProgramException: Common Language Runtime detected an invalid program.
(With a call stack ending at an attempt to set an init property.)
After some investigation it appears to be related to use of System.Runtime.CompilerServices IsExternalInit which I introduced a while ago as part of a preview feature workaround. Ultimately I no longer required the workaround and was able to remove my defintiion of IsExternalInit to restore successful test execution via ncrunch.
Minimal repro here: https://github.com/eric-winkler/ncruncherror
This may be the same issue as https://forum.ncrunch.net/yaf_postst3148_InvalidOperationException-with-init-properties-again---NET-5.aspx
Build/Test Issues
InvalidOperationException with init properties (.net6)
Started by ericwinkler on 2,149 views
Remco NCrunch Developer
#15924
04 Jan 2022 22:40 UTC
Thanks for sharing this. I guess this attribute must have some kind of impact on the behaviour of the JIT. Do you have any information about the preview feature workaround you had in place? I'm trying to establish if this is an issue other users might also be experiencing. From the docs, it looks like this is an internal attribute that MS don't intend for developers to normally make use of.
Edit: Nevermind, I found it. We'll take a look at this. Thanks for bringing it up.
Edit: Nevermind, I found it. We'll take a look at this. Thanks for bringing it up.
Edited 04 Jan 2022 22:41 UTC
Deleted post
#15945
21 Jan 2022 11:28 UTC
I'm also experiencing this but cannot recreate it.
I'm running NCrunch 4.11.0.2 in VS2022 (17.1.5) using .NET SDK 6.0.104.
Using .NET SDK 6.0.202 makes no difference.
I'm running NCrunch 4.11.0.2 in VS2022 (17.1.5) using .NET SDK 6.0.104.
Using .NET SDK 6.0.202 makes no difference.
Remco NCrunch Developer
#16086
20 Apr 2022 12:22 UTC
spectresystems wrote:I'm also experiencing this but cannot recreate it.
I'm running NCrunch 4.11.0.2 in VS2022 (17.1.5) using .NET SDK 6.0.104.
Using .NET SDK 6.0.202 makes no difference.
Thanks for sharing this. Could you confirm if you're using the System.Runtime.CompilerServices IsExternalInit attribute in your codebase?
Remco wrote:spectresystems wrote:I'm also experiencing this but cannot recreate it.
I'm running NCrunch 4.11.0.2 in VS2022 (17.1.5) using .NET SDK 6.0.104.
Using .NET SDK 6.0.202 makes no difference.
Thanks for sharing this. Could you confirm if you're using the System.Runtime.CompilerServices IsExternalInit attribute in your codebase?
Yes, had an old `IsExternalInit` polyfill in my codebase that wasn't used anymore, and removing that made the tests work again.
Post a reply
Log in to reply.