diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs index adab6929c..869544225 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs @@ -133,6 +133,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } } + public object Item { + get { + return null; + } + set { + + } + } + #if ROSLYN public int NotAnAutoProperty => someField; #else diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il index bfdbee6f5..238852784 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il @@ -66,8 +66,8 @@ .event [mscorlib]System.Action Event { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event(class [mscorlib]System.Action) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event(class [mscorlib]System.Action) } // end of event IBase::Event .property instance int32 GetterOnly() { @@ -79,8 +79,8 @@ } // end of property IBase::SetterOnly .property instance int32 Test() { - .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test(int32) .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::get_Test() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test(int32) } // end of property IBase::Test } // end of class IBase @@ -109,8 +109,8 @@ .event [mscorlib]System.EventHandler ThisIsAnAbstractEvent { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/BaseClass::add_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/BaseClass::remove_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/BaseClass::add_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) } // end of event BaseClass::ThisIsAnAbstractEvent } // end of class BaseClass @@ -210,8 +210,8 @@ .event [mscorlib]System.EventHandler ThisIsAnAbstractEvent { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/OtherClass::remove_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/OtherClass::add_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/OtherClass::remove_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) } // end of event OtherClass::ThisIsAnAbstractEvent } // end of class OtherClass @@ -294,8 +294,8 @@ .event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) } // end of event ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() { @@ -449,8 +449,8 @@ .event [mscorlib]System.Action Event { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::add_Event(class [mscorlib]System.Action) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::remove_Event(class [mscorlib]System.Action) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::add_Event(class [mscorlib]System.Action) } // end of event Impl::Event .property instance int32 GetterOnly() { @@ -462,8 +462,8 @@ } // end of property Impl::SetterOnly .property instance int32 Test() { - .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::get_Test() .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::set_Test(int32) + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::get_Test() } // end of property Impl::Test } // end of class Impl @@ -496,8 +496,8 @@ } // end of event IChange::Changed .property instance int32 Property() { - .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IChange::get_Property() .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IChange::set_Property(int32) + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IChange::get_Property() } // end of property IChange::Property } // end of class IChange @@ -586,13 +586,13 @@ .event [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.add_Changed(class [mscorlib]System.EventHandler) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.remove_Changed(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.add_Changed(class [mscorlib]System.EventHandler) } // end of event Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property() { - .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.set_Property(int32) .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.get_Property() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.set_Property(int32) } // end of property Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property } // end of class Change @@ -644,6 +644,30 @@ IL_0008: ret } // end of method PropertiesAndEvents::set_Issue1221 + .method public hidebysig specialname instance object + get_Item() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method PropertiesAndEvents::get_Item + + .method public hidebysig specialname instance void + set_Item(object 'value') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method PropertiesAndEvents::set_Item + .method public hidebysig specialname instance int32 get_NotAnAutoProperty() cil managed { @@ -888,8 +912,8 @@ } // end of event PropertiesAndEvents::AutomaticEvent .event [mscorlib]System.EventHandler AutomaticEventWithInitializer { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::remove_AutomaticEventWithInitializer(class [mscorlib]System.EventHandler) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::add_AutomaticEventWithInitializer(class [mscorlib]System.EventHandler) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::remove_AutomaticEventWithInitializer(class [mscorlib]System.EventHandler) } // end of event PropertiesAndEvents::AutomaticEventWithInitializer .event [mscorlib]System.EventHandler CustomEvent { @@ -905,6 +929,11 @@ { .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object) } // end of property PropertiesAndEvents::Issue1221 + .property instance object Item() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_Item() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Item(object) + } // end of property PropertiesAndEvents::Item .property instance int32 NotAnAutoProperty() { .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il index aab998df8..40f54ec9d 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il @@ -66,8 +66,8 @@ .event [mscorlib]System.Action Event { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event(class [mscorlib]System.Action) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event(class [mscorlib]System.Action) } // end of event IBase::Event .property instance int32 GetterOnly() { @@ -79,8 +79,8 @@ } // end of property IBase::SetterOnly .property instance int32 Test() { - .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test(int32) .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::get_Test() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test(int32) } // end of property IBase::Test } // end of class IBase @@ -109,8 +109,8 @@ .event [mscorlib]System.EventHandler ThisIsAnAbstractEvent { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/BaseClass::add_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/BaseClass::remove_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/BaseClass::add_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) } // end of event BaseClass::ThisIsAnAbstractEvent } // end of class BaseClass @@ -198,8 +198,8 @@ .event [mscorlib]System.EventHandler ThisIsAnAbstractEvent { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/OtherClass::remove_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/OtherClass::add_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/OtherClass::remove_ThisIsAnAbstractEvent(class [mscorlib]System.EventHandler) } // end of event OtherClass::ThisIsAnAbstractEvent } // end of class OtherClass @@ -276,8 +276,8 @@ .event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) } // end of event ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() { @@ -415,8 +415,8 @@ .event [mscorlib]System.Action Event { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::add_Event(class [mscorlib]System.Action) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::remove_Event(class [mscorlib]System.Action) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::add_Event(class [mscorlib]System.Action) } // end of event Impl::Event .property instance int32 GetterOnly() { @@ -428,8 +428,8 @@ } // end of property Impl::SetterOnly .property instance int32 Test() { - .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::get_Test() .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::set_Test(int32) + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::get_Test() } // end of property Impl::Test } // end of class Impl @@ -462,8 +462,8 @@ } // end of event IChange::Changed .property instance int32 Property() { - .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IChange::get_Property() .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IChange::set_Property(int32) + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IChange::get_Property() } // end of property IChange::Property } // end of class IChange @@ -545,13 +545,13 @@ .event [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.add_Changed(class [mscorlib]System.EventHandler) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.remove_Changed(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.add_Changed(class [mscorlib]System.EventHandler) } // end of event Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property() { - .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.set_Property(int32) .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.get_Property() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.set_Property(int32) } // end of property Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property } // end of class Change @@ -597,6 +597,23 @@ IL_0007: ret } // end of method PropertiesAndEvents::set_Issue1221 + .method public hidebysig specialname instance object + get_Item() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method PropertiesAndEvents::get_Item + + .method public hidebysig specialname instance void + set_Item(object 'value') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method PropertiesAndEvents::set_Item + .method public hidebysig specialname instance int32 get_NotAnAutoProperty() cil managed { @@ -803,8 +820,8 @@ } // end of event PropertiesAndEvents::AutomaticEvent .event [mscorlib]System.EventHandler AutomaticEventWithInitializer { - .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::remove_AutomaticEventWithInitializer(class [mscorlib]System.EventHandler) .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::add_AutomaticEventWithInitializer(class [mscorlib]System.EventHandler) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::remove_AutomaticEventWithInitializer(class [mscorlib]System.EventHandler) } // end of event PropertiesAndEvents::AutomaticEventWithInitializer .event [mscorlib]System.EventHandler CustomEvent { @@ -820,6 +837,11 @@ { .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object) } // end of property PropertiesAndEvents::Issue1221 + .property instance object Item() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_Item() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Item(object) + } // end of property PropertiesAndEvents::Item .property instance int32 NotAnAutoProperty() { .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il index 24f71de03..0cbebfaef 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il @@ -576,7 +576,7 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c' '<>9' - .field public static class [mscorlib]System.EventHandler '<>9__26_0' + .field public static class [mscorlib]System.EventHandler '<>9__29_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -598,13 +598,13 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - '<.ctor>b__26_0'(object '', + '<.ctor>b__29_0'(object '', class [mscorlib]System.EventArgs '') cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret - } // end of method '<>c'::'<.ctor>b__26_0' + } // end of method '<>c'::'<.ctor>b__29_0' } // end of class '<>c' @@ -650,6 +650,23 @@ IL_0007: ret } // end of method PropertiesAndEvents::set_Issue1221 + .method public hidebysig specialname instance object + get_Item() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } // end of method PropertiesAndEvents::get_Item + + .method public hidebysig specialname instance void + set_Item(object 'value') cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method PropertiesAndEvents::set_Item + .method public hidebysig specialname instance int32 get_NotAnAutoProperty() cil managed { @@ -828,18 +845,18 @@ // Code size 44 (0x2c) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__26_0' + IL_0001: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__29_0' IL_0006: dup IL_0007: brtrue.s IL_0020 IL_0009: pop IL_000a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9' - IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<.ctor>b__26_0'(object, + IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<.ctor>b__29_0'(object, class [mscorlib]System.EventArgs) IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int) IL_001a: dup - IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__26_0' + IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__29_0' IL_0020: stfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::AutomaticEventWithInitializer IL_0025: ldarg.0 IL_0026: call instance void [mscorlib]System.Object::.ctor() @@ -870,6 +887,11 @@ { .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object) } // end of property PropertiesAndEvents::Issue1221 + .property instance object Item() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_Item() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Item(object) + } // end of property PropertiesAndEvents::Item .property instance int32 NotAnAutoProperty() { .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il index 2aba1c1c4..36217d3be 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il @@ -596,7 +596,7 @@ { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public static initonly class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c' '<>9' - .field public static class [mscorlib]System.EventHandler '<>9__26_0' + .field public static class [mscorlib]System.EventHandler '<>9__29_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -619,14 +619,14 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - '<.ctor>b__26_0'(object '', + '<.ctor>b__29_0'(object '', class [mscorlib]System.EventArgs '') cil managed { // Code size 2 (0x2) .maxstack 8 IL_0000: nop IL_0001: ret - } // end of method '<>c'::'<.ctor>b__26_0' + } // end of method '<>c'::'<.ctor>b__29_0' } // end of class '<>c' @@ -676,6 +676,30 @@ IL_0008: ret } // end of method PropertiesAndEvents::set_Issue1221 + .method public hidebysig specialname instance object + get_Item() cil managed + { + // Code size 7 (0x7) + .maxstack 1 + .locals init (object V_0) + IL_0000: nop + IL_0001: ldnull + IL_0002: stloc.0 + IL_0003: br.s IL_0005 + + IL_0005: ldloc.0 + IL_0006: ret + } // end of method PropertiesAndEvents::get_Item + + .method public hidebysig specialname instance void + set_Item(object 'value') cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method PropertiesAndEvents::set_Item + .method public hidebysig specialname instance int32 get_NotAnAutoProperty() cil managed { @@ -858,18 +882,18 @@ // Code size 45 (0x2d) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__26_0' + IL_0001: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__29_0' IL_0006: dup IL_0007: brtrue.s IL_0020 IL_0009: pop IL_000a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9' - IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<.ctor>b__26_0'(object, + IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<.ctor>b__29_0'(object, class [mscorlib]System.EventArgs) IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int) IL_001a: dup - IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__26_0' + IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__29_0' IL_0020: stfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::AutomaticEventWithInitializer IL_0025: ldarg.0 IL_0026: call instance void [mscorlib]System.Object::.ctor() @@ -901,6 +925,11 @@ { .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object) } // end of property PropertiesAndEvents::Issue1221 + .property instance object Item() + { + .get instance object ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_Item() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Item(object) + } // end of property PropertiesAndEvents::Item .property instance int32 NotAnAutoProperty() { .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs index a4dc29a22..3bfdce19d 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs @@ -54,7 +54,8 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation getter = module.GetDefinition(accessors.Getter); setter = module.GetDefinition(accessors.Setter); name = metadata.GetString(prop.Name); - if (name == (DeclaringTypeDefinition as MetadataTypeDefinition)?.DefaultMemberName) { + // Maybe we should defer the calculation of symbolKind? + if (DetermineIsIndexer(metadata, name, accessors)) { symbolKind = SymbolKind.Indexer; } else if (name.IndexOf('.') >= 0) { // explicit interface implementation @@ -65,6 +66,20 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation } } + bool DetermineIsIndexer(MetadataReader metadata, string name, PropertyAccessors accessors) + { + if (!accessors.Getter.IsNil) { + var md = metadata.GetMethodDefinition(accessors.Getter); + if (md.GetParameters().Count == 0) + return false; + } else if (!accessors.Setter.IsNil) { + var md = metadata.GetMethodDefinition(accessors.Setter); + if (md.GetParameters().Count <= 1) + return false; + } + return name == (DeclaringTypeDefinition as MetadataTypeDefinition)?.DefaultMemberName; + } + public override string ToString() { return $"{MetadataTokens.GetToken(propertyHandle):X8} {DeclaringType?.ReflectionName}.{Name}";