DISQUS

Miguel de Icaza's blog: Interactive C# Shell - Miguel de Icaza

  • RichB · 1 year ago
    You need to play with Firebug's Console. it's the best immediate window around. For starters, try executing:
    console.dir(console)
  • Joe Shaw · 1 year ago
    Man, you have no idea how many times I wished I had this for Beagle. It would also be create if you could create a "manhole" system like Twisted in Python where you telnet to a socket and can use this inside the running program's process space.

    One thing that sticks out for me is that it sucks that you have to LoadAssembly() or LoadPackage() and then import with the "using" statement. A nice extension might be to modify the "using" statement to make it easier. For example:

    using System.Xml.Linq;

    might first try to look for an equally named assembly (System.Xml.Linq.dll) and load from there. If there isn't a 1:1 mapping, you could do something like:

    using Mono.Unix from Mono.Posix;

    or

    using Gtk from pkg:gtk-sharp-2.0;

    and have it load from a differently-named assembly or pkg-config package.
  • migueldeicaza · 1 year ago
    I agree that having the LoadPackage/LoadAssembly followed by a repertoire of using statements is annoying; Perhaps I need an "import" command that will do a combo: LoadPackage/Assembly and import all the namespaces defined on it?

    I like your suggestion for extending the using syntax to import namespaces; We could also have:

    using * from pkg:gtk-sharp-2.0;

    The feature shall be implemented shortly.

    As for "manhole", keep your eyes open for the next post, I did not want to give everything away on the maiden post of Mono.CSharp.Evaluate().
  • blah lar · 11 months ago
    Don't do that... it's not C#
  • Eric · 1 year ago
    Very cool!

    I use booish and booi all the time, this will be another great tool for debugging.
  • Sidnei da Silva · 1 year ago
    Hi Miguel,

    I really love what you've done here. It definitelly makes things a lot easier to try out, and I suspect that you took a clue from the interactive Python prompt.

    As for suggestions on what to improve on, I recommend taking a look at the IPython Tutorial (http://ipython.scipy.org/doc/manual/html/intera...). IPython is a full-featured interactive Python interpreter which every Python developer just loves.
  • Ed Ropple · 1 year ago
    Miguel, is there a day of the week you don't do something crazy-awesome? I mean, seriously, you make the rest of the community look positively blocked. :-P
  • Marc Brooks · 1 year ago
    This is very cool, thanks. Have you gandered at LinqPad? Very useful REPL shell for LINQ.
  • Peyroux · 1 year ago
    Beautiful work. Thanks !
  • Ted Percival · 1 year ago
    How did Hashtable turn /etc into /tmp? I sure hope /tmp is not cleaned on boot.
  • mmmm · 1 year ago
    Oops. That was me trying to simplify the formatting or the blog entry and
    Manually changing stuff after I initially wrote it
  • Andrew · 1 year ago
    I've wanted this exact thing for over a year now. Awesome.

    Perhaps a method to list objects one has created in the shell would be useful in addition to an Inspect method.

    What is the effect of GC on objects allocated in the shell? Are they persistent for the session without fear of being reclaimed?
  • migueldeicaza · 1 year ago
    This feature is already there, its the ShowVars method that you can invoke from the shell.

    As for lifetime, standard .NET lifetime applies: if there is a reference to the object, it stays alive. Any variables that you do not manually point to null will keep references to any objects you created.
  • Bruce · 1 year ago
    intellisense and tab completion
  • Anthony · 1 year ago
    Would be awesome if it would also be possible to use with Microsoft's csc compiler? Maybe using powershell's interactive type system. What do you think?
  • Carlos Alberto · 1 year ago
    Auto completion (bash alike) would be nice, too.
  • migueldeicaza · 1 year ago
    Microsoft's C# compiler is proprietary, so we can not do the work of turning it into a shell; Microsoft would have to do that.

    Our compiler is dual-licensed MIT X11 or GPL (pick your choice).

    But additionally, our compiler being written in C# significantly simplified the process of adding a REPL mode to it.

    Making it run under the .NET framework is the subject of a separate post.

    As for powershell: could you provide more information? I am not familiar with it, and I am curious as to what you have in mind.
  • Anthony · 1 year ago
    Miguel

    This blog starts to sheds some light on PowerShell's Adaptive Type System (ATS) and its use of adapters to .NET types

    http://blogs.msdn.com/powershell/archive/2008/0...

    this one shows more of the underlying type adaptor relationships

    http://blogs.msdn.com/powershell/archive/2006/1...

    And the free sample chapter 1 "Object and Object Types" from the Apress book "Pro Windows PowerShell" should finish off your questions

    http://www.apress.com/book/view/1590599403
  • Anthony · 1 year ago
  • Uriel Katz · 1 year ago
    nicely done!
    i was missing a shell like in python,what you can add is things like auto-completion,and enumerating the properties of a object like in IPython
  • migueldeicaza · 1 year ago
    Do you have more details? What is the way this is done there?
  • Anonymous Coward · 1 year ago
    Would this be suitable for writing 'shell scripts' in C#? #!/usr/bin/csharp style?

    Remaining anonymous as I'm ashamed I don't know enough mono to know if this is already possible. :P
  • migueldeicaza · 1 year ago
    It would be possible, its a good idea.

    Currently it executes as scripts all the files in ~/.config/csharp, but we should make it also run any scripts specified on the command line.
  • psantosl · 1 year ago
    I'd love to have #!/usr/bin/csharp scripts!!

    Ok, maybe something like /usr/bin/monoscript (or better name) so that it supports F# and the rest of the family too!
  • nachokb · 1 year ago
    Even though I don't do much C#, having used Ruby's irb, THIS ROCKS. I hope Java guys are watching this (as I have a few projects in Java).

    I'm intrigued about Joe's comment about Twisted's "manhole", as I never tried it...

    Keep the good work,

    -- nachokb
  • justizin · 1 year ago
    In Python, we have a __repr__ method to go along with __str__ - our rough equivalent of ToString, which are typically invoked by str(obj) or repr(obj). Also just printing a value typically gets repr.

    An Inspect() method is not a bad idear at all. You might look at some of the enhancements people have created for Python, which behaves like this by default, in the iPython shell.
  • Doug · 1 year ago
    Lovely! What I'd love to do is connect this to the Dynamic Language Runtime (DLR) and make it so that it could share data with IronPython, IronRuby, and the rest. This would be a great step in the classroom. Let me know if I can help.

    -Doug
  • migueldeicaza · 1 year ago
    I would love to see this happen!

    I refactored the C# shell into an Evaluator class, and it should now be easier to integrate in other applications, hopefully with the DLR as well.

    At this point, the real question is: which features do we need in the CSharpEvaluator class to make it useful for the above scenario?
  • Aleks · 1 year ago
    How accurate is the roadmap from:
    http://www.mono-project.com/Mono_Project_Roadmap
    ? Is there a chance that Mono 2.2. will be released in November?
  • migueldeicaza · 1 year ago
    We are on schedule, give or take a week or two.
  • halr9000 · 1 year ago
    That's pretty darn neat. I can see a lot of similarities to what you are doing with what a guy is doing with Pash, which is a mono-based version of PowerShell: http://pash.sourceforge.net/. You guys should join forces or something. :)
  • psantosl · 1 year ago
    I was going to propose something like that! Didn't know about pash
  • Anonymous Coward · 1 year ago
    Python, Ruby interpreters and others had this for years, you are just catching up now. .NET sucks.
  • psantosl · 1 year ago
    keep yourself anonymous...
  • Anonymous · 8 months ago
    Python and Ruby are dynamic languages. Most dynamic languages have interpreters.
    C# is not a dynamic language, and don't have a REPL.

    And .NET have IronPython, IronRuby and PowerShell, all have REPL's.

    So you can't say that .NET sucks.

    And yes, Microsoft sucks.
    But Mono isn't Microsoft.

    Troll.