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

Interfaces generated for classes with override or new methods contain duplicates #50

Closed
simonmckenzie opened this issue Jun 14, 2024 · 4 comments

Comments

@simonmckenzie
Copy link
Contributor

The current code will insert multiple definitions of a method when that method has been overridden or shadowed via new.

For example, given these two classes:

public class BaseClass
{
    public virtual bool AMethod();
}

[GenerateAutomaticInterface]
public class DemoClass : BaseClass
{
    public override bool AMethod() => return true;
}

The generated interface will look like this:

[GeneratedCode("AutomaticInterface", "")]
public partial interface IDemoClass
{
    /// <inheritdoc />
    bool AMethod();
        
    /// <inheritdoc />
    bool AMethod();
}
@simonmckenzie
Copy link
Contributor Author

Resolved by the merge of #51

@FinnAngelo
Copy link

FinnAngelo commented Aug 5, 2024

Hi all
FYI: it doesn't look like the fix is sticking - the error is still showing with this;

<PackageReference Include="AutomaticInterface" Version="2.5.0">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
file class GenerateAutomaticInterface : Attribute;

[GenerateAutomaticInterface]
file class MyButton : System.Windows.Forms.Button;


// OR
[GenerateAutomaticInterface]
file class MyButton : System.Windows.Forms.Button
{
    // This gives **2** instances of the error
    public new event System.EventHandler? ImeModeChanged;
}

I really like the package though - thanks for your work so far!

@simonmckenzie
Copy link
Contributor Author

simonmckenzie commented Aug 5, 2024

HI @FinnAngelo,

My fix was only for methods. It looks like we'll need another issue for events 🤦

Would you be interested in doing this? It'll be much the same as in this PR: #33

If not, I can have a look later in the week.

@FinnAngelo
Copy link

Hi @simonmckenzie - I wont be able to start till this weekend (Sat 10 Aug) but yeah, sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants