Skip to content

Commit 2d84ab1

Browse files
committed
fixed not showing any lines... now all is shown
1 parent 791beee commit 2d84ab1

File tree

20 files changed

+1032
-719
lines changed

20 files changed

+1032
-719
lines changed

src/ColumnizerLib.UnitTests/ColumnTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void Column_TruncatesAtConfiguredDisplayLength ()
4444
Column.SetMaxDisplayLength(10_000);
4545

4646
// Create a line longer than the display max length
47-
var longValue = new StringBuilder().Append('X', 15_000).ToString();
47+
var longValue = new StringBuilder().Append('X', 15_000).ToString().AsMemory();
4848

4949
Column column = new()
5050
{
@@ -57,8 +57,8 @@ public void Column_TruncatesAtConfiguredDisplayLength ()
5757

5858
// DisplayValue should be truncated at 10,000 with "..." appended
5959
Assert.That(column.DisplayValue.Length, Is.EqualTo(10_003)); // 10000 + "..."
60-
Assert.That(column.DisplayValue.EndsWith("...", StringComparison.OrdinalIgnoreCase), Is.True);
61-
Assert.That(column.DisplayValue.StartsWith("XXX", StringComparison.OrdinalIgnoreCase), Is.True);
60+
Assert.That(column.DisplayValue.ToString().EndsWith("...", StringComparison.OrdinalIgnoreCase), Is.True);
61+
Assert.That(column.DisplayValue.ToString().StartsWith("XXX", StringComparison.OrdinalIgnoreCase), Is.True);
6262

6363
// Reset for other tests
6464
Column.SetMaxDisplayLength(20_000);
@@ -69,7 +69,7 @@ public void Column_NoTruncationWhenBelowLimit ()
6969
{
7070
Column.SetMaxDisplayLength(20_000);
7171

72-
var normalValue = new StringBuilder().Append('Y', 5_000).ToString();
72+
var normalValue = new StringBuilder().Append('Y', 5_000).ToString().AsMemory();
7373
Column column = new()
7474
{
7575
FullValue = normalValue
@@ -80,11 +80,12 @@ public void Column_NoTruncationWhenBelowLimit ()
8080
}
8181

8282
[Test]
83+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Unit Test")]
8384
public void Column_NullCharReplacement ()
8485
{
8586
Column column = new()
8687
{
87-
FullValue = "asdf\0"
88+
FullValue = "asdf\0".AsMemory()
8889
};
8990

9091
//Switch between the different implementation for the windows versions
@@ -103,11 +104,12 @@ public void Column_NullCharReplacement ()
103104
}
104105

105106
[Test]
107+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Unit Test")]
106108
public void Column_TabReplacement ()
107109
{
108110
Column column = new()
109111
{
110-
FullValue = "asdf\t"
112+
FullValue = "asdf\t".AsMemory()
111113
};
112114

113115
Assert.That(column.DisplayValue, Is.EqualTo("asdf "));

src/ColumnizerLib/ILogLineColumnizer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public interface ILogLineColumnizer
6060
/// add the offset and convert the timestamp back to string value(s).
6161
/// </remarks>
6262
/// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
63-
/// <param name="line">The line content to be splitted</param>
64-
IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line);
63+
/// <param name="logLine">The line content to be splitted</param>
64+
IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine logLine);
6565

6666
/// <summary>
6767
/// Returns true, if the columnizer supports timeshift handling.

src/ColumnizerLib/ILogLineMemoryColumnizer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ public interface ILogLineMemoryColumnizer : ILogLineColumnizer
1616
/// Splits a log line into columns using the specified callback for columnization.
1717
/// </summary>
1818
/// <param name="callback">The callback used to determine how the log line is split into columns. Cannot be null.</param>
19-
/// <param name="line">The log line to be split into columns. Cannot be null.</param>
19+
/// <param name="logLine">The log line to be split into columns. Cannot be null.</param>
2020
/// <returns>An object representing the columnized log line. The returned object contains the extracted columns from the
2121
/// input line.</returns>
22-
IColumnizedLogLineMemory SplitLine (ILogLineMemoryColumnizerCallback callback, ILogLineMemory line);
22+
IColumnizedLogLineMemory SplitLine (ILogLineMemoryColumnizerCallback callback, ILogLineMemory logLine);
2323

2424
/// <summary>
2525
/// Retrieves the timestamp associated with the specified log line.
2626
/// </summary>
2727
/// <param name="callback">An object that provides access to columnizer services for the log line. Used to obtain additional context or
2828
/// data required for timestamp extraction.</param>
29-
/// <param name="line">The log line from which to extract the timestamp.</param>
29+
/// <param name="logLine">The log line from which to extract the timestamp.</param>
3030
/// <returns>A DateTime value representing the timestamp of the specified log line.</returns>
31-
DateTime GetTimestamp (ILogLineMemoryColumnizerCallback callback, ILogLineMemory line);
31+
DateTime GetTimestamp (ILogLineMemoryColumnizerCallback callback, ILogLineMemory logLine);
3232

3333
/// <summary>
3434
/// Notifies the callback of a new value for the specified column, providing both the current and previous values.

src/CsvColumnizer/CsvColumnizer.cs

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,7 @@ public string PreProcessLine (string logLine, int lineNum, int realLineNum)
3939
{
4040
ArgumentNullException.ThrowIfNull(logLine, nameof(logLine));
4141

42-
if (realLineNum == 0)
43-
{
44-
// store for later field names and field count retrieval
45-
_firstLine = new CsvLogLine(logLine, 0);
46-
47-
if (_config.MinColumns > 0)
48-
{
49-
using CsvReader csv = new(new StringReader(logLine), _config.ReaderConfiguration);
50-
if (csv.Parser.Count < _config.MinColumns)
51-
{
52-
// on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode
53-
_isValidCsv = false;
54-
return logLine;
55-
}
56-
}
57-
58-
_isValidCsv = true;
59-
}
60-
61-
if (_config.HasFieldNames && realLineNum == 0)
62-
{
63-
return null; // hide from LogExpert
64-
}
65-
66-
return _config.CommentChar != ' ' &&
67-
logLine.StartsWith("" + _config.CommentChar, StringComparison.OrdinalIgnoreCase)
68-
? null
69-
: logLine;
42+
return PreProcessLine(logLine.AsMemory(), lineNum, realLineNum).ToString();
7043
}
7144

7245
public ReadOnlyMemory<char> PreProcessLine (ReadOnlyMemory<char> logLine, int lineNum, int realLineNum)
@@ -140,18 +113,18 @@ public string[] GetColumnNames ()
140113
return names;
141114
}
142115

143-
public IColumnizedLogLineMemory SplitLine (ILogLineMemoryColumnizerCallback callback, ILogLineMemory line)
116+
public IColumnizedLogLineMemory SplitLine (ILogLineMemoryColumnizerCallback callback, ILogLineMemory logLine)
144117
{
145-
ArgumentNullException.ThrowIfNull(line, nameof(line));
118+
ArgumentNullException.ThrowIfNull(logLine, nameof(logLine));
146119

147120
return _isValidCsv
148-
? SplitCsvLine(line)
149-
: CreateColumnizedLogLine(line);
121+
? SplitCsvLine(logLine)
122+
: CreateColumnizedLogLine(logLine);
150123
}
151124

152-
public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line)
125+
public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine logLine)
153126
{
154-
return SplitLine(callback as ILogLineMemoryColumnizerCallback, line as ILogLineMemory);
127+
return SplitLine(callback as ILogLineMemoryColumnizerCallback, logLine as ILogLineMemory);
155128
}
156129

157130
private static ColumnizedLogLine CreateColumnizedLogLine (ILogLineMemory line)
@@ -180,12 +153,12 @@ public int GetTimeOffset ()
180153
throw new NotImplementedException();
181154
}
182155

183-
public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line)
156+
public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine logLine)
184157
{
185158
throw new NotImplementedException();
186159
}
187160

188-
public DateTime GetTimestamp (ILogLineMemoryColumnizerCallback callback, ILogLineMemory line)
161+
public DateTime GetTimestamp (ILogLineMemoryColumnizerCallback callback, ILogLineMemory logLine)
189162
{
190163
throw new NotImplementedException();
191164
}

0 commit comments

Comments
 (0)