From 08c302f8393a58b160bffe3c484c39950f023830 Mon Sep 17 00:00:00 2001 From: EonaCat Date: Mon, 19 Sep 2022 09:27:48 +0200 Subject: [PATCH] Initial version --- .gitignore | 76 +---- EonaCat.CommentRegionRemover.sln | 25 ++ .../EonaCat.CommentRegionRemover.cs | 300 ++++++++++++++++++ .../EonaCat.CommentRegionRemover.csproj | 8 + EonaCat.CommentRegionRemover/Program.cs | 35 ++ LICENSE | 99 +++--- README.md | 61 +++- 7 files changed, 472 insertions(+), 132 deletions(-) create mode 100644 EonaCat.CommentRegionRemover.sln create mode 100644 EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.cs create mode 100644 EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.csproj create mode 100644 EonaCat.CommentRegionRemover/Program.cs diff --git a/.gitignore b/.gitignore index 1998960..e3ba347 100644 --- a/.gitignore +++ b/.gitignore @@ -14,9 +14,6 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs -# Mono auto generated files -mono_crash.* - # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -24,14 +21,10 @@ mono_crash.* [Rr]eleases/ x64/ x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ -[Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ @@ -45,10 +38,9 @@ Generated\ Files/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -# NUnit +# NUNIT *.VisualState.xml TestResult.xml -nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ @@ -63,9 +55,6 @@ project.lock.json project.fragment.lock.json artifacts/ -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - # StyleCop StyleCopReport.xml @@ -91,7 +80,6 @@ StyleCopReport.xml *.tmp_proj *_wpftmp.csproj *.log -*.tlog *.vspscc *.vssscc .builds @@ -133,6 +121,9 @@ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user +# JustCode is a .NET coding add-in +.JustCode + # TeamCity is a build add-in _TeamCity* @@ -143,11 +134,6 @@ _TeamCity* .axoCover/* !.axoCover/settings.json -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - # Visual Studio code coverage results *.coverage *.coveragexml @@ -195,8 +181,6 @@ PublishScripts/ # NuGet Packages *.nupkg -# NuGet Symbol Packages -*.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. @@ -207,9 +191,6 @@ PublishScripts/ *.nuget.props *.nuget.targets -# Nuget personal access tokens and Credentials -nuget.config - # Microsoft Azure Build Output csx/ *.build.csdef @@ -224,14 +205,12 @@ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx -*.appxbundle -*.appxupload # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache -!?*.[Cc]ache/ +!*.[Cc]ache/ # Others ClientBin/ @@ -275,9 +254,6 @@ ServiceFabricBackup/ *.bim.layout *.bim_*.settings *.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ @@ -313,6 +289,10 @@ paket-files/ # FAKE - F# Make .fake/ +# JetBrains Rider +.idea/ +*.sln.iml + # CodeRush personal settings .cr/personal @@ -354,48 +334,10 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd - -# VS Code files for those working on multiple tools -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ - -# Windows Installer files from build outputs -*.cab -*.msi -*.msix -*.msm -*.msp - -# JetBrains Rider -.idea/ -*.sln.iml - # ---> VisualStudioCode .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ diff --git a/EonaCat.CommentRegionRemover.sln b/EonaCat.CommentRegionRemover.sln new file mode 100644 index 0000000..f3ff7e1 --- /dev/null +++ b/EonaCat.CommentRegionRemover.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29926.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EonaCat.CommentRegionRemover", "EonaCat.CommentRegionRemover\EonaCat.CommentRegionRemover.csproj", "{44FCD2E6-BAD1-43BA-ACC3-D5AADDD35568}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {44FCD2E6-BAD1-43BA-ACC3-D5AADDD35568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44FCD2E6-BAD1-43BA-ACC3-D5AADDD35568}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44FCD2E6-BAD1-43BA-ACC3-D5AADDD35568}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44FCD2E6-BAD1-43BA-ACC3-D5AADDD35568}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {78F1D1D4-7348-4F9D-B6E7-169DDEB6F669} + EndGlobalSection +EndGlobal diff --git a/EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.cs b/EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.cs new file mode 100644 index 0000000..45b1d6c --- /dev/null +++ b/EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.cs @@ -0,0 +1,300 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace EonaCatRemover +{ + internal class EonaCatCommentRegionRemover + { + private const string BeginStrOfMulLineCom = "/*"; + private const string BeginStrOfSglLineCom = "//"; + private const string BeginStrOfXmlTagsCom = "/// "; + private const string EndStrOfMulLineCom = "*/"; + + private bool removingCommentsTags = false; + private bool removingRegionTags = false; + private bool removingXmlTags = false; + private int rewrittenFiles = 0; + private int rmLinesSum = 0; + private int rmPartsSum = 0; + private string[] targetExtensions = null; + + public EonaCatCommentRegionRemover(bool removingCommentsTags, bool removingXmlTags, bool removingRegionTags) + { + Console.WriteLine("[EonaCat CommentRegion Remover created by Jeroen Saey]"); + targetExtensions = new string[] { "*.cs" }; + this.removingCommentsTags = removingCommentsTags; + this.removingXmlTags = removingXmlTags; + this.removingRegionTags = removingRegionTags; + } + + public void Remove(string path) + { + rewrittenFiles = 0; + rmLinesSum = 0; + rmPartsSum = 0; + if (Directory.Exists(path)) + { + RemoveForDirectory(path); + } + else if (File.Exists(path)) + { + RemoveForFile(path); + } + else + { + Console.WriteLine("[WARN]: {0} does not exist.", path); + } + } + + private int GetEndIdxOfString(string line, int beginIdx, bool isLiteral) + { + int i = beginIdx + 1; + while (i < line.Length) + { + if (IsEscSeq(line, i, isLiteral)) + { + i += 2; + continue; + } + if (line[i] == '"') + { + return i; + } + i++; + } + return i; + } + + private List GetFilesList(string rootDir) + { + var filesList = new List(); + foreach (string extension in targetExtensions) + { + string[] files = Directory.GetFiles(rootDir, extension, SearchOption.AllDirectories); + filesList.AddRange(files); + } + return filesList; + } + + // Key: begin index of string + // Value: end index of string + private Dictionary GetStringFields(string line) + { + var dic = new Dictionary(); + int i = 0; + int beginIdx = 0; + while ((beginIdx = line.IndexOf('"', i)) > 0) + { + bool isLiteral = (beginIdx > 0 && line[beginIdx - 1] == '@'); + int endIdx = GetEndIdxOfString(line, beginIdx, isLiteral); + if (line.Length <= endIdx) + { + break; + } + dic.Add(beginIdx, endIdx); + i = endIdx + 1; + } + return dic; + } + + private bool HasBeginIdxOfComment(string line, ref bool mulLineCom, ref int beginIdx) + { + var strFields = GetStringFields(line); + for (int i = 0; i <= line.Length; i++) + { + // skip string field + if (strFields.Keys.Contains(i)) + { + i = strFields[i]; + continue; + } + + // XML tags comments + if (IsBeginIndex(line, i, BeginStrOfXmlTagsCom)) + { + if (removingXmlTags) + { + beginIdx = i; + return true; + } + break; + } + // Single line comments + if (IsBeginIndex(line, i, BeginStrOfSglLineCom)) + { + beginIdx = i; + return true; + } + // Multiple line comments + if (IsBeginIndex(line, i, BeginStrOfMulLineCom)) + { + mulLineCom = true; + beginIdx = i; + return true; + } + } + return false; + } + + private bool HasEndIdxOfMulLineCom(string line, ref int endIdx) + { + for (int i = 0; i < line.Length - 1; i++) + { + if (line.Substring(i, EndStrOfMulLineCom.Length) == EndStrOfMulLineCom) + { + endIdx = i + 1; + return true; + } + } + return false; + } + + private bool IsBeginIndex(string line, int index, string str) + { + return (index <= line.Length - str.Length) && (line.Substring(index, str.Length) == str); + } + + private bool IsEscSeq(string line, int index, bool isLiteral) + { + bool isEscSeq = false; + if (index < line.Length - 1) + { + isEscSeq |= line.Substring(index, 2) == "\\\""; + isEscSeq |= isLiteral && line.Substring(index, 2) == "\"\""; + } + return isEscSeq; + } + + private void RemoveForDirectory(string path) + { + Console.WriteLine("[Dir]: {0}", path); + var files = GetFilesList(path); + foreach (string file in files) + { + RemoveForOneFile(file); + } + Console.WriteLine(" {0} files rewritten. (including {1} files in directory.)", rewrittenFiles, files.Count); + Console.WriteLine(" {0} lines removed.", rmLinesSum); + Console.WriteLine(" {0} lines removed with parts.", rmPartsSum); + } + + private void RemoveForFile(string path) + { + bool isTargetExtension = targetExtensions.Contains("*" + Path.GetExtension(path)); + if (!isTargetExtension) + { + Console.WriteLine("[WARN]: The extension of {0} is out of target.", path); + return; + } + + Console.WriteLine("[File]: {0}", path); + RemoveForOneFile(path); + Console.WriteLine(" {0} lines removed.", rmLinesSum); + Console.WriteLine(" {0} lines removed with parts.", rmPartsSum); + } + + private void RemoveForOneFile(string path) + { + int rmLines = 0; + int rmParts = 0; + string tmpFile = Path.GetTempFileName(); + using (StreamReader sr = new StreamReader(path)) + using (StreamWriter sw = new StreamWriter(tmpFile)) + { + bool mulLineCom = false; + while (sr.Peek() > -1) + { + string orgLine = sr.ReadLine(); + string newLine = orgLine; + + if (removingCommentsTags) + { + newLine = TrimComment(newLine, ref mulLineCom); + } + + if (removingRegionTags) + { + newLine = TrimRegion(newLine); + } + + if (newLine == null) + { + rmLines++; + } + else + { + if (orgLine != newLine) + { + rmParts++; + } + sw.WriteLine(newLine); + } + } + } + + bool fileIsRewritten = (rmLines > 0 || rmParts > 0); + if (fileIsRewritten) + { + rewrittenFiles++; + File.Copy(tmpFile, path, true); + } + File.Delete(tmpFile); + + rmLinesSum += rmLines; + rmPartsSum += rmParts; + } + + private string TrimComment(string line, ref bool mulLineCom) + { + if (mulLineCom) + { + line = TrimMulLineCom(line, ref mulLineCom); + if (line == null || line.Trim().Length == 0) + { + // The line is comment only. + return null; + } + } + int beginComIdx = 0; + if (HasBeginIdxOfComment(line, ref mulLineCom, ref beginComIdx)) + { + string orgLine = line; + line = orgLine.Remove(beginComIdx); + if (mulLineCom) + { + string afterLineOfComIdx = orgLine.Remove(0, beginComIdx + BeginStrOfMulLineCom.Length); + line += TrimComment(afterLineOfComIdx, ref mulLineCom); + } + if (line.Trim().Length == 0) + { + // If trimmed line is empty, the line won't be outputed. + return null; + } + } + return line; + } + + private string TrimMulLineCom(string line, ref bool mulLineCom) + { + int endIdx = 0; + if (HasEndIdxOfMulLineCom(line, ref endIdx)) + { + mulLineCom = false; + return line.Remove(0, endIdx + 1); + } + return null; + } + + private string TrimRegion(string currentLine) + { + if (currentLine != null && currentLine.IndexOf("#region", 0, StringComparison.CurrentCultureIgnoreCase) != -1 || + currentLine != null && currentLine.IndexOf("#endregion", 0, StringComparison.CurrentCultureIgnoreCase) != -1) + { + currentLine = null; + } + return currentLine; + } + } +} \ No newline at end of file diff --git a/EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.csproj b/EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.csproj new file mode 100644 index 0000000..958d2f1 --- /dev/null +++ b/EonaCat.CommentRegionRemover/EonaCat.CommentRegionRemover.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.0 + + + diff --git a/EonaCat.CommentRegionRemover/Program.cs b/EonaCat.CommentRegionRemover/Program.cs new file mode 100644 index 0000000..a935de1 --- /dev/null +++ b/EonaCat.CommentRegionRemover/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.Linq; + +namespace EonaCatRemover +{ + internal class Program + { + private static string ALL_TAG = "-cxr"; + private static string COMMENTS_TAG = "-c"; + private static string REGION_TAG = "-r"; + private static string XML_TAG = "-x"; + + private static void Main(string[] args) + { + Console.Title = "EonaCat CommentRegion remover for C#"; + bool removingXmlTags = false; + bool removingRegionTags = false; + bool removingCommentsTags = false; + var arguments = args.ToList(); + if (args[0] == COMMENTS_TAG || args[0] == XML_TAG || args[0] == REGION_TAG || args[0] == ALL_TAG) + { + removingCommentsTags = args[0] == COMMENTS_TAG || args[0] == XML_TAG || args[0] == ALL_TAG; + removingXmlTags = args[0] == XML_TAG || args[0] == ALL_TAG; + removingRegionTags = args[0] == REGION_TAG || args[0] == ALL_TAG; + arguments.RemoveAt(0); + } + + var EonaCatRemover = new EonaCatCommentRegionRemover(removingCommentsTags, removingXmlTags, removingRegionTags); + foreach (var path in arguments) + { + EonaCatRemover.Remove(path); + } + } + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 137069b..923c623 100644 --- a/LICENSE +++ b/LICENSE @@ -1,73 +1,46 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ +Copyright (c) 1995-1999 The Apache Group. All rights reserved. -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: -1. Definitions. +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. +3. All advertising materials mentioning features or use of this software must +display the following acknowledgment: "This product includes software developed +by the Apache Group for use in the Apache HTTP server project (http://www.apache.org/) +." -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. +4. The name "Apache Server" and "Apache Group" must not be used to endorse +or promote products derived from this software without prior written permission. +For written permission, please contact apache@apache.org . -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. +5. Products derived from this software may not be called "Apache" nor may +"Apache" appear in their name, without prior written permission of the Apache +Group . -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. +6. Redistributions of any form whatsoever must retain the following acknowledgment: -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. +"This product includes software developed by the Apache Group for use in the +Apache HTTP server project (http://www.apache.org/) ." -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). +THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY EXPRESSED +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL THE APACHE GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - - You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - -To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +This software consists of voluntary contributions made by many individuals +on behalf of the Apache Group and was originally based on public domain software +written at the National Center for Supercomputing Applications, University +of Illinois, Urbana-Champaign. For more information on the Apache Group and +the Apache HTTP server project, please see . diff --git a/README.md b/README.md index 9de1361..34ddd6d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,60 @@ -# EonaCat.CommentRegionRemover +EonaCat CommentRegionRemover for C# +========= -EonaCat Comment and Region Remover \ No newline at end of file +## Overview +EonaCat CommentRegionRemover is a tool for removing comments (including XML) and regions for C# code. +## Description +* Single line comments + ``` +// for single line comments +``` +* Multiple line comments +``` +/* for multi line comments */ +``` +* XML tags comments +using *-x* option so as to remove this type. +``` +/// XML tags displayed in a code comment +``` +* Regions +using *-r* option so as to remove this type. + ``` +// for start and end regions +``` +### Example +Before: +``` +/* +Any comments +*/ +Console.Write("Hello "); +Console.Write(/*Hello*/"World");//int i = 0; +//Console.Write("World"); +``` +After: +``` +Console.Write("Hello "); +Console.Write("World"); +``` + +## Usage +``` +cd ./EonaCatRemover + +EonaCatRemover.exe -cxr C:\Users\EonaCat\Desktop\Project + +[EonaCat C# Remover created by Jeroen Saey] +[Dir]: C:\Users\31638\Desktop\Network-master + 82 files rewritten. (including 105 files in directory.) + 3911 lines removed. + 19 lines removed with parts. + +EonaCatRemover.exe [-x] [file or directory] (Strips XML and comments) +or +EonaCatRemover.exe [-c] [file or directory] (Strips comments) +or +EonaCatRemover.exe [-r] [file or directory] (Strips regions) +or +EonaCatRemover.exe [-cxr] [file or directory] (Strips comments, XML and regions) +```