-
Notifications
You must be signed in to change notification settings - Fork 11
Fix "label column cannot start at the end of the line" error in Console reporting #1224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b31e9b0
to
42c276f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Your previous approach did not work. I changed the branch so that it now contains a test case which fails due to the issue. The testcase is Should_Work_With_Issue_On_End_Of_Line
in src\Cake.Issues.Reporting.Console.Tests\ConsoleIssueReportGeneratorTests.cs
.
In you previous approach you tried to catch the exception. This won't work since the exception is not thrown when the label is added. It is an internal exception in Spectre.Console when calling Render
which is internally catched and rendered to the console output.
You're absolutely right that the exception handling approach wouldn't work since the error occurs during Spectre.Console rendering. I've implemented a better solution that validates column positions against actual file content before they reach the Errata rendering engine. The fix enhances the Fixed in commit 10cd0fa. |
… start at the end of the line" errors
10cd0fa
to
420c6d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a crash in the Cake.Issues.Reporting.Console package that occurred when issues were positioned at the end of source code lines. The solution enhances column position validation to prevent the "label column cannot start at the end of the line" error from the Errata library.
Key changes:
- Enhanced
IssueDiagnostic
class to validate column positions against actual file content before rendering - Modified
ConsoleIssueReportGenerator
to accept anIAnsiConsole
parameter for better testability - Added comprehensive test coverage using Verify framework and Spectre.Console.Testing
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
IssueDiagnostic.cs |
Added file content validation logic to adjust column positions when they exceed line length |
ConsoleIssueReportGenerator.cs |
Modified constructor to accept IAnsiConsole parameter and updated all console output calls |
ConsoleIssueReportFormatAliases.cs |
Updated alias to pass AnsiConsole.Console to the generator constructor |
ConsoleIssueReportGeneratorTests.cs |
Enhanced tests with new constructor parameter validation and snapshot testing for end-of-line issues |
ConsoleIssueReportFixture.cs |
Updated test fixture to use TestConsole for capturing output in tests |
Cake.Issues.Reporting.Console.Tests.csproj |
Added test dependencies for Spectre.Console.Testing and Verify.Xunit |
packages.lock.json |
Updated package lock file with new test dependencies |
Test verification file | Added expected output for the end-of-line issue test case |
src/Cake.Issues.Reporting.Console.Tests/ConsoleIssueReportGeneratorTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
The Cake.Issues.Reporting.Console package was throwing an error when issues were positioned at the end of source code lines. This occurred when the column position equaled the line length (e.g., column 119 on a 119-character line), causing the Errata library to throw "label column cannot start at the end of the line" errors.
Problem
When StyleCop or other analyzers reported issues at the end of lines, the Console reporter would crash with:
Solution
Enhanced the
IssueDiagnostic
class to validate column positions against actual file content before they reach the Errata rendering engine:repositoryRoot
parameter to enable file content accessGetLocation()
method to read source files and validate column positions against actual line contentThe fix ensures issues are still reported and displayed at the correct position, preventing crashes while maintaining full functionality.
Testing
Should_Work_With_Issue_On_End_Of_Line
now passes successfullyThe solution is minimal and surgical - it only affects error cases that would previously crash, while preserving all existing functionality and ensuring users still see their issues reported correctly.
Fixes #1223.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.