Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Explicit interface implementation issue #1682

Open
ahdung opened this issue Aug 31, 2019 · 7 comments
Open

[BUG] Explicit interface implementation issue #1682

ahdung opened this issue Aug 31, 2019 · 7 comments
Labels
C# Decompiler The decompiler engine itself Enhancement Areas for improvement

Comments

@ahdung
Copy link

ahdung commented Aug 31, 2019

Version: 5.0.0.4776-preview1

image

If you need this dll, I can provide.

@siegfriedpammer
Copy link
Member

Yes, please provide the DLL. Seems like there is something missing in the metadata tables.

Thank you!

@ahdung
Copy link
Author

ahdung commented Aug 31, 2019

I thank you, you sir are so great.

at DevComponents.DotNetBar.PanelEx last content.
FastReport.Bars.zip

@siegfriedpammer
Copy link
Member

Thank you very much!

It's just like I suspected: There is no info in the Property, PropertyMap and MethodSemantics tables for these methods. I think, the only thing we could do is strip invalid modifiers from the declarations when generating C# code.

@ahdung
Copy link
Author

ahdung commented Sep 2, 2019

@siegfriedpammer I think you can do more thing, like check it by Interface, Ixxx has Enabled property, class shouldn't has Ixxx.get_Enabled().

@siegfriedpammer siegfriedpammer added C# Decompiler The decompiler engine itself Enhancement Areas for improvement labels Sep 7, 2019
@yyjdelete
Copy link
Contributor

yyjdelete commented Dec 17, 2019

See an reproduce for this, and it can be generated with roslyn.
Seems roslyn will generated those proxy method for interface when

case 1: none of ancestor impl the interface, and the class(ClassA1A) and the ancestor(ClassA2A) which the impl methods come from different assembly.

case 2: the impl methods(ClassA1C or ClassA1D) is defined in subclass of first ancestor which impl the interface (ClassA1E) but not override(directly use newslot or override an newslot) the methods in it.

Not sure if there is any document for this, but if those generated methods is removed manually:
For case 1: get an System.TypeLoadException: Method "xxx" is not implemented for runtime, and Error: Class implements interface but not method, Class: '' Interface: '' Missing method for ILVerify.
And for case 2 matches the wrong method.

//In assembly1
    public class ClassA1A : ClassA2A, IA
    {
    }
    public class ClassA1B : ClassA1C, IA
    {
    }
    public class ClassA1C : ClassA1D
    {
        public new int A { get; set; } = 1;
    }
    public class ClassA1D : ClassA1E
    {
        public new void C() { Console.WriteLine("ClassA1D"); }
    }
    public class ClassA1E : IA
    {
        public int A { get; set; }
        public event Action B;//also for events
        public void C() { Console.WriteLine("ClassA1E"); }//normal methods still works
    }

    //In any assembly
    public interface IA
    {
        int A { get; set; }
        event Action B;
        void C();
    }

//In another assembly2
public class ClassA2A
{
    public int A { get; set; }
    public event Action B;
    public void C() { Console.WriteLine("A2A"); }
}

Updated:
This will also generate an proxy method if it's not virtual, and remove it lead to missing method.
https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQMwAICWA7ALgUwCcAzAQwGN90BJAYXQG9l0Ws90BZLgChzd3QB9AJQBuZAF9kadLHT0QNekyStZGHAK4de2fkOHoAvAD4h4pFNWsgA
Normal method works well, but it can also be an indexer property.

    public interface IC
    {
        int MMM(in int _);
    }
    public class C : IC
    {
        public int MMM(in int x) => x;
    }

@siegfriedpammer
Copy link
Member

Thank you very much for providing these reproduction steps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# Decompiler The decompiler engine itself Enhancement Areas for improvement
Projects
None yet
Development

No branches or pull requests

3 participants