In one sentence, XSharper is a framework and scripting language for writing Windows console and simple GUI applications quickly, with or without Visual Studio.
But it's actually many things at once:
- a free open source framework with useful classes for writing simple programs in C#, dealing with common issues from parsing command line parameters and Vista/Windows7 UAC to evaluating expressions and graceful Ctrl+Break handling
- a tool to replace Windows .BAT files with something that is more reliable
- a scripting language that is useful without the learning curve, that does not require installation, yet with IntelliSense support in Visual Studio
- a language that can be easily compiled to single file executables or translated to human-readable C# code, to be used independently or to extend functionality of other products
- a way to quickly produce utilities of decent quality, which are easy to write and easy to use
- a Swiss-knife tool for writing, compiling, debugging and running code from the command line on any Windows computer. Visual Studio not required. .ZIP support is built in.
- a way to script SQL commands and greatly simplify database deployment and initialization
- a simple framework to automatically upgrade complex software, consisting of many modules and SQL databases, on multiple computers on the internet from a single repository
- a bunch of C# files that solve problems frequently encountered when writing .NET applications, from accessing 32 and 64 bit registry to parsing and interpreting C# expressions, from producing readable debug output to invoking C# compiler
- a program that can easily print is own source code
- many other things
Parts of XSharper can be used as independent source code files too. For some, an extensive description exist:
There are many other pieces in XSharper source code that can be used without creating a dependency on the whole XSharper.Core assembly.
Compared to other tools
XSharper development was inspired by many different tools and frameworks, from ASP.NET to parts of Windows Workflow Foundation, from Microsoft Build XML projects to special scripting languages like Microsoft PowerShell.
In many ways XSharper is to Windows console applications what is ASP.NET to Web applications. It's a framework that consists of multiple simple classes, from parsing user input to downloading files, from formatting output to evaluating expressions and executing SQL, that boost productivity considerably.
Certain frequent operations may be combined into actions, that may be further glued together with XML, producing a simple language where programs can be written without any C# code, not unlike ASP.NET or MS Build scripts. Like ASP.NET, XSharper program using XML syntax may be interpreted or converted to C# source code or .EXE file in a single step, and even back from .EXE to XML. Because it's a framework, it's also possible to glue XSharper actions and classes with PowerShell, Visual Basic, or any other .NET programming language.
As XSharper can also be used as a general purpose scripting language, it may be also compared to Microsoft PowerShell. Both PowerShell and XSharper are languages, and both can be used to replace Windows batch files, producing more readable and more reliable code. There are, however, important differences:
- PowerShell is primarily a shell for non-programmers to automate administrative tasks on one or multiple computers. As a scripting language, it's a powerful language with its own unique syntax. An explicit installation is required on XP/Vista/Windows 2003/Windows 2008 machines. Even though it is free, it is not open source, and is not redistributable either, so using PowerShell scripts adds prerequisites to your application.
- XSharper is open source, free, redistributable, and requires no installation or administrative rights. .NET 2.0 installed is the only prerequisite. Even XSharper itself is not required, as any script can be compiled into .exe file easily. And Powershell scripts can be run from XSharper too:
<include from="#/powershell.xsh" withTypes="true" />
$dirs = dir
$dirs[0..3] | Write-Host
A little example
If you know C#, using XSharper is as simple as
<% Console.WriteLine("Hello, World!") %>
Below, for example, is a screenshot XSharper console program ("demo"), which prints some text, its own source code, runs some C# code, then DIR command. All that is executed from another XSharper console program (gui-console, available in Library) as
C:\>XSharper #/gui-console.xsh demo.xsh
There are many other examples in Library.