-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from MonoMod/byreflike-sizeof
Properly support Extensions.GetManagedSize() for byreflike types
Showing
5 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using MonoMod.Utils; | ||
using System; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace MonoMod.UnitTest | ||
{ | ||
public unsafe class SizeofByRefLikeTest : TestBase | ||
{ | ||
public SizeofByRefLikeTest(ITestOutputHelper helper) : base(helper) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[InlineData(typeof(int))] | ||
[InlineData(typeof(string))] | ||
[InlineData(typeof(SizeofByRefLikeTest))] | ||
[InlineData(typeof(ReadOnlySpan<char>))] | ||
[InlineData(typeof(ReadOnlyMemory<char>))] | ||
[InlineData(typeof(Span<byte>))] | ||
[InlineData(typeof(void*))] | ||
[InlineData(typeof(int*))] | ||
[InlineData(typeof(int), true)] | ||
[InlineData(typeof(string), true)] | ||
[InlineData(typeof(object), true)] | ||
public void SizeofDoesNotThrow(Type t, bool byref = false) | ||
{ | ||
if (byref) | ||
{ | ||
t = t.MakeByRefType(); | ||
} | ||
_ = t.GetManagedSize(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters