Browse Source

Fix #1220: Auto Property named 'Item' decompiled as an invalid indexer

pull/1420/head
Siegfried Pammer 8 years ago
parent
commit
39a9efde29
  1. 9
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs
  2. 51
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il
  3. 44
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il
  4. 34
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il
  5. 41
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il
  6. 17
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs

9
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 #if ROSLYN
public int NotAnAutoProperty => someField; public int NotAnAutoProperty => someField;
#else #else

51
ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il

@ -66,8 +66,8 @@
.event [mscorlib]System.Action Event .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) .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 } // end of event IBase::Event
.property instance int32 GetterOnly() .property instance int32 GetterOnly()
{ {
@ -79,8 +79,8 @@
} // end of property IBase::SetterOnly } // end of property IBase::SetterOnly
.property instance int32 Test() .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() .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 property IBase::Test
} // end of class IBase } // end of class IBase
@ -109,8 +109,8 @@
.event [mscorlib]System.EventHandler ThisIsAnAbstractEvent .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) .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 event BaseClass::ThisIsAnAbstractEvent
} // end of class BaseClass } // end of class BaseClass
@ -210,8 +210,8 @@
.event [mscorlib]System.EventHandler ThisIsAnAbstractEvent .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) .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 event OtherClass::ThisIsAnAbstractEvent
} // end of class OtherClass } // end of class OtherClass
@ -294,8 +294,8 @@
.event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event .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) .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 } // end of event ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event
.property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test()
{ {
@ -449,8 +449,8 @@
.event [mscorlib]System.Action Event .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) .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 } // end of event Impl::Event
.property instance int32 GetterOnly() .property instance int32 GetterOnly()
{ {
@ -462,8 +462,8 @@
} // end of property Impl::SetterOnly } // end of property Impl::SetterOnly
.property instance int32 Test() .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) .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 property Impl::Test
} // end of class Impl } // end of class Impl
@ -496,8 +496,8 @@
} // end of event IChange::Changed } // end of event IChange::Changed
.property instance int32 Property() .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) .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 property IChange::Property
} // end of class IChange } // end of class IChange
@ -586,13 +586,13 @@
.event [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed .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) .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 } // end of event Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed
.property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property() .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() .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 property Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property
} // end of class Change } // end of class Change
@ -644,6 +644,30 @@
IL_0008: ret IL_0008: ret
} // end of method PropertiesAndEvents::set_Issue1221 } // 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 .method public hidebysig specialname instance int32
get_NotAnAutoProperty() cil managed get_NotAnAutoProperty() cil managed
{ {
@ -888,8 +912,8 @@
} // end of event PropertiesAndEvents::AutomaticEvent } // end of event PropertiesAndEvents::AutomaticEvent
.event [mscorlib]System.EventHandler AutomaticEventWithInitializer .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) .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 } // end of event PropertiesAndEvents::AutomaticEventWithInitializer
.event [mscorlib]System.EventHandler CustomEvent .event [mscorlib]System.EventHandler CustomEvent
{ {
@ -905,6 +929,11 @@
{ {
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object) .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object)
} // end of property PropertiesAndEvents::Issue1221 } // 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() .property instance int32 NotAnAutoProperty()
{ {
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty()

44
ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il

@ -66,8 +66,8 @@
.event [mscorlib]System.Action Event .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) .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 } // end of event IBase::Event
.property instance int32 GetterOnly() .property instance int32 GetterOnly()
{ {
@ -79,8 +79,8 @@
} // end of property IBase::SetterOnly } // end of property IBase::SetterOnly
.property instance int32 Test() .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() .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 property IBase::Test
} // end of class IBase } // end of class IBase
@ -109,8 +109,8 @@
.event [mscorlib]System.EventHandler ThisIsAnAbstractEvent .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) .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 event BaseClass::ThisIsAnAbstractEvent
} // end of class BaseClass } // end of class BaseClass
@ -198,8 +198,8 @@
.event [mscorlib]System.EventHandler ThisIsAnAbstractEvent .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) .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 event OtherClass::ThisIsAnAbstractEvent
} // end of class OtherClass } // end of class OtherClass
@ -276,8 +276,8 @@
.event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event .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) .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 } // end of event ExplicitImpl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event
.property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test()
{ {
@ -415,8 +415,8 @@
.event [mscorlib]System.Action Event .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) .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 } // end of event Impl::Event
.property instance int32 GetterOnly() .property instance int32 GetterOnly()
{ {
@ -428,8 +428,8 @@
} // end of property Impl::SetterOnly } // end of property Impl::SetterOnly
.property instance int32 Test() .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) .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 property Impl::Test
} // end of class Impl } // end of class Impl
@ -462,8 +462,8 @@
} // end of event IChange::Changed } // end of event IChange::Changed
.property instance int32 Property() .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) .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 property IChange::Property
} // end of class IChange } // end of class IChange
@ -545,13 +545,13 @@
.event [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed .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) .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 } // end of event Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Changed
.property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property() .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() .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 property Change::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IChange.Property
} // end of class Change } // end of class Change
@ -597,6 +597,23 @@
IL_0007: ret IL_0007: ret
} // end of method PropertiesAndEvents::set_Issue1221 } // 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 .method public hidebysig specialname instance int32
get_NotAnAutoProperty() cil managed get_NotAnAutoProperty() cil managed
{ {
@ -803,8 +820,8 @@
} // end of event PropertiesAndEvents::AutomaticEvent } // end of event PropertiesAndEvents::AutomaticEvent
.event [mscorlib]System.EventHandler AutomaticEventWithInitializer .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) .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 } // end of event PropertiesAndEvents::AutomaticEventWithInitializer
.event [mscorlib]System.EventHandler CustomEvent .event [mscorlib]System.EventHandler CustomEvent
{ {
@ -820,6 +837,11 @@
{ {
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object) .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object)
} // end of property PropertiesAndEvents::Issue1221 } // 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() .property instance int32 NotAnAutoProperty()
{ {
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty()

34
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 ) .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 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 .method private hidebysig specialname rtspecialname static
void .cctor() cil managed void .cctor() cil managed
{ {
@ -598,13 +598,13 @@
} // end of method '<>c'::.ctor } // end of method '<>c'::.ctor
.method assembly hidebysig instance void .method assembly hidebysig instance void
'<.ctor>b__26_0'(object '<p0>', '<.ctor>b__29_0'(object '<p0>',
class [mscorlib]System.EventArgs '<p1>') cil managed class [mscorlib]System.EventArgs '<p1>') cil managed
{ {
// Code size 1 (0x1) // Code size 1 (0x1)
.maxstack 8 .maxstack 8
IL_0000: ret IL_0000: ret
} // end of method '<>c'::'<.ctor>b__26_0' } // end of method '<>c'::'<.ctor>b__29_0'
} // end of class '<>c' } // end of class '<>c'
@ -650,6 +650,23 @@
IL_0007: ret IL_0007: ret
} // end of method PropertiesAndEvents::set_Issue1221 } // 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 .method public hidebysig specialname instance int32
get_NotAnAutoProperty() cil managed get_NotAnAutoProperty() cil managed
{ {
@ -828,18 +845,18 @@
// Code size 44 (0x2c) // Code size 44 (0x2c)
.maxstack 8 .maxstack 8
IL_0000: ldarg.0 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_0006: dup
IL_0007: brtrue.s IL_0020 IL_0007: brtrue.s IL_0020
IL_0009: pop IL_0009: pop
IL_000a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9' 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) class [mscorlib]System.EventArgs)
IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object, IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int) native int)
IL_001a: dup 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_0020: stfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::AutomaticEventWithInitializer
IL_0025: ldarg.0 IL_0025: ldarg.0
IL_0026: call instance void [mscorlib]System.Object::.ctor() 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) .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object)
} // end of property PropertiesAndEvents::Issue1221 } // 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() .property instance int32 NotAnAutoProperty()
{ {
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty()

41
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 ) .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 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 .method private hidebysig specialname rtspecialname static
void .cctor() cil managed void .cctor() cil managed
{ {
@ -619,14 +619,14 @@
} // end of method '<>c'::.ctor } // end of method '<>c'::.ctor
.method assembly hidebysig instance void .method assembly hidebysig instance void
'<.ctor>b__26_0'(object '<p0>', '<.ctor>b__29_0'(object '<p0>',
class [mscorlib]System.EventArgs '<p1>') cil managed class [mscorlib]System.EventArgs '<p1>') cil managed
{ {
// Code size 2 (0x2) // Code size 2 (0x2)
.maxstack 8 .maxstack 8
IL_0000: nop IL_0000: nop
IL_0001: ret IL_0001: ret
} // end of method '<>c'::'<.ctor>b__26_0' } // end of method '<>c'::'<.ctor>b__29_0'
} // end of class '<>c' } // end of class '<>c'
@ -676,6 +676,30 @@
IL_0008: ret IL_0008: ret
} // end of method PropertiesAndEvents::set_Issue1221 } // 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 .method public hidebysig specialname instance int32
get_NotAnAutoProperty() cil managed get_NotAnAutoProperty() cil managed
{ {
@ -858,18 +882,18 @@
// Code size 45 (0x2d) // Code size 45 (0x2d)
.maxstack 8 .maxstack 8
IL_0000: ldarg.0 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_0006: dup
IL_0007: brtrue.s IL_0020 IL_0007: brtrue.s IL_0020
IL_0009: pop IL_0009: pop
IL_000a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c' ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9' 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) class [mscorlib]System.EventArgs)
IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object, IL_0015: newobj instance void [mscorlib]System.EventHandler::.ctor(object,
native int) native int)
IL_001a: dup 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_0020: stfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::AutomaticEventWithInitializer
IL_0025: ldarg.0 IL_0025: ldarg.0
IL_0026: call instance void [mscorlib]System.Object::.ctor() 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) .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Issue1221(object)
} // end of property PropertiesAndEvents::Issue1221 } // 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() .property instance int32 NotAnAutoProperty()
{ {
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty() .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_NotAnAutoProperty()

17
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs

@ -54,7 +54,8 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
getter = module.GetDefinition(accessors.Getter); getter = module.GetDefinition(accessors.Getter);
setter = module.GetDefinition(accessors.Setter); setter = module.GetDefinition(accessors.Setter);
name = metadata.GetString(prop.Name); 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; symbolKind = SymbolKind.Indexer;
} else if (name.IndexOf('.') >= 0) { } else if (name.IndexOf('.') >= 0) {
// explicit interface implementation // 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() public override string ToString()
{ {
return $"{MetadataTokens.GetToken(propertyHandle):X8} {DeclaringType?.ReflectionName}.{Name}"; return $"{MetadataTokens.GetToken(propertyHandle):X8} {DeclaringType?.ReflectionName}.{Name}";

Loading…
Cancel
Save