Browse Source

Add regression test for property rows without accessors

Corrupt or hand-written metadata can contain a property with no
MethodSemantics rows at all. MetadataTypeDefinition.Properties already
skips properties with neither a visible getter nor setter, so neither
the parameterized-property path nor the ordinary one ever sees them;
the accessor-method emission also tolerates a missing accessor by
construction. Pin that with an ILPretty case containing both a
parameterized and an ordinary accessor-less property.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3925/head
Siegfried Pammer 2 months ago committed by Siegfried Pammer
parent
commit
c0aa2db0f8
  1. 3
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 6
      ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
  3. 9
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/NoAccessorProperties.cs
  4. 33
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/NoAccessorProperties.il

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

@ -158,6 +158,7 @@ @@ -158,6 +158,7 @@
<None Include="TestCases\Disassembler\Pretty\SecurityDeclarations.il" />
<None Include="TestCases\ILPretty\Issue1038.il" />
<None Include="TestCases\ILPretty\Issue1145.il" />
<None Include="TestCases\ILPretty\NoAccessorProperties.il" />
<None Include="TestCases\ILPretty\Issue1047.il" />
<None Include="TestCases\ILPretty\Issue959.il" />
</ItemGroup>
@ -202,6 +203,8 @@ @@ -202,6 +203,8 @@
<None Include="TestCases\ILPretty\FSharpUsing_Release.cs" />
<Compile Remove="TestCases\ILPretty\GuessAccessors.cs" />
<None Include="TestCases\ILPretty\GuessAccessors.cs" />
<Compile Remove="TestCases\ILPretty\NoAccessorProperties.cs" />
<None Include="TestCases\ILPretty\NoAccessorProperties.cs" />
<Compile Remove="TestCases\ILPretty\Issue1145.cs" />
<None Include="TestCases\ILPretty\Issue1145.cs" />
<Compile Remove="TestCases\ILPretty\Issue1325.cs" />

6
ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs

@ -159,6 +159,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -159,6 +159,12 @@ namespace ICSharpCode.Decompiler.Tests
await Run();
}
[Test]
public async Task NoAccessorProperties()
{
await Run();
}
[Test]
public async Task Issue1145()
{

9
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/NoAccessorProperties.cs

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
public class BrokenProperties
{
private int _field;
public int Touch(int i)
{
return _field + i;
}
}

33
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/NoAccessorProperties.il

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// Property rows without any MethodSemantics accessors (corrupt or hand-written
// metadata). The type system skips such properties, whether parameterized or not;
// decompilation must not crash on them.
.class public auto ansi beforefieldinit BrokenProperties extends [mscorlib]System.Object
{
.field private int32 _field
.property instance int32 Parameterized(int32)
{
} // end of property BrokenProperties::Parameterized
.property instance int32 Plain()
{
} // end of property BrokenProperties::Plain
.method public hidebysig instance int32 Touch (int32 i) cil managed
{
.maxstack 8
ldarg.0
ldfld int32 BrokenProperties::_field
ldarg.1
add
ret
} // end of method BrokenProperties::Touch
.method public hidebysig specialname rtspecialname instance void .ctor () cil managed
{
.maxstack 8
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
} // end of method BrokenProperties::.ctor
}
Loading…
Cancel
Save