public static void Validate_InvalidOpCode_Scenarios() { Console.WriteLine($"{nameof(Validate_InvalidOpCode_Scenarios)}..."); // These methods uses opcodes that are not able to handle ByRefLike type operands. // The TypeLoader prevents these invalid types from being constructed. We rely on // the failure to construct these invalid types to block opcode usage. Assert.Throws <TypeLoadException>(() => { Exec.AllocArrayOfT_Invalid(); }); Assert.Throws <TypeLoadException>(() => { Exec.AllocMultiDimArrayOfT_Invalid(); }); Assert.Throws <TypeLoadException>(() => { Exec.GenericClassWithStaticField_Invalid(); }); // Test that explicitly tries to box a ByRefLike type. Assert.Throws <InvalidProgramException>(() => { Exec.BoxAsObject(); }); }