Support C# Syntax and Other .NET Languages
To start with, PowerShell is really awesome. It is great to see it progress and mature as it has over the years.
One of the issues I (and other .NET developers I know) have had with this great scripting solution is that it is based on .NET, but the way in which you write scripts for it is not based on any language that .NET has known.
That is, it seems as if PowerShell is a .NET technology, and supports only one language. This seems to fly in the face of the spirit of .NET, where its intent/value was to offer a platform where numerous languages could be used to access a multitude of namespaces, components, and assemblies -- and the functionality afforded by these powerful elements.
It would be great to see C# and all .NET languages be able to access the convenient scripting power that PowerShell provides.
Thank you for any consideration and feedback!
Matt M. commented
Are you just looking for a C# REPL (run C# code ad-hoc)? If so, that already exists:
Sorry for the delay here, I didn't have comments updates enabled.
I am basically wanting to use C# syntax to create the scripts, exactly how I would create a C#/.NET application, but within a shell (as you point out, Bill).
Right now PowerShell is ".NET" but it is in a totally different paradigm (or way of development) from a typical .NET/C# application. The idea here is to converge the two camps to allow one to easily interface with the other.
Hope that makes sense. :) Please let me know if you have further reservations/questions.
Also, @Anonymous... can you provide an example of C#-syntax/usage in PowerShell? It would be very useful to see what you are referencing!
You are mentioning you want C# to "be able to access the convenient scripting power that PowerShell provides". That's already available.
Reference System.Management.Automation and run as much PowerShell as you want, complete with rudimentary object type mapping for return and full control over the host, all in C#.
And for the easy inverse, you can reference .NET assemblies from PowerShell scripts AND you can write binary PowerShell modules directly in C#.
PowerShell already supports C#-like method/function syntax, C#-like class declaration, and C#-like fields.
I'm honestly not sure how much more integration you want, before PowerShell stops being a shell scripting language (hence the name), and just becomes a .NET language with worse syntax than any of the existing ones...
Bill Kempf commented
You may have to explain this better, but this doesn't make sense to me. Most languages aren't designed to be scripting languages. Even CSScript made a lot of changes to bend C# in ways to make it viable for scripting. Far more important, though, is PowerShell is NOT a scripting language either. It's a shell language. Part of that means, yes, it's designed for writing script. However, it's just as much designed for use in the interactive shell, including the concept of piping. I don't see how you'd adapt C# to that, and even if you did I'm not sure you'd recognize it as C# anymore.
I can use C# (or any other .NET language) in my PowerShell scripts today using Add-Type. What more would you want? What is it your actually proposing?