From 6c414cedd346204907b3ef1db959c157f26f8922 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 29 Sep 2017 10:38:29 +0200 Subject: [PATCH] Fix #883: Incorrect decompilation of explicitly implemented events --- .../TestCases/Pretty/PropertiesAndEvents.cs | 28 ++++ .../TestCases/Pretty/PropertiesAndEvents.il | 113 ++++++++++++++++- .../Pretty/PropertiesAndEvents.opt.il | 109 +++++++++++++++- .../Pretty/PropertiesAndEvents.opt.roslyn.il | 115 +++++++++++++++-- .../Pretty/PropertiesAndEvents.roslyn.il | 120 ++++++++++++++++-- .../CSharp/Syntax/TypeSystemAstBuilder.cs | 1 + 6 files changed, 458 insertions(+), 28 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs index 61fa8a7f0..e08a8b8fd 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.cs @@ -4,6 +4,34 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { internal class PropertiesAndEvents { + private interface IBase + { + int Test { + get; + set; + } + + event Action Event; + } + + private class Impl : IBase + { + int IBase.Test { + get { + throw new NotImplementedException(); + } + set { + } + } + + event Action IBase.Event { + add { + } + remove { + } + } + } + public int Value { get; private set; diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il index b13e4d04e..d39f70d58 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.il @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly rxpttcc3 +.assembly l2f5cj2d { .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module rxpttcc3.dll -// MVID: {1FF2BE16-6925-4D61-92AB-530ECA34D69F} +.module l2f5cj2d.dll +// MVID: {B40A9FBE-DEAE-43DA-970B-68C48E122E20} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x01200000 +// Image base: 0x00DC0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -36,6 +36,107 @@ .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents extends [mscorlib]System.Object { + .class interface abstract auto ansi nested private IBase + { + .method public hidebysig newslot specialname abstract virtual + instance void add_Event(class [mscorlib]System.Action 'value') cil managed + { + } // end of method IBase::add_Event + + .method public hidebysig newslot specialname abstract virtual + instance void remove_Event(class [mscorlib]System.Action 'value') cil managed + { + } // end of method IBase::remove_Event + + .method public hidebysig newslot specialname abstract virtual + instance int32 get_Test() cil managed + { + } // end of method IBase::get_Test + + .method public hidebysig newslot specialname abstract virtual + instance void set_Test(int32 'value') cil managed + { + } // end of method IBase::set_Test + + .event [mscorlib]System.Action Event + { + .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 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() + } // end of property IBase::Test + } // end of class IBase + + .class auto ansi nested private beforefieldinit Impl + extends [mscorlib]System.Object + implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase + { + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::add_Event + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event + + .method private hidebysig newslot specialname virtual final + instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::get_Test + // Code size 7 (0x7) + .maxstack 8 + IL_0000: nop + IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor() + IL_0006: throw + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method Impl::.ctor + + .event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + { + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) + } // end of event Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32) + } // end of property Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test + } // end of class Impl + .field private class [mscorlib]System.EventHandler AutomaticEvent .field private notserialized class [mscorlib]System.EventHandler AutomaticEventWithInitializer .field private int32 'k__BackingField' @@ -303,13 +404,13 @@ } // end of event PropertiesAndEvents::AutomaticEventWithInitializer .event [mscorlib]System.EventHandler CustomEvent { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::add_CustomEvent(class [mscorlib]System.EventHandler) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::remove_CustomEvent(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::add_CustomEvent(class [mscorlib]System.EventHandler) } // end of event PropertiesAndEvents::CustomEvent .property instance int32 Value() { - .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Value(int32) .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_Value() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Value(int32) } // end of property PropertiesAndEvents::Value } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il index 54bd4b723..340d81bc0 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.il @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly izb3o5sr +.assembly sagvhpmx { .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module izb3o5sr.dll -// MVID: {8A2B95C7-4655-426C-A216-92C7BBB9D7D5} +.module sagvhpmx.dll +// MVID: {01D434AD-9489-4A19-81AE-3BC2177A09C3} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x00DE0000 +// Image base: 0x02850000 // =============== CLASS MEMBERS DECLARATION =================== @@ -36,6 +36,103 @@ .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents extends [mscorlib]System.Object { + .class interface abstract auto ansi nested private IBase + { + .method public hidebysig newslot specialname abstract virtual + instance void add_Event(class [mscorlib]System.Action 'value') cil managed + { + } // end of method IBase::add_Event + + .method public hidebysig newslot specialname abstract virtual + instance void remove_Event(class [mscorlib]System.Action 'value') cil managed + { + } // end of method IBase::remove_Event + + .method public hidebysig newslot specialname abstract virtual + instance int32 get_Test() cil managed + { + } // end of method IBase::get_Test + + .method public hidebysig newslot specialname abstract virtual + instance void set_Test(int32 'value') cil managed + { + } // end of method IBase::set_Test + + .event [mscorlib]System.Action Event + { + .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 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() + } // end of property IBase::Test + } // end of class IBase + + .class auto ansi nested private beforefieldinit Impl + extends [mscorlib]System.Object + implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase + { + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::add_Event + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event + + .method private hidebysig newslot specialname virtual final + instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::get_Test + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor() + IL_0005: throw + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method Impl::.ctor + + .event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + { + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) + } // end of event Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32) + } // end of property Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test + } // end of class Impl + .field private class [mscorlib]System.EventHandler AutomaticEvent .field private notserialized class [mscorlib]System.EventHandler AutomaticEventWithInitializer .field private int32 'k__BackingField' @@ -266,13 +363,13 @@ } // end of event PropertiesAndEvents::AutomaticEventWithInitializer .event [mscorlib]System.EventHandler CustomEvent { - .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::add_CustomEvent(class [mscorlib]System.EventHandler) .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::remove_CustomEvent(class [mscorlib]System.EventHandler) + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::add_CustomEvent(class [mscorlib]System.EventHandler) } // end of event PropertiesAndEvents::CustomEvent .property instance int32 Value() { - .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Value(int32) .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::get_Value() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents::set_Value(int32) } // end of property PropertiesAndEvents::Value } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il index 7bc345323..cacb2f6b7 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.opt.roslyn.il @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module PropertiesAndEvents.dll -// MVID: {10E5705F-7F26-4317-B44C-F957A4E21EAC} +// MVID: {E5CF30AD-E357-4D3A-A4A6-85702FD6B2F0} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x015B0000 +// Image base: 0x00DE0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -40,12 +40,111 @@ .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents extends [mscorlib]System.Object { + .class interface abstract auto ansi nested private IBase + { + .method public hidebysig newslot specialname abstract virtual + instance void add_Event(class [mscorlib]System.Action 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + } // end of method IBase::add_Event + + .method public hidebysig newslot specialname abstract virtual + instance void remove_Event(class [mscorlib]System.Action 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + } // end of method IBase::remove_Event + + .method public hidebysig newslot specialname abstract virtual + instance int32 get_Test() cil managed + { + } // end of method IBase::get_Test + + .method public hidebysig newslot specialname abstract virtual + instance void set_Test(int32 'value') cil managed + { + } // end of method IBase::set_Test + + .event [mscorlib]System.Action Event + { + .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 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 class IBase + + .class auto ansi nested private beforefieldinit Impl + extends [mscorlib]System.Object + implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase + { + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::add_Event + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event + + .method private hidebysig newslot specialname virtual final + instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::get_Test + // Code size 6 (0x6) + .maxstack 8 + IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor() + IL_0005: throw + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method Impl::.ctor + + .event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + { + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) + } // end of event Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32) + } // end of property Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test + } // end of class Impl + .class auto ansi serializable sealed nested private beforefieldinit '<>c' extends [mscorlib]System.Object { .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__13_0' + .field public static class [mscorlib]System.EventHandler '<>9__15_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -67,13 +166,13 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - '<.ctor>b__13_0'(object sender, + '<.ctor>b__15_0'(object sender, class [mscorlib]System.EventArgs e) cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret - } // end of method '<>c'::'<.ctor>b__13_0' + } // end of method '<>c'::'<.ctor>b__15_0' } // end of class '<>c' @@ -274,18 +373,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__13_0' + IL_0001: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__15_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__13_0'(object, + IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<.ctor>b__15_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__13_0' + IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__15_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() diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il index 86cc68fa8..c6cfd7dc9 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/PropertiesAndEvents.roslyn.il @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module PropertiesAndEvents.dll -// MVID: {978432C8-A999-48CF-A173-68805B029A1E} +// MVID: {5C49D703-0238-402E-BAF9-EBBFECDA8E13} .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .imagebase 0x10000000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x00E70000 +// Image base: 0x02A60000 // =============== CLASS MEMBERS DECLARATION =================== @@ -40,12 +40,116 @@ .class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents extends [mscorlib]System.Object { + .class interface abstract auto ansi nested private IBase + { + .method public hidebysig newslot specialname abstract virtual + instance void add_Event(class [mscorlib]System.Action 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + } // end of method IBase::add_Event + + .method public hidebysig newslot specialname abstract virtual + instance void remove_Event(class [mscorlib]System.Action 'value') cil managed + { + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + } // end of method IBase::remove_Event + + .method public hidebysig newslot specialname abstract virtual + instance int32 get_Test() cil managed + { + } // end of method IBase::get_Test + + .method public hidebysig newslot specialname abstract virtual + instance void set_Test(int32 'value') cil managed + { + } // end of method IBase::set_Test + + .event [mscorlib]System.Action Event + { + .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 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 class IBase + + .class auto ansi nested private beforefieldinit Impl + extends [mscorlib]System.Object + implements ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase + { + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::add_Event + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::remove_Event + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event + + .method private hidebysig newslot specialname virtual final + instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::get_Test + // Code size 7 (0x7) + .maxstack 8 + IL_0000: nop + IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor() + IL_0006: throw + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test + + .method private hidebysig newslot specialname virtual final + instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32 'value') cil managed + { + .override ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/IBase::set_Test + // Code size 2 (0x2) + .maxstack 8 + IL_0000: nop + IL_0001: ret + } // end of method Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method Impl::.ctor + + .event [mscorlib]System.Action ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + { + .addon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.add_Event(class [mscorlib]System.Action) + .removeon instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.remove_Event(class [mscorlib]System.Action) + } // end of event Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Event + .property instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test() + { + .get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.get_Test() + .set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.set_Test(int32) + } // end of property Impl::ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents.IBase.Test + } // end of class Impl + .class auto ansi serializable sealed nested private beforefieldinit '<>c' extends [mscorlib]System.Object { .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__13_0' + .field public static class [mscorlib]System.EventHandler '<>9__15_0' .method private hidebysig specialname rtspecialname static void .cctor() cil managed { @@ -68,14 +172,14 @@ } // end of method '<>c'::.ctor .method assembly hidebysig instance void - '<.ctor>b__13_0'(object sender, + '<.ctor>b__15_0'(object sender, class [mscorlib]System.EventArgs e) cil managed { // Code size 2 (0x2) .maxstack 8 IL_0000: nop IL_0001: ret - } // end of method '<>c'::'<.ctor>b__13_0' + } // end of method '<>c'::'<.ctor>b__15_0' } // end of class '<>c' @@ -283,18 +387,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__13_0' + IL_0001: ldsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__15_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__13_0'(object, + IL_000f: ldftn instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<.ctor>b__15_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__13_0' + IL_001b: stsfld class [mscorlib]System.EventHandler ICSharpCode.Decompiler.Tests.TestCases.Pretty.PropertiesAndEvents/'<>c'::'<>9__15_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() diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index 44e17f571..abf709ad7 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -934,6 +934,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax decl.Name = ev.Name; decl.AddAccessor = ConvertAccessor(ev.AddAccessor, ev.Accessibility, true); decl.RemoveAccessor = ConvertAccessor(ev.RemoveAccessor, ev.Accessibility, true); + decl.PrivateImplementationType = GetExplicitInterfaceType (ev); return decl; } else { EventDeclaration decl = new EventDeclaration();