Exception "System.InvalidProgramException: JIT Compiler encountered an internal limitation " has occured
Sample code:
Below code is not complete but it is enough to show wt problem i am facing.
namespace ClassLibrary1
{
class Class1
{
internal static void sum(ref List<TestClass> a, int b)
{
//some code
}
}
}
There is another class in same assembly
namespace ClassLibrary1
{
class TestClass
{开发者_Python百科
//code
}
}
when I create unit test case for method sum then code would be like
[TestMethod()]
public void sumTest()
{
List<TestClass_Accessor> lstTestClass = new List<TestClass_Accessor>();
Class1_Accessor.sum(ref lstTestClass, b);
}
Problem: In above code I am creating list of type TestClass but it is private class so VSTS create TestClass_Accessor to access class functionality. In method Sum, It takes parameter as a reference of list of type "TestClass".
I have also debug my code but when
Class1_Accessor.sum(ref lstTestClass, b);
is debugged it throws exception "System.InvalidProgramException: JIT Compiler encountered an internal limitation ".
When i created list of string type then it works i.e. list has no problem.
As per my understanding problem is in type of list. in unit test we create list of type TestClass_Accessor
.
And in class list has type List<TestClass>
.
please provide solution for this.
Regards,
Nitin Sahu
I have problems understanding what You are saying. But... TestClass is not private in code You provided. By default it is internal when no access modifier is specified. And You can easily access internal members in Your tests. Maybe You won't have any problems when You eliminate additional stuff (TestClass_Accessor).
Look here: How to test Framework if Unit tests are in separate assembly?
And BTW You don't need ref
when passing reference values.
Using "ref" is part of the problem here. I had the same problem and it went away when not using the "ref" keyword.
As Peri already stated, using ref is not needed here.
精彩评论