Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected opcode: Initobj #38

Open
VinS101 opened this issue Jan 2, 2018 · 0 comments
Open

Unexpected opcode: Initobj #38

VinS101 opened this issue Jan 2, 2018 · 0 comments

Comments

@VinS101
Copy link

VinS101 commented Jan 2, 2018

I am getting this error when trying to setup a callback for a static method that has two int? arguments with default values of null.

My static method looks like this:

public List<EventTriggerAction> LookupActions(int? fieldValueChangedID = null, int? eventTriggerActionID = null)
{
	using (var conn = new SqlConnection(ConnectionString.Sql))
	{
		using (var cmd = new SqlCommand("EventTriggerActionGroup_LookupActions", conn))
		{
			// DB call
		}
	}
}

My test:

Smock.Run(context =>
{
    EventTriggerActionGroup group = EventTriggerActionGroupTests.Mock();
    context.Setup(() => group.LookupActions(null, null)).Returns(mockLookUpActions);
    
    scheduleSet.ExecuteAllEventTriggerActionGroups(); // Method that depends on LookupActions()
    Assert.IsNull(scheduleSet);
});

Stacktrace:

System.NotImplementedException: Unexpected opcode: Initobj
    at Smocks.IL.Visitors.NumberPoppedVisitor.Visit(Instruction instruction)
   at Smocks.IL.Visitors.InstructionVisitorBase`1.VisitType(Instruction instruction, TypeReference typeReference)
   at Smocks.IL.Visitors.InstructionVisitorBase`1.VisitInlineType(Instruction instruction, TypeReference operand)
   at Smocks.IL.InstructionExtensions.Accept[T](Instruction instruction, IInstructionVisitor`1 visitor)
   at Smocks.IL.ExpressionDecompiler`1.GetNumberPoppedByInstruction(Instruction current)
   at Smocks.IL.ExpressionDecompiler`1.IncludeInstructionsUntilStackEmpty(MethodBody body, Instruction instruction, BitArray includedInstructions, Int32 expectedStackSize)
   at Smocks.IL.ExpressionDecompiler`1.Decompile(MethodBody body, Instruction instruction, Object target, Int32 expectedStackSize, Int32 stackEntriesToSkip)
   at Smocks.IL.ExpressionDecompiler`1.Decompile(MethodBody body, Instruction instruction, Object target)
   at Smocks.IL.SetupExtractor.<GetSetupsFromInstructions>d__10.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Smocks.Smock.CreateAssemblyRewriter(Delegate delegate, Configuration configuration)
   at Smocks.Smock.RunAction(Action`1 action, Configuration configuration)
   at Smocks.Smock.Run(Configuration configuration, Action`1 action)
   at Smocks.Smock.Run(Action`1 action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant