yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.56k stars 1.61k forks source link

NotSupportedException in IsPublicFunction.Evaluate #98

Closed bignoncedric closed 9 years ago

bignoncedric commented 9 years ago

When using the is-public() function to disable renaming on public elements of an Application, it fails on the following class:

public class MyClass
{
    public delegate void MyDelegate();

    public class MyNestedClass
    {
    }
}

with the log:

[ERROR] Unknown error occurred.
Exception: System.NotSupportedException: Specified method is not supported.
   at Confuser.Core.Project.Patterns.IsPublicFunction.Evaluate(IDnlibDef definition) in c:\projects\confuserex\Confuser.Core\Project\Patterns\IsPublicFunction.cs:line 43
   at Confuser.Core.Marker.ApplyRules(ConfuserContext context, IDnlibDef target, Dictionary`2 rules) in c:\projects\confuserex\Confuser.Core\Marker.cs:line 189
   at Confuser.Core.Marker.MarkProject(ConfuserProject proj, ConfuserContext context) in c:\projects\confuserex\Confuser.Core\Marker.cs:line 126
   at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in c:\projects\confuserex\Confuser.Core\ConfuserEngine.cs:line 123
Failed at 12:51, 0:00 elapsed.

I solved this issue by adding support for TypeDef in IsPublicFunction.Evaluate(...) with:

if (member is TypeDef)
    return ((TypeDef)member).IsPublic || ((TypeDef)member).IsNestedPublic;
yck1509 commented 9 years ago

Thanks for your report. I'll include your fix in the source code.

yck1509 commented 9 years ago

Close by 42d32e80debb395034c8cb321a79cc4d5313a3a0