Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are .CSX C# files for?

Tags:

c#

csx

I've heard of .cs files but never of .csx files. Google searches led me to CSX corporation and other unwanted bodies. Can someone provide a terse description of what a CSX file is, and perhaps the main differences between CSX and CS?

like image 241
Robin Rodricks Avatar asked Aug 20 '14 13:08

Robin Rodricks


People also ask

What is CSX short for?

CSX Transportation (it's name deriving with the “C” standing for Chessie, “S” for Seaboard, and “X” an all-encompassing multiplication symbol that “together we are so much more”) is the railroad division of CSX Corporation. The latter was originally created in 1980 as a holding company for several subsidiaries.

What is CSX rail?

Founded in 1827, CSX is a Class I railroad, one of seven in North America. CSX employs approximately 25,000 people. CSX serves 23 states, the District of Columbia and two Canadian provinces. The network connects major metropolitan centers in the eastern United States.

Is CSX a good stock to buy?

Out of 17 analysts, 7 (41.18%) are recommending CSX as a Strong Buy, 4 (23.53%) are recommending CSX as a Buy, 5 (29.41%) are recommending CSX as a Hold, 0 (0%) are recommending CSX as a Sell, and 1 (5.88%) are recommending CSX as a Strong Sell.


1 Answers

It is a C# Script File introduced with Roslyn:

C# Script File (.csx) Editing Support: The CTP introduces a concept of a C# Script File. You can create a .csx file [...]

[What is Roslyn? .NET Compiler Platform, also known by its nickname Roslyn, is a set of open-source compilers and code analysis APIs for C# and Visual Basic .NET languages from Microsoft.]

You don't have to have everything in a class and method, a csx file is like it's own method, and everything in the file will be executed on start. It also supports some additional directives (like #load to load another script).

The Scripting Api provided in Roslyn, while being promising, has some severe flaws:

Scripting APIs require desktop .NET Framework 4.6+.

  • It means it was not cross-platform. (but with .NET Core, now it should be).
  • The syntax of C# is not really script oriented (too verbose)
  • The directives available while mandatory are not sufficient to cover the broad scope of a CLI (like powershell). For exemple, there is no cd, alias, pwd, ls, exec or the like.

There are several scripting engines which are based on it (or on the underneath Roslyn) or at least on the same format, while providing more advanced directives. So, it means a csx file should run on one of the following:

  • Nake (run on .Net Framework and Mono)
  • dotnet script (run on .NET Core)
  • ScriptCS

Beware, even if they share a common base, they are not cross-compatible, since there is no standard on the extensions they implement.

like image 67
Juri Robl Avatar answered Sep 27 '22 18:09

Juri Robl