@@ -26,7 +26,7 @@ public class CsvColumnizer : ILogLineColumnizer, IInitColumnizer, IColumnizerCon
2626
2727 private static readonly string _configFileName = "csvcolumnizer.json" ;
2828
29- private readonly IList < CsvColumn > _columnList = new List < CsvColumn > ( ) ;
29+ private readonly IList < CsvColumn > _columnList = [ ] ;
3030 private CsvColumnizerConfig _config ;
3131
3232 private ILogLine _firstLine ;
@@ -47,14 +47,12 @@ public string PreProcessLine(string logLine, int lineNum, int realLineNum)
4747
4848 if ( _config . MinColumns > 0 )
4949 {
50- using ( CsvReader csv = new CsvReader ( new StringReader ( logLine ) , _config . ReaderConfiguration ) )
50+ using CsvReader csv = new ( new StringReader ( logLine ) , _config . ReaderConfiguration ) ;
51+ if ( csv . Parser . Count < _config . MinColumns )
5152 {
52- if ( csv . Parser . Count < _config . MinColumns )
53- {
54- // on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode
55- _isValidCsv = false ;
56- return logLine ;
57- }
53+ // on invalid CSV don't hide the first line from LogExpert, since the file will be displayed in plain mode
54+ _isValidCsv = false ;
55+ return logLine ;
5856 }
5957 }
6058
@@ -120,9 +118,11 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin
120118
121119 private static ColumnizedLogLine CreateColumnizedLogLine ( ILogLine line )
122120 {
123- ColumnizedLogLine cLogLine = new ColumnizedLogLine ( ) ;
124- cLogLine . LogLine = line ;
125- cLogLine . ColumnValues = new IColumn [ ] { new Column { FullValue = line . FullLine , Parent = cLogLine } } ;
121+ ColumnizedLogLine cLogLine = new ( )
122+ {
123+ LogLine = line
124+ } ;
125+ cLogLine . ColumnValues = [ new Column { FullValue = line . FullLine , Parent = cLogLine } ] ;
126126 return cLogLine ;
127127 }
128128
@@ -194,16 +194,17 @@ public void DeSelected(ILogLineColumnizerCallback callback)
194194 public void Configure ( ILogLineColumnizerCallback callback , string configDir )
195195 {
196196 string configPath = configDir + "\\ " + _configFileName ;
197- FileInfo fileInfo = new FileInfo ( configPath ) ;
197+ FileInfo fileInfo = new ( configPath ) ;
198+
199+ CsvColumnizerConfigDlg dlg = new ( _config ) ;
198200
199- CsvColumnizerConfigDlg dlg = new CsvColumnizerConfigDlg ( _config ) ;
200201 if ( dlg . ShowDialog ( ) == DialogResult . OK )
201202 {
202203 _config . VersionBuild = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . Build ;
203204
204- using ( StreamWriter sw = new StreamWriter ( fileInfo . Create ( ) ) )
205+ using ( StreamWriter sw = new ( fileInfo . Create ( ) ) )
205206 {
206- JsonSerializer serializer = new JsonSerializer ( ) ;
207+ JsonSerializer serializer = new ( ) ;
207208 serializer . Serialize ( sw , _config ) ;
208209 }
209210
@@ -256,31 +257,31 @@ public Priority GetPriority(string fileName, IEnumerable<ILogLine> samples)
256257
257258 private IColumnizedLogLine SplitCsvLine ( ILogLine line )
258259 {
259- ColumnizedLogLine cLogLine = new ColumnizedLogLine ( ) ;
260- cLogLine . LogLine = line ;
261-
262- using ( CsvReader csv = new CsvReader ( new StringReader ( line . FullLine ) , _config . ReaderConfiguration ) )
260+ ColumnizedLogLine cLogLine = new ( )
263261 {
264- csv . Read ( ) ;
265- csv . ReadHeader ( ) ;
262+ LogLine = line
263+ } ;
266264
267- //we only read line by line and not the whole file so it is always the header
268- string [ ] records = csv . HeaderRecord ;
265+ using CsvReader csv = new ( new StringReader ( line . FullLine ) , _config . ReaderConfiguration ) ;
266+ csv . Read ( ) ;
267+ csv . ReadHeader ( ) ;
269268
270- if ( records != null )
271- {
272- List < Column > columns = new List < Column > ( ) ;
269+ //we only read line by line and not the whole file so it is always the header
270+ string [ ] records = csv . HeaderRecord ;
273271
274- foreach ( string record in records )
275- {
276- columns . Add ( new Column { FullValue = record , Parent = cLogLine } ) ;
277- }
272+ if ( records != null )
273+ {
274+ List < Column > columns = [ ] ;
278275
279- cLogLine . ColumnValues = columns . Select ( a => a as IColumn ) . ToArray ( ) ;
276+ foreach ( string record in records )
277+ {
278+ columns . Add ( new Column { FullValue = record , Parent = cLogLine } ) ;
280279 }
281280
282- return cLogLine ;
281+ cLogLine . ColumnValues = columns . Select ( a => a as IColumn ) . ToArray ( ) ;
283282 }
283+
284+ return cLogLine ;
284285 }
285286
286287 #endregion
0 commit comments