Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

InvalidOperationException with init properties (.net6)
ericwinkler
#1 Posted : Tuesday, January 4, 2022 2:59:08 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/4/2022(UTC)
Posts: 1
Location: Australia

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.ne...rties-again---NET-5.aspx
Remco
#2 Posted : Tuesday, January 4, 2022 10:40:00 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,592

Thanks: 868 times
Was thanked: 1179 time(s) in 1099 post(s)
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.
spectresystems
#4 Posted : Wednesday, April 20, 2022 5:49:42 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/13/2021(UTC)
Posts: 2
Location: Sweden

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
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.
Remco
#5 Posted : Wednesday, April 20, 2022 12:22:09 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,592

Thanks: 868 times
Was thanked: 1179 time(s) in 1099 post(s)
spectresystems;16085 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?
1 user thanked Remco for this useful post.
spectresystems on 5/10/2022(UTC)
spectresystems
#6 Posted : Tuesday, May 10, 2022 7:00:56 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/13/2021(UTC)
Posts: 2
Location: Sweden

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
Remco;16086 wrote:
spectresystems;16085 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.
1 user thanked spectresystems for this useful post.
Remco on 5/10/2022(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.044 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download