How to correctly count the number of characters of a string

  • .NET
Counting characters may seems trivial. You can just use the string.Length property, can't you? Unfortunately, this is not that trivial. If you remember my previous post about comparing strings, you know that strings can be very tricky 😃 Let's use the character 👨‍👩‍👧‍👦. The "Family: Man, Woman, Girl, Boy" emoji is a sequence of the 👨 Man, 👩 Woman, 👧 Girl and 👦 Boy emojis. These are combined using…[read more]

How to protect against XML vulnerabilities in .NET

  • .NET
  • Security
Lots of applications use XML files. For instance, this blog has RSS and Atom feeds that are XML documents. Application can communicate using SOAP. You can use XML serialization. But most the applications use only a subset of the XML features. When you start exploring the rest of the specification, you can find some possible vulnerabilities when dealing with XML documents! Let's explore some of them and…[read more]

Enforce .NET code style in CI with dotnet format

  • .NET
  • Azure DevOps
  • Azure
In a previous post, I wrote about using an .editorfile to define the coding style. Visual Studio understands this file and provides quick fixes to make your code match the coding style. You can easily rename symbols and add spaces where it's needed. However, it's easy to miss some warnings and commit a code that doesn't match the coding style. In this post I'll show you how to enforce the coding style by…[read more]