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

Exception when minifying file containing nested classes with same inner name #27

Closed ghost closed 7 years ago

ghost commented 8 years ago

Exception is thrown in MinifyLocalsAstVisitor.VisitMember when the code to minify contains nested static classes, where an inner class has the same name as another in a different enclosing class.

MWE:

public static class A
{
    public static class One
    {
        public void foo() {}
    }
}

public static class B
{
    public static class One
    {
        public void foo() {}
    }
}
KvanTTT commented 8 years ago

@ThePadawan ok, I'll look at it. Is it critical for you, are you using this library?

ghost commented 8 years ago

Not critical at all :). Was just playing around with the minifier.

theCalcaholic commented 7 years ago

I think I encounter the same bug. Can I help somehow to track it down? Here's the Stacktrace:

EDIT: It seems to be something else. I'll keep that stacktrace here until I know enough to make a proper bug report.

minifier_stacktrace.txt

Until then I'll collect some details here for myself:

  1. "Compress members" breaks interfaces (does not recognize that their members are public without modifier).
  2. "Compress members" breaks inheritance with protected members (parent class protected members are being renamed, child class protected (overriding) members arent).
  3. "Compress misc" removes necessary empty string assignment (once).
  4. "Enum to int conversion" for some reasons breaks nested Dictionary of the form Dictionary<int, Dictionary<char, int>>.
  5. "Enum to int conversion" occasionally removes enum completely.