KvanTTT / CSharp-Minifier

Library for C# code minification based on NRefactory. That is lib for spaces, line breaks, comments removing, reduction of identifiers name length and so on in C# code.
Apache License 2.0
41 stars 21 forks source link

Minifier removes overriden ToString() method #39

Open theCalcaholic opened 7 years ago

theCalcaholic commented 7 years ago

On classes which override the method ToString() inherited from object, this method gets removed completely. This might also be the case for other methods inherited from object (but I didn't test this).

Example:

    class Test {
      public override string ToString() {
        return "my test class";
      }
    }

results in:

class a{}

atifaziz commented 5 years ago

Removal of the ToString() method is an option:

https://github.com/KvanTTT/CSharp-Minifier/blob/887784c070e613f208e5e8b2952409077cb43110/CSharpMinifier/MinifyMembersAstVisitor.cs#L45-L53

If it's false, ToString() implementations in types should be preserved.

It's also an option in the GUI application:

image

When I un-check it, your example gets minified to:

class a{public override string ToString(){return "my test class";}}