DotPeekCleaner is a tool to clean a by JetBrains's dotPeek exported project from all the annoying comments on top of every file. Additional: The tool removes the empty line in every C# file. Example.:
// Decompiled with JetBrains decompiler
// Type: System.Runtime.CompilerServices.RefSafetyRulesAttribute
// Assembly: {YourAssemblyName}, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: {YourMVID}
// Assembly location: {YourAssemblyLocation}
- Go to Releases and choose the latest version to install. Download the "DotPeekCleaner-v{version}.zip" file to your local computer.
- Open the Zip file in a program you want (7Zip, WinRAR or the windows internal Zip tool).
- Extract all files from the Zip to your local program files folder (C:\Program Files\DotPeekCleaner) or any path you want it to be. It works everywhere.
- Start the .exe file and follow the instructions.
- Open the DotPeekCleaner.exe. It should look like that:
- Paste the path of the folder where the .csproj file is located:
- After all files are processed, it should look like this:
Here is the internal used code for cleaning the C# project's .cs files:
static void ProcessFile(string path)
{
string[] lines = File.ReadAllLines(path)
.Select(line => line.TrimEnd()) // removes trailing whitespaces
.SkipWhile(line => line.TrimStart().StartsWith("//") || string.IsNullOrWhiteSpace(line))
.ToArray();
int count = 0;
for (int i = lines.Length - 1; i >= 0; i--)
{
if (string.IsNullOrWhiteSpace(lines[i]))
count++;
else
break; // end loop when non-empty line was found
}
Array.Resize(ref lines, lines.Length - count);
lines = lines.Select(line => line.TrimEnd()).ToArray();
string text = string.Join(Environment.NewLine, lines);
File.WriteAllText(path, text);
path = path.Replace(_fullPath!, "...");
WriteInfoLine("Processed file: " + path);
}