Skip to content

Commit

Permalink
Merge pull request #18 from dassjosh/develop
Browse files Browse the repository at this point in the history
Support removing multiline comments
  • Loading branch information
dassjosh committed Mar 15, 2024
2 parents 775cc46 + b1aba88 commit 9e98ada
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/PluginMerge/Writer/CodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CodeWriter
private readonly PluginData _pluginData;
private readonly CodeStyleConfig _style;
private readonly string _pluginNameReplacement;
private bool _isInMultilineComment;

/// <summary>
/// Constructor for the code writer
Expand Down Expand Up @@ -198,9 +199,29 @@ public void WriteDescriptionAttribute(bool comment)
/// <param name="line"></param>
public void WriteCode(ReadOnlySpan<char> line)
{
if (!_style.KeepComments && line.StartsWith("//"))
if (!_style.KeepComments)
{
return;
if (line.StartsWith("//"))
{
return;
}

if (line.StartsWith("/*"))
{
_isInMultilineComment = true;
return;
}

if (line.EndsWith("*/"))
{
_isInMultilineComment = false;
return;
}

if (_isInMultilineComment)
{
return;
}
}

bool isRegion = line.StartsWith("#region") || line.StartsWith("#endregion");
Expand Down

0 comments on commit 9e98ada

Please sign in to comment.