Browse Source

Add test for indexer initializers

pull/2792/head
Standa Lukeš 3 years ago
parent
commit
6153f9cf35
No known key found for this signature in database
GPG Key ID: DEDDF275FAB0910F
  1. 9
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.cs
  2. 22
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.il
  3. 2
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs

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

@ -97,6 +97,15 @@ namespace ClassLibrary1 @@ -97,6 +97,15 @@ namespace ClassLibrary1
UnknownStaticGenericClass<string>.OnEvent -= Instance_OnEvent;
}
public void MethodUnknownIndexerInitializer()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
new UnknownClass {
["a"] = 1,
["b"] = 2
};
}
private void Instance_OnEvent(object sender, EventArgs e)
{
throw new NotImplementedException();

22
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/GuessAccessors.il

@ -378,6 +378,28 @@ @@ -378,6 +378,28 @@
IL_0098: ret
} // end of method UnknownClassTest::MethodUnknownStaticGeneric
.method public hidebysig
instance void MethodUnknownIndexerInitializer () cil managed
{
// Method begins at RVA 0x2050
// Code size 32 (0x20)
.maxstack 8
IL_0000: nop
IL_0001: newobj instance void [UnknownAssembly]UnknownNamespace.UnknownClass::.ctor()
IL_0006: dup
IL_0007: ldstr "a"
IL_000c: ldc.i4.1
IL_000d: callvirt instance void [UnknownAssembly]UnknownNamespace.UnknownClass::set_Item(string, int32)
IL_0012: nop
IL_0013: ldstr "b"
IL_0018: ldc.i4.2
IL_0019: callvirt instance void [UnknownAssembly]UnknownNamespace.UnknownClass::set_Item(string, int32)
IL_001e: nop
IL_001f: ret
} // end of method C::MethodUnknownIndexerInitializer
.method /* 100663301 */ private hidebysig
instance void Instance_OnEvent (
object sender,

2
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -539,6 +539,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -539,6 +539,8 @@ namespace ICSharpCode.Decompiler.CSharp
public ExpressionWithResolveResult BuildDictionaryInitializerExpression(OpCode callOpCode, IMethod method,
InitializedObjectResolveResult target, IReadOnlyList<ILInstruction> indices, ILInstruction value = null)
{
if (method is null)
throw new ArgumentNullException(nameof(method));
ExpectedTargetDetails expectedTargetDetails = new ExpectedTargetDetails { CallOpCode = callOpCode };
var callArguments = new List<ILInstruction>();

Loading…
Cancel
Save