Skip to content

Conversation

@gregoryyoung
Copy link
Contributor

@gregoryyoung gregoryyoung commented Apr 19, 2016

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
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
Contributor

Let's get a unit of acceptance test


public void Print(object o)
{
Console.WriteLine(_printers.GetStringFor(o));
Copy link
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
Contributor

Awesome work, thanks!

Make sure to add your name to our contributors page!

@filipw
Copy link
Member

filipw commented Apr 19, 2016

👍 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