malforge / mdk2

MIT License
73 stars 5 forks source link

Full minifier fails with error "error CS0115: 'O.u()': no suitable method found to override" #36

Closed irreality-net closed 2 months ago

irreality-net commented 2 months ago

The problem occurs with two-levels of method overriding when overriding method of standard .NET class. The base class overrides "ToString()" method and also descendent class overrides it as well. In the descendent class the "ToString()" method is replaced with symbol by minifier.

Signatures of methods for base class before minification (omitted body for clarity):

internal class Menu
{
  public override string ToString() {}

  public virtual void Up() {}

  public virtual void Down() {}

  public virtual void Apply() {}

  public virtual void Cancel() {}
}

Signatures of methods in descendent class:

internal class RemoteMenu : Menu
{
  public override string ToString() { }

  public override void Up() {}

  public override void Down() {}

  public override void Apply() {}
}

Minified code in 'obj\intermediate-script.SymbolRenamer.cs' (also 'obj\intermediate-script.WhitespaceTrimmer.cs):

Base class (correct):

internal class K
{
  public override string ToString() {}

  public virtual void ñ() {}

  public virtual void ò() {}

  public virtual void ó() {}

  public virtual void Z() {}
}

Descendent class (incorrect - the "ToString()" method is replaced by "ų()"):

internal class O : K
{
  public override string ų() {}

  public override void ñ() {}

  public override void ò()

  public override void ó()
}
malware-dev commented 2 months ago

Perfect example. Thank you.

malware-dev commented 2 months ago

@irreality-net Are you sure you're using the newest nuget packages? Because your test doesn't fail for me.

Never mind, figured it out

malware-dev commented 2 months ago

Version 2.0.8 fixes this issue.

irreality-net commented 2 months ago

@malware-dev Tested on full project. Works perfect now. Thank you very much!