Skip to content

Commit 72bed81

Browse files
committed
refactor: Simplify GetSourceText and add XML docs
1 parent 8505376 commit 72bed81

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Riok.Mapperly/Helpers/LineEndingTextWriter.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System.IO;
12
using System.Text;
3+
using Microsoft.CodeAnalysis.Text;
24

35
namespace Riok.Mapperly.Helpers;
46

@@ -18,6 +20,10 @@ public LineEndingTextWriter(StringBuilder sb, string targetLineEnding)
1820
_targetLineEnding = targetLineEnding;
1921
}
2022

23+
/// <summary>
24+
/// Required by <see cref="TextWriter"/> but not used in this implementation.
25+
/// Character encoding is handled by <see cref="SourceText"/> after line ending conversion.
26+
/// </summary>
2127
public override Encoding Encoding => Encoding.UTF8;
2228

2329
public override void Write(char value)
@@ -27,7 +33,7 @@ public override void Write(char value)
2733
_lastCharWasCr = false;
2834
if (value == '\n')
2935
{
30-
// CRLF detected - replace with target line ending
36+
// CRLF detected - replace it with target line ending
3137
_sb.Append(_targetLineEnding);
3238
return;
3339
}
@@ -38,7 +44,7 @@ public override void Write(char value)
3844

3945
if (value == '\r')
4046
{
41-
// Hold CR - might be start of CRLF
47+
// Hold CR - might be the start of CRLF
4248
_lastCharWasCr = true;
4349
return;
4450
}

0 commit comments

Comments
 (0)