Conversation
There was a problem hiding this comment.
Pull request overview
Adds multi-line cell rendering support to ConsoleTable.Text so headers, rows, and footers can contain newline characters and render as multiple physical lines with correct column sizing.
Changes:
- Updated table rendering logic to split cell content by line breaks and render multi-line rows/headers/footers.
- Added an extensive test suite covering multi-line rendering, alignment, padding, CRLF/LF handling, and mixed row types.
- Updated docs/examples and bumped package version + changelog entry for v2.2.0.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
ConsoleTable.Text/Table.cs |
Implements multi-line splitting, width calculation based on widest line, and multi-line rendering in CreateValueLine. |
Tests/ConsoleTable.Text.Tests/TableTests.cs |
Adds multi-line behavior tests and helper for output line parsing. |
README.md |
Documents multi-line support and updates Quick Start example/output. |
ConsoleTable.Text.Examples/Program.cs |
Adds multi-line example and updates some sample rows to include newlines. |
ConsoleTable.Text/ConsoleTable.Text.csproj |
Bumps package version to 2.2.0. |
ConsoleTable.slnx |
Includes the new 2.2.0 changelog file in the solution items. |
ChangeLogs/2.2.0-ChangeLog.md |
Adds v2.2.0 release notes with a multi-line usage example and output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| foreach (var row in table) | ||
| { | ||
| if (row == null || row.Length <= 0) | ||
| continue; | ||
|
|
There was a problem hiding this comment.
ToTable() calls CleanupRow (which converts null/empty rows into a single-column row), but GetMaxCellWidths() skips null/empty rows entirely. If a table contains only an empty row (e.g., AddRow() with no values) and no headers/footers, maximumCellWidths can end up length 0 and CreateValueLine() will throw IndexOutOfRangeException when rendering the cleaned row. Consider applying CleanupRow inside GetMaxCellWidths() (and when determining the initial column count) so widths are computed for the same normalized rows that are rendered.
There was a problem hiding this comment.
Test validates empty table does not throw exception
| ```csharp | ||
| using ConsoleTable.Text; | ||
|
|
There was a problem hiding this comment.
The Quick Start snippet uses Environment.NewLine and List<string[]> later in the example, but only imports ConsoleTable.Text. To make the snippet compile in projects without implicit global usings, add using System; and using System.Collections.Generic; (or fully-qualify those types).
| new string[] { "Alice Cooper", $"30{Environment.NewLine}1995", "New York" }, | ||
| new string[] { "Bob", $"25{Environment.NewLine}2000", "Los Angeles" }, | ||
| new string[] { "Charlie Brown", $"67{Environment.NewLine}1958", "Chicago" }, | ||
| new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally fron Bogota, Colombia" } |
There was a problem hiding this comment.
Typo in the example string: "Originally fron Bogota, Colombia" should be "Originally from Bogota, Colombia".
| new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally fron Bogota, Colombia" } | |
| new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally from Bogota, Colombia" } |
| Cell content can contain newlines and the table will adjust row height accordingly, in headers, rows and footers. | ||
|
|
||
|
|
||
| ```csharp |
There was a problem hiding this comment.
The changelog snippet uses Environment.NewLine and List<string[]>, but only imports ConsoleTable.Text. Consider adding using System; and using System.Collections.Generic; so the example compiles without relying on implicit global usings.
| ```csharp | |
| ```csharp | |
| using System; | |
| using System.Collections.Generic; |
| new string[] { "Charlie Brown", $"67{Environment.NewLine}1958", "Chicago" }, | ||
| new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally fron Bogota, Colombia" } | ||
| }, |
There was a problem hiding this comment.
Typo in the example string: "Originally fron Bogota, Colombia" should be "Originally from Bogota, Colombia".
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…2/ConsoleTable into feature/multiLineText
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| foreach (var row in table) | ||
| { | ||
| if (row == null || row.Length <= 0) | ||
| continue; | ||
|
|
||
| for (int i = 0; i < row.Length; i++) | ||
| { | ||
| var maxWidth = row[i].Length + paddingCount; | ||
| var lines = GetCellLines(row[i]); |
There was a problem hiding this comment.
GetMaxCellWidths() skips rows that are null or have Length <= 0, but ToTable() later calls CleanupRow() which converts those rows into a 1-column row (new[] { " " }). If Rows contains only an empty/null row (e.g., AddRow() with no values or AddRow(null)), maximumCellWidths can end up length 0 and CreateValueLine() will throw IndexOutOfRangeException when it tries to access maximumCellWidths[0]. Normalize rows consistently when computing widths (e.g., apply CleanupRow() while building/iterating table, and ensure maximumColumns is at least 1 when any row exists after cleanup).
| [Fact] | ||
| public void Empty() | ||
| { | ||
| var table = new Table(); | ||
|
|
||
| var result = table.ToTable(); | ||
|
|
||
| Assert.Equal(string.Empty, result); | ||
| } |
There was a problem hiding this comment.
Test method name Empty doesn’t follow the naming pattern used throughout this file (e.g., SetHeaders_Success, ToTable_...). Consider renaming it to something descriptive like ToTable_EmptyTable_ReturnsEmptyString to keep the suite consistent and self-explanatory.
| - Simple and intuitive API | ||
| - Optimized for performance | ||
| - Support for varying column counts across rows (each row can have its own number of cells) | ||
| - Multi line support (cell content can contain newlines and the table will adjust row height accordingly) in headers, rows and footers |
There was a problem hiding this comment.
Typo/wording: consider using the hyphenated form “Multi-line support” (and “multi-line” as an adjective) for standard English usage.
| - Multi line support (cell content can contain newlines and the table will adjust row height accordingly) in headers, rows and footers | |
| - Multi-line support (cell content can contain newlines and the table will adjust row height accordingly) in headers, rows and footers |
ChangeLogs/2.2.0-ChangeLog.md
Outdated
| @@ -0,0 +1,53 @@ | |||
| # V2.2.0 | |||
|
|
|||
| ## Multi line support | |||
There was a problem hiding this comment.
Typo/wording: use “Multi-line support” (hyphenated) in the section header for standard English usage (and match README phrasing).
| ## Multi line support | |
| ## Multi-line support |
| private static void WriteMultiLineTable() | ||
| { | ||
| Console.WriteLine(); | ||
| Console.WriteLine("Multi line table:"); |
There was a problem hiding this comment.
Minor wording: consider changing the output label to “Multi-line table:” for consistency with the README/changelog phrasing.
| Console.WriteLine("Multi line table:"); | |
| Console.WriteLine("Multi-line table:"); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.