Skip to content

Commit

Permalink
Add missing NoInlining to new DetourExtTest struct-related additions
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ade committed Dec 13, 2021
1 parent 1eeb605 commit ede81f4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions MonoMod.UnitTest/RuntimeDetour/DetourExtTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ public void TestDetoursExt() {
// It should be preferably tested on x86, as it's where the struct size caused problems.
#if true
Assert.Equal(new TwoInts() {
A = 0x11111111,
B = 0x22222222
A = 11111111,
B = 22222222
}, DummyTwoInts());

using (Hook h = new Hook(
Expand All @@ -271,14 +271,14 @@ public void TestDetoursExt() {
})
)) {
Assert.Equal(new TwoInts() {
A = 0x11111111 * 2,
B = 0x22222222 * 3
A = 11111111 * 2,
B = 22222222 * 3
}, DummyTwoInts());
}

Assert.Equal(new TwoInts() {
A = 0x11111111,
B = 0x22222222
A = 11111111,
B = 22222222
}, DummyTwoInts());
#endif

Expand Down Expand Up @@ -331,10 +331,10 @@ public void TestDetoursExt() {
// It should be preferably tested on x86, as it's where the edge case with this certain return size occurred.
#if true
Assert.Equal(
0x11111111,
11111111,
new TwoInts() {
A = 0x11111111,
B = 0x22222222
A = 11111111,
B = 22222222
}.Magic
);

Expand All @@ -347,19 +347,19 @@ public void TestDetoursExt() {
})
)) {
Assert.Equal(
0x11111111 * 2 + 0x22222222,
11111111 * 2 + 22222222,
new TwoInts() {
A = 0x11111111,
B = 0x22222222
A = 11111111,
B = 22222222
}.Magic
);
}

Assert.Equal(
0x11111111,
11111111,
new TwoInts() {
A = 0x11111111,
B = 0x22222222
A = 11111111,
B = 22222222
}.Magic
);
#endif
Expand Down Expand Up @@ -399,19 +399,21 @@ public struct TwoInts {
public int A;
public int B;
public int Magic {
[MethodImpl(MethodImplOptions.NoInlining)]
get {
return A;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public override string ToString()
=> $"({A}, {B})";
}

[MethodImpl(MethodImplOptions.NoInlining)]
private TwoInts DummyTwoInts() {
return new TwoInts() {
A = 0x11111111,
B = 0x22222222
A = 11111111,
B = 22222222
};
}

Expand Down

0 comments on commit ede81f4

Please sign in to comment.