Skip to content

Commit 1b6495b

Browse files
committed
FW 4.6+ targeting
1 parent 465cc07 commit 1b6495b

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

Main/src/TableData/CsvFormat.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ private static string[] ParseCsv(TextReader reader, ref int lineNum, char separa
3838
if (curChar.IsEol)
3939
{
4040
lineNum++;
41+
#if !FW452
42+
return Array.Empty<string>();
43+
#else
4144
return Array<string>.Empty;
45+
#endif
4246
}
4347

4448
var result = new List<string>();
@@ -162,11 +166,15 @@ private static string[] ParseCsvNoEscape(TextReader reader, ref int lineNum, cha
162166
var parts = line.Split(separator);
163167
// Special case - whitespace lines are ignored
164168
if (parts.Length == 1 && parts[0].IsNullOrWhiteSpace())
169+
#if !FW452
170+
return Array.Empty<string>();
171+
#else
165172
return Array<string>.Empty;
173+
#endif
166174
return parts;
167175
}
168176

169-
#region CharReader struct
177+
#region CharReader struct
170178
private struct CharReader
171179
{
172180
private const int s_Eof = -1;
@@ -209,20 +217,20 @@ private static int Read(TextReader reader)
209217

210218
public CharReader Peek() => new CharReader(m_Reader, m_Reader.Peek());
211219
}
212-
#endregion
220+
#endregion
213221

214-
#region ParserState enum
222+
#region ParserState enum
215223
private enum ParserState
216224
{
217225
ExpectField,
218226
Field,
219227
QuotedField,
220228
AfterField
221229
}
222-
#endregion
223-
#endregion
230+
#endregion
231+
#endregion
224232

225-
#region Formatter
233+
#region Formatter
226234
/// <summary>
227235
/// Creates formatter for CSV.
228236
/// </summary>
@@ -278,7 +286,7 @@ public string FormatLine(string[] values, int[] columnWidths)
278286

279287
private class CsvNoEscapeFormatter : ITableDataFormatter
280288
{
281-
#region Implementation of ITableDataFormatter
289+
#region Implementation of ITableDataFormatter
282290
/// <summary>
283291
/// Returns length of formatted value.
284292
/// </summary>
@@ -296,8 +304,8 @@ public string FormatLine(string[] values, int[] columnWidths) =>
296304
values
297305
.Zip(columnWidths, (s, w) => s.PadLeft(w))
298306
.Join(", ");
299-
#endregion
307+
#endregion
300308
}
301-
#endregion
309+
#endregion
302310
}
303311
}

Main/src/TableData/FixedWidthFormat.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ private static string[] Parse(TextReader reader, ref int lineNum, int[] widths)
3535
if (line == null)
3636
return null;
3737
if (line.IsNullOrWhiteSpace())
38+
#if !FW452
39+
return Array.Empty<string>();
40+
#else
3841
return Array<string>.Empty;
42+
#endif
3943

4044
var pos = 0;
4145
var result = new string[widths.Length];

0 commit comments

Comments
 (0)