"Insert explicit access modifiers on" option can pollute your code with modifiers in "random" places, see the example below.
I'm using VS2012 with CodeMaid 0.7.4.
With option "Insert explicit access modifiers on" enabled for all possible items (CODEMAID menu-> Configuration menu item -> Cleaning -> Insert) if you enter the code below
using System.Configuration;
namespace MyNamespace
{
internal class Class2
{
};
private void Main()
{
if (bool.Parse(ConfigurationManager.AppSettings["MySetting"]))
{
//...
}
}
}
}
and save the file you will end up with
using System.Configuration;
namespace MyNamespace
{
internal class Class2
{
};
private void Main()
{
if (bool.Parse(ConfigurationManager.AppSettings[internal "MySetting"]))
{
//...
}
}
}
}
The problem is the "internal" being inserted in "random" places.
This is a contrived example but here's a short version of what I was actually doing when I discovered the issue:
using System.Collections.Generic;
using System.Configuration;
namespace MyNamespace
{
internal class Class1
{
private Dictionary<string, Dictionary<string, string>> dict = new Dictionary<string, Dictionary<string, string>>
{
{"string", new Dictionary<string, string> {{"a", "b"}}}
};
};
private void Main()
{
if (bool.Parse(ConfigurationManager.AppSettings[internal "MySetting"]))
{
}
}
}
}
I know that code is syntactically incorrect while saving but in such case CodeMaid should not do any cleanups at all until code is syntactically correct.
Now the big problem is that I had a several hundred lines of code file that got broken by the cleanup and I had to manually go through it and remove the randomly injected "internal" keyword.
I've had other issues with cleanup like inserting empty lines (in similar scenario) but this gets fixed automatically on save when code becomes syntactically correct so it's not a a problem however in this case CodeMaid leaves me with extra work after cleanup.
I suppose the problem stems from the fact that CodeMaid does not understand C# syntax and it is using tricks like regex and etc. to cheat :)
I guess it's time to think how to get CodeMaid to the next level and give it some more smarts and some basic syntax understanding otherwise it will never work well IMHO and crash miserably on "edge" cases.