Vaughan Reid's blog

What I learnt attending the Microsoft build online event

A major positive of the whole world working from home is that events that you would normally have to travel to are now online for everyone. Thats a huge saving in time and money for someone in South Africa. This year I was lucky to be able to attend the Microsoft Build event hosted in Seattle. Because of time zone issues I only attending the event on the 20th May but there was still quite a lot of content that was available in my timezone.

Github Code spaces

One really interesting development is that github is bringing out a new feature called code spaces.

When its enabled, Github has a open codespace button in github project source pages and pull requests pages. Clicking this button will load the code into a browser based visual studio code. It will allow you to run it and make changes with all of the processing happening in azure.

I haven’t had a chance to play around with it yet other than watching the demos but have requested early access. The demos look great and its really interesting in how you are able to even run web apps that would run on localhost and the environment magically loads a hosted link that connects.

My one question that I don’t think was answered is how much it would cost. It maybe doesn’t matter much for large companies but if I were to use it in my personal projects, what would I have to pay for these resources?

Visual studio - Code space integration

Also part of the code spaces offering is the ability to use it within visual studio. Mads Kristensen explained how people with underpowered machines can offload all the processing to code spaces as long as the project is hosted in github. His demo showed him loading the project and selecting what spec VM will do the processing. Then all the build events and output actually gets streamed from azure. Its a really interesting approach. I’m also not sure about cost on this one.

Update: This article gives basic pricing. If correct then you can run your code with 8 cores and 16GB RAM for $0.34 an hour.

Dapr

While its not that new, its the first time I saw a demo. Its a really interesting approach to microservices. Basically you deploy their service as a side car application and it supports things like pub/sub and retrieving/saving into storage. You configure Dapr with a yaml file on how to connect to the provider and then its apparently ready to work.

Dapr will then interact with you application through either http or gRPC endpoints. In ASP.NET Core you can attribute your api action with for example a Topic attribute to get it to receive event updates. eg:

[Topic("deposit")]
[HttpPost("/")]
public async Task<ActionResult<Account>> Deposit(Transaction transaction,[FromServices] DaprClient daprClient)
{

}

In theory there is a deposit pub/sub configuration in dapr that will handle connecting to say RabbitMQ and pass on messages into this action as if there was a http call. You can also save a response to a configured storage by interacting with the injected client.

Azure Arc enabled kubernetes

To be honest I don’t 100% understand all of this offering but my understanding is that it allows on prem kubernetes to get configuration and basic access to azure services. He explicitly mentioned that there is Rancher support.

Some tooling updates

winget

Windows now has a package manager called winget. It also will have chocolately integration.

Microsoft PowerToys

This isn’t new but its new to me. PowerToys gives a little more power to your windows install. You get things like more controlled windows splitting and running multiple desktops.

windows subsystem for linux

You can run linux within you windows install and with this you can browse you linux file system in windows explorer.

Windows Terminal

Also not new other than it having a new release but Windows Terminal is much better than directly using cmd.

Dependabot

Dependabot has a silly name but quite a nice idea. Basically it looks at your project dependencies and looks for package updates. If it finds them then I will create a pull request with all the release notes.

C# 9.0 changes coming

Mads Kristensen showed some of the changes coming in November with .NET 5 and C# 9.0. Most of it is around immutability and writing less boilerplate code.

A lot less to write in your program.cs file.

I don’t really like this change but maybe it will grow on me. In you entry point class you can now exclude a lot of the boilerplate.

So this:

using System;

class Program
{
	static void Main(string[] args)
	{
		Print("Hello world");

		static void Print(string text)
		{
			Console.WriteLine(text);
		}
	}
}

Will be the same as:

using System;

Print("Hello world");

static void Print(string text)
{
	Console.WriteLine(text);
}
	

init auto properties

This is kind of like a readonly property with auto intializers.

You will be able to define a class like this if you don’t want the initially set values to change.

class Person
{
	public string FirstName {get;init}
	public string LastName {get;init}
}

The second line of code below will give a compiler error when trying to change the LastName because of the init modifier.


var person = new Person{
FirstName = "Joe",
LastName = "Soap"
};
person.LastName = "Soap2"

Records

You can make a class immutable by making adding the data modifier. Eg:

data class Person
{
	public string FirstName {get;set}
	public string LastName {get;set}
}

This is now a value type similar to a struct but it supports inheritance. equals now compares equality on each property not references.

There is a short hand for this which is the same as above.

data class Person
{
	string FirstName;
	string LastName;
}

If you want to pass them into the constructor you can define it like this as well:


data class Person(string FirstName,string LastName);

there is also now a with keyword that you can copy a whole record and change a value in the new copy. eg:

var otherPerson = person with {LastName = smith}

parameter null checking

This will now do a null check on the parameters of this method if there are ! on the parameters.


Public Person Get(string firstName!)
{
	return new Person();
}

Covariant returns

Derived classes can return derived types when overriding methods. This one is quite nice!


class Person
{
	virtual Person Get()
	{
		return this;
	}
}

class Student : Person
{
	override Student Get()
	{
		return this;
	}
}

Minor visual studio layout changes

Save windows layout

You can now save a layout stucture with the menu

Window=>save window layout

and then load the layout that makes sense with a key shortcut or the menu.

Window=>apply window layout

Move tabs to left or right to free up vertical space

right clicking on your tabs and selecting the Set Tab Layout option allows you to dock them to the left.