C# 9 Deep Dive: Records | Dave Brock

In the previous post of this series, Dave Brock discussed the init-only features of C# 9, which allowed us to make individual properties immutable. That works great on a case-by-case basis, but the real power in leveraging C# immutability is when we can do this for custom types. This is where records shine.

This is the second post in a five-post series on C# 9 features in-depth.

Source: C# 9 Deep Dive: Records | Dave Brock

My Daily Toolbox

tool, wrench, toolbox, repair, work, metal, workshop, mechanic, HD wallpaper
Toolbox

We all have our favorite tools. Here is the other stuff I use, in no particular order!

RAD Studio Enterprise (10.3.3)
Yes, I am oldschool, but this old dog knows a lot of new tricks. There is no better way to do Windows GUI, and possibly cross platform GUI.

FinalBuilder / Continua CI (Current)
If you are not using at least one of these, you are missing out! Finalbuilder helps your Delphi builds keep their configurations straight, and Continua CI is an amazing orchestrator that detects your commits and starts your builds, unit tests, integration tests, build your installers, push the latest build the the appropriate staging areas, and much, much more.

Beyond Compare Pro (Current)
Is it the same, or different? This is my favorite comparison tool. Stable and awesome and plugs nicely into SVN and git.

TextPad (Current)
For powerful RegExp, Macros and handling massive text files.

VS Code (Current)
This thing is rapidly becoming one of my favorite editors for PowerShell and SQL.

Visual Studio Enterprise (Current)
Still can’t do without it.

SQL Server Management Studio (Current)
When you need to find out why your SQL sucks.

ApexSQL Developer Pack (Current)
When you need to sync schemas or data, and beyond.

PowerShell 7 (Current)
It is absolutely a programming language in it’s own right. You need to learn this tool as it can really do some serious OS level, cross platform scripting! 

Windows Terminal (Current)
Very handy for CLI work. Use Bash, PSH 5.x, PSH 7.x or cmd in the same container, at the same time.

Process Hacker 2 (Current)
TaskHandler on steroids. What threads are running, how has that memory been trending, so many features!

PowerToys (Current)
A growing collection of useful gadgets for your desktop.

GreenShot (Current)
Screenshots galore – and mine are automatically uploaded to my Google Drive.

PostMan (Current)
For all your REST/SOAP/JsonRPC/<web tech> protocol testing.

Remote Desktop Manager Enterprise (Current)
Too many dang servers! For all your remoting needs, it has a very large collection of integration options.

VNC (Current)
When you need to remote to the unremotable.

FileZilla (Current)
Fine Transfer Program.

PeaZip (Current)
Compress the world.

Oracle VirtualBox (Current)
Where to test your stuff without blowing up your workstation.

Paint.NET (Current)
Compact, capable, and easy to use image editing program.

TortoiseSVN (Current)
Does that make me the hare?

Github Desktop (Current)
git gud!

Inno Setup (Current)
When you need an installer, this has you covered, although I am leaning towards Powershell these days.

IcoFX (Portable 1.6.4, the last free version)
Handy icon designer

Chrome and various Google Services
Drive / Docs / Photos / Keep, Meet, etc. etc.

Teams
Which has totally replaced Skype and Skype for Biz as well as Slack

Office 365
You know what I am talking about

What are you using?

Preview any text file

The preview pane in the File Explorer will preview .txt files, but it will not by default allow you to preview .json, .pas, .dpr files and many other files, even if they really are text files.
Luckily, there is a simple remedy for this.

Locate the extension you want to view as text – f.x. .json

You will find it under
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.json
or
HKEY_CURRENT_USER\SOFTWARE\Classes\.json

Add a REG_SZ string named “PerceivedType” and give it the value “text”

This will instantly allow you to preview .json files in File Explorer. No restart needed, just click on the file name again.

Another example, is the Delphi .dpr files that do not preview.

Add the PerceivedType key for .dpr

and voila

Not rocket science, but kinda handy.

Migrating your Editor Colors to Delphi 10.4 Sydney

RAD Studio 10.4 Sydney introduces Custom themes for editor colors. Here is how to migrate your 10.3 settings to 10.4.

First, we make a custom color theme in 10.4 – go to Options | User Interface | Editor | Color.
With the current colors, just click on [Save As] and and give your personal scheme a name. 
I called mine Lars.

This creates a Registry branch, named HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Editor\Highlight\Custom themes\Lars

In RegEdit, go to HKEY_CURRENT_USER\Software\Embarcadero\BDS\20.0\Editor\Highlight (i.e. the Rio branch)

Export to a file, f.x. MyColors.reg

In MyColors.reg, you’ll see

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Embarcadero\BDS\20.0\Editor\Highlight]
[HKEY_CURRENT_USER\Software\Embarcadero\BDS\20.0\Editor\Highlight\Additional search match highlight]
... and so on

Now, Open MyColors.reg in Notepad, search for “20.0\Editor\Highlight\” and replace it with “21.0\Editor\Highlight\Custom themes\Lars”.

Add the two branch paths for good measure.

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Editor\Highlight]
[HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Editor\Highlight\Custom themes]
[HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Editor\Highlight\Custom themes\Lars]
[HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Editor\Highlight\Custom themes\Lars\Additional search match highlight]
... and so on

Import the file into the registry, Restart the 10.4, go to Options | User Interface | Editor | Color and pick the custom theme “Lars”.