-
Scriptcs : The Tooling
- Part 1 - Getting Started
- Part 2 - Up & Running
- Part 3 - Becoming more productive with Scriptcs
- Part 4 - Raising the bar with better abstractions
- Part 5 - Doing something Useful
- Part 6 - Tools to make you productive
Tools really make the ecosystem more productive. I list down some of the tools that I have found to be useful.
Version Management
We can have multiple version of ScriptCS installed on the system. Then to pick which one to use we can use the ScriptCS version Manager SVM This is essentially similar to npm and helps keep track of different scriptcs versions.
Running the code
Sublime Plugin : Sublime Plugin
It is a little dodgy on mac, windows will work just fine.
Atom Runner : The wiki has a good guide on how to start with Atom and Scriptcs Atom I did struggle quite a bit with getting this to work neatly on mac initially things seem to be better now.
Omnisharp : One of the most active and loved .net projects. Omnisharp also has support for ScriptCS. Omnisharp
This was a short tour of the tools and hopefully this gets you on your way.
With this we round up our tour of ScriptCS, it is a great project that continues to make little improvements to my every day workflow.
-
Scriptcs : Doing something Useful
- Part 1 - Getting Started
- Part 2 - Up & Running
- Part 3 - Becoming more productive with Scriptcs
- Part 4 - Raising the bar with better abstractions
- Part 5 - Doing something Useful
- Part 6 - Tools to make you productive
We now have a fair grasp of how to swing with ScriptCS. Let's try and do something more useful with it.
Let's start by talking to a redis instance. Talking to a running instance interactively is a great a capability to have.
scriptcs -install StackExchange.Redis using StackExchange.Redis; var redis = ConnectionMultiplexer.Connect("localhost"); var db = redis.GetDatabase(); db.StringSet("foo","bar"); var result = db.StringGet("foo"); Console.WriteLine(result);
-
Scriptcs : Better Abstraction
- Part 1 - Getting Started
- Part 2 - Up & Running
- Part 3 - Becoming more productive with Scriptcs
- Part 4 - Raising the bar with better abstractions
- Part 5 - Doing something Useful
- Part 6 - Tools to make you productive
Abstractions are what drive most of software development. ScriptCS also has a few abstractions which bridge the gap between the existing frameworks and the notion of scripting and REPL.
From the github wiki
Script Packs allow you to bootstrap the environment for new scripts, further reducing the amount of code necessary to take advantage of your favorite C# frameworks.
-
Scriptcs : Becoming Productive
- Part 1 - Getting Started
- Part 2 - Up & Running
- Part 3 - Becoming more productive with Scriptcs
- Part 4 - Raising the bar with better abstractions
- Part 5 - Doing something Useful
- Part 6 - Tools to make you productive
Last time we got up and running with Scriptcs. We have done everything in the REPL so far. When it comes to scripts we need a few more things to make everything easy.
Roslyn allows us to load assemblies using the #r directive.
#r System.Data #r System.Net.Http
Roslyn does not give us the power to load multiple script files. Scriptcs helps us out here by giving the #load directive.
HelloWorld.csx Console.WriteLine("Hello World"); MyWorld.csx #load HelloWorld.csx Console.WriteLine("MyWorld"); //output Hello World MyWorld
The loading of scriptcs is recursive and the script that gets loaded first gets executed first. Scriptcs also ensures that only one version of the script is loaded at a time (e.g. File1 loads File2 & File3 and File2 also loads File3).
-
Scriptcs : Up & Running
- Part 1 - Getting Started
- Part 2 - Up & Running
- Part 3 - Becoming more productive with Scriptcs
- Part 4 - Raising the bar with better abstractions
- Part 5 - Doing something Useful
- Part 6 - Tools to make you productive
Last time we saw how we could get Scriptcs up and running. Before we go further, it would be nice to know what is going on.
Roslyn enabled in-memory compilation which means we can finally take loose C# code and start running with it. In code terms it means we can get rid of class Program public static void ....
We can valid C# statements and then move on to doing the real thing.
-
Scriptcs : Getting Started
- Part 1 - Getting Started
- Part 2 - Up & Running
- Part 3 - Becoming more productive with Scriptcs
- Part 4 - Raising the bar with better abstractions
- Part 5 - Doing something Useful
- Part 6 - Tools to make you productive
C# even though a really nice language has always been tied to Visual Studio. With mono we had the ability to write it on non-windows platforms as well. One other thing that mono had was the repl and the ability to script.
What is Scriptcs ?
- Use C# as a scripting language powered by Roslyn
- Uses the Rosyln nuget package
- No IDE, No dlls
- Xplat, CLI
- Lighter experience with faster feedback
-
Everyday utilities for a Windows developer - Contd.
- Part 1 - Everyday utilities for a Windows Developer
- Part 2 - Everyday utilities for a Windows developer - Contd.
From the previous post if you do end up using cmder mini like me then you should also register it and let it show up in the explorer.
cmder.exe /REGISTER ALL
This time we look at some utility programs that are often required when doing deeper analysis in a windows environment.
-
Everyday utilities for a Windows developer
- Part 1 - Everyday utilities for a Windows Developer
- Part 2 - Everyday utilities for a Windows developer - Contd.
As I have learned to use the command line more and more on windows I often get stuck due to lack of commands. This can be quite frustrating and if you switch between the *nix and windows then the gap can seem to quite alarming. In this post I will share some tidbits on how to overcome some of these pains.
First, do yourself and get a better console like Console2 or Mini Commander(or anything else that suits your style). Things are a bit better in Windows 10 (copy paste will be allowed on the command line) but that is still sometime away. If you are willing then I do suggest making the permanent shift to Powershell for all practical purposes, I don't see the windows command line (CMD) ever improving enough to make it my default console. Next, I describe some of the common things I do all the time.
-
Implicit and Explicit Operator in C#
One of the features that I have never used in C# is the implicit and Explicit keywords.
The definitive word from MSDN on explicit is "The explicit keyword declares a user-defined type conversion operator that must be invoked with a cast." Omitting the cast will result in a compile time warning.
The definitive word from MSDN on implicit is "The implicit keyword is used to declare an implicit user-defined type conversion operator." Implicit doesn't require an explicit cast and makes the syntax a lot easier.
-
NDepend Review
Patrick from NDepend wasgracious enough to give me a license for NDepend. I have been wanting to get my hands on such a tool for some time now, and as it turns NDepend is actually quite good. Let's have a look at what the hell am I a talking about.