Repository navigation
Add dotnet-counters console exporter tests - #4376
Conversation
Today all the testing of the console formatting is mostly manual. This adds some automated testing of the formatting logic in preparation to both refactor and make some design changes. The tests should make it very obvious in the future when the output formatting intentionally changes. This change also includes a small update to opportunistically hide the cursor when doing dotnet-counters monitor which looks a little nicer.
|
@hoyosjs @davmason - could one of you take a look at this? |
|
|
||
| try | ||
| { | ||
| _console.CursorVisible = oldCursorVisibility; |
There was a problem hiding this comment.
I don't see a CancelKeyPress handler, though I might have missed it. If the user kills the process with Control-C, whether or not the cursor is properly restored or not will depend on the terminal implementation. That means some Control-C behavior will leave the cursor invisible in some consoles, which is quite annoying.
I would suggest adding a CancelKeyPress handler to your IConsole interface if you are messing with cursor visibility and register it when you set IConsole.CursorVisible successfully.
Lastly, you might consider making oldCursorVisibility a nullable and check its nullability in Initialize, to make sure you haven't already set the cursor/ControlC handler. It might be a bug if someone calls Initialize twice, but it doesn't hurt to get cursor visibility restoration right.
I ran into this a few times with an old project I had where hitting Control-C would sometimes mess up that terminal window's cursor, requiring a restart.
There was a problem hiding this comment.
I'll probably just take this out for now. Even with a ctrl-C handler there are other failure modes that wouldn't hit it and if the terminal won't restore it on process exit I don't want to mess up people's console just for a small aesthetic improvement.
hoyosjs
left a comment
There was a problem hiding this comment.
Other than the field name comment, LGTM
Today all the testing of the console formatting is mostly manual. This adds some automated testing of the formatting logic in preparation to both refactor and make some design changes. The tests should make it very obvious in the future when the output formatting intentionally changes.
This change also includes a small update to opportunistically hide the cursor when doing dotnet-counters monitor which looks a little nicer.