Static code analysis with NDepend

[Disclaimer: Patrick Smacchia from the NDepend team approached me and offered me a licence for NDepend if I would blog about my experiences with the tool. However, all opinions are my own.] Static code analysis is a powerful tool to understand and improve your codebase, using a variety of techniques…

MongoDB doesn’t serialise C# read-only properties

C# 6 introduced getter-only auto-properties, which are a great way of conveying immutability for your classes. However, by default MongoDB ignores these properties from its class maps, as it can’t deserialise them back into a class. To automatically map read-only properties, you can use a custom convention: /// <summary> ///…

MongoDB backup script

You can run this on a scheduled task and it will take a backup of all databases, zip it and copy it to a backup location, and automatically remove older backups after 7 days. REM Create filename for output set filename=mongodb-backup-%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%__%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2% REM Export the databases @echo Dumping databases to “%filename%”…

Diagnosing issues with Elasticsearch

We use logstash in our infrastructure, which ingests logs and outputs transformed data to a store of your choice, which for us is Elasticsearch. We then use Grafana to visualise some of this data. Recently we noticed that Grafana was struggling to perform the queries it needed, which led to…

Disk Cleanup on Microsoft Windows Server

Servers run out of disk space too sometimes, but the Server versions of Windows don’t have the handy Disk Cleanup utility installed by default. If you want to get it back, you can run this Powershell command: Install-WindowsFeature Desktop-Experience or you can follow the instructions here if you’re more of…

TeamCity build fails with “no net in java.library.path”

One of our builds just failed with this fairly cryptic error: [File content replacer] no net in java.library.path java.lang.UnsatisfiedLinkError: no net in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) Turns out we’d manually updated Java on the machine that the build agent was running on. If you…