C#

Blog posts tagged by C#

How to write a stateful Roslyn analyzer

I wrote a stateful Roslyn analyzer a couple of days ago to analyze the codebase at work for irregularities, and I thought I would share my findings on how I did it.

Generating API clients using AutoRest

This blog post looks at automatically generating an HTTP API client from a OpenAPI specification (formerly swagger) using AutoRest.

An introduction to Spectre.Cli

I've been writing a lot of CLI apps, both at work and in my free time, and there's never really been a command line parsing framework that has fitted my needs. While being either too complex or too simple, it's always nagged me that I need to write so much code myself. What I wanted was a way to be declarative about my commands, options and arguments while still allowing composition of them.

Binding to a RichTextBox in WPF

I've been doing some WPF development the last couple of weeks, and one thing that bugged me was that there is no way (as far as I know) to bind content to a RichTextBox. This makes it kind of difficult to follow the MVVM pattern since the view model needs intimate knowledge of the view.

Conditionals in XAML

Ever wanted to display things conditionally in XAML based on a pre-processor directive like `DEBUG`?

Using embedded resources in xUnit tests

I was reading Andrew Lock's excellent blog post about Creating parameterised tests in xUnit when I remembered something I wrote a while back that has proven to be quite useful.

Script aliases

Cake supports something called script aliases. Script aliases are convenience methods that are easily accessible directly from a Cake script. Every API method in Cake is implemented like this.

It's not a party without Cake

I have during my nine years as a (professional) programmer used several different build automation systems such as Rake, psake, CMake, TFS Build and FAKE, but none of these have allowed me to write my build scripts using C# - the language I use the most.

BinaryWriter and C++

A while back I had to read string data written by .NET's BinaryWriter in C++. I was initially a little bit confused about how the data was written but after using Reflector it turned out that the write method prefixes the string with a 7-bit encoded integer.

Culture agnostic string comparisons

Something I've seen a lot at different clients is naive string comparison. The most common case is to do something involving String.ToLower() on both strings that are being compared and then an equality comparison of the result.