douglasg14b / BetterConsoleTables

Faster, colorable, more configurable, and more robust console colors & tables for C# console applications
GNU Lesser General Public License v3.0
92 stars 16 forks source link

Crashes in LinqPad :( #5

Closed bchavez closed 5 years ago

bchavez commented 5 years ago

Hi there,

I'm trying to use this library in LINQPad to copy/paste a table for some readme docs; but soon as I try to call .ToString on the table, I get an IO exception.

I'm guessing because the library is running in an execution context without the console subsystem, but it would be nice if it ran in a situation like this without a console.

Here's the query I tried to run in LINQPad:

// Define other methods and classes here public class Order{ public int OrderId{get;set;} public string Item{get;set;} public int Quantity{get;set;} }


And here's the exception stack I'm getting:
![LINQPad_2863](https://user-images.githubusercontent.com/478118/54955863-c16ea800-4f0b-11e9-807e-aeec81245b22.png)

Feel free to close the issue if you don't think this is an appropriate execution environment.

Also,  I could send a pull request to fix the issue if you think it is appropriate to accept one.

Let me know.

Thanks!
Brian
douglasg14b commented 5 years ago

Thanks for the report.

Looks like the padding method is the issue since it relies on a console to check the width.

I think wrapping it in a if(Environment.UserInteractive) { //padding code...etc } should do the trick?

If you have the ability to test that, let me know if it does.

A pull request is always welcome.

bchavez commented 5 years ago

Yea, that looks like it!

I was thinking about adding something like TableConfiguration.VirutalWidth (or ForceWidth or whatever) which would be set and take precedence over of Console.WindowWidth when in UserInteractive is true.

What do you think?

Also, can I change the compilation targets to cross-compile to net471, netstandard1.3 and netstandard2.0? Only compiling to netstandard1.6 seems to download the entire Internet and lead to some dependency hell with LINQPad when adding a NuGet reference. I vaguely remember the recommended guidance now is to directly target full framework and netstandard2.0 (if you have a compile target less than netstandard2.0, in this case 1.6).

I can't remember where I read it, but I can look it up if needed.