Skip to content

Pretty Printing#1156

Merged
glennblock merged 3 commits into
scriptcs:devfrom
gregoryyoung:printer
Apr 19, 2016
Merged

Pretty Printing#1156
glennblock merged 3 commits into
scriptcs:devfrom
gregoryyoung:printer

Conversation

@gregoryyoung

@gregoryyoung gregoryyoung commented Apr 19, 2016

Copy link
Copy Markdown
Contributor

Pretty printing support for ScriptCS in REPL

(some of original changes are squashed in @glennblock commit)

$ scriptcs
scriptcs (ctrl-c to exit or :help for help)
> Env.AddCustomPrinter<int>(x => "testing " + x)
Adding custom printer for Int32
> 5
testing 5
>  

For running scripts without repl you can also use:

Env.Print(25)
testing 25

There is also an overload for Print< T >(T obj) that allows for Print(derived)

@glennblock and I were also discussing the possibility of extracting a Printers interface (a little odd in a test setup to pass the dependecy in).

As state before this is to open up conversation.

@glennblock

Copy link
Copy Markdown
Contributor

Cool!

@filipw this doesn't move to console but it does introduce a Print method on Env which can be called outside the REPL.

@glennblock

Copy link
Copy Markdown
Contributor

Let's get a unit of acceptance test

Comment thread src/ScriptCs.Core/ScriptEnvironment.cs Outdated

public void Print(object o)
{
Console.WriteLine(_printers.GetStringFor(o));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be _console?

@glennblock glennblock merged commit a252cd4 into scriptcs:dev Apr 19, 2016
@glennblock

Copy link
Copy Markdown
Contributor

Awesome work, thanks!

Make sure to add your name to our contributors page!

@filipw

filipw commented Apr 19, 2016

Copy link
Copy Markdown
Member

👍 thanks

@glennblock glennblock mentioned this pull request Sep 6, 2016
@glennblock glennblock mentioned this pull request Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants