Skip to content

Commit 4c08359

Browse files
committed
Support byreflike constraint
1 parent fccd9e2 commit 4c08359

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

ICSharpCode.Decompiler.Tests/DisassemblerPrettyTestRunner.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public void AllFilesHaveTests()
5252
}
5353
}
5454

55+
[Test]
56+
public async Task GenericConstraints()
57+
{
58+
await Run();
59+
}
60+
5561
[Test]
5662
public async Task SecurityDeclarations()
5763
{

ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<None Include="TestCases\Correctness\StackTests.il" />
9292
<None Include="TestCases\Correctness\StackTypes.il" />
9393
<None Include="TestCases\Correctness\Uninit.vb" />
94+
<None Include="TestCases\Disassembler\Pretty\GenericConstraints.il" />
9495
<None Include="TestCases\Disassembler\Pretty\InterfaceImplAttributes.il" />
9596
<None Include="TestCases\Disassembler\Pretty\SortMembers.expected.il" />
9697
<None Include="TestCases\Disassembler\Pretty\SortMembers.il" />
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.assembly extern mscorlib
2+
{
3+
.publickeytoken = (
4+
b7 7a 5c 56 19 34 e0 89
5+
)
6+
.ver 4:0:0:0
7+
}
8+
.assembly GenericConstraints
9+
{
10+
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = (
11+
01 00 07 31 2e 30 2e 30 2e 30 00 00
12+
)
13+
.hash algorithm 0x00008004 // SHA1
14+
.ver 1:0:0:0
15+
}
16+
17+
.module GenericConstraints.dll
18+
.imagebase 0x10000000
19+
.file alignment 0x00000200
20+
.stackreserve 0x00100000
21+
.subsystem 0x0003 // WindowsCui
22+
.corflags 0x00000001 // ILOnly
23+
24+
.class private auto ansi '<Module>'
25+
{
26+
} // end of class <Module>
27+
28+
.class public auto ansi beforefieldinit TestType`1<byreflike T>
29+
extends [mscorlib]System.Object
30+
{
31+
// Methods
32+
.method public hidebysig specialname rtspecialname
33+
instance void .ctor () cil managed
34+
{
35+
// Method begins at RVA 0x2050
36+
// Header size: 1
37+
// Code size: 7 (0x7)
38+
.maxstack 8
39+
40+
IL_0000: ldarg.0
41+
IL_0001: call instance void [mscorlib]System.Object::.ctor()
42+
IL_0006: ret
43+
} // end of method TestType::.ctor
44+
45+
} // end of class TestType

ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,11 @@ void WriteTypeParameters(ITextOutput output, MetadataFile module, MetadataGeneri
17331733
{
17341734
output.Write("valuetype ");
17351735
}
1736+
const GenericParameterAttributes allowByRefLike = (GenericParameterAttributes)0x0020;
1737+
if ((gp.Attributes & allowByRefLike) == allowByRefLike)
1738+
{
1739+
output.Write("byreflike ");
1740+
}
17361741
if ((gp.Attributes & GenericParameterAttributes.DefaultConstructorConstraint) == GenericParameterAttributes.DefaultConstructorConstraint)
17371742
{
17381743
output.Write(".ctor ");

0 commit comments

Comments
 (0)