• Simplify Integration Testing with Testcontainers

    #csharp #testing

    Integration tests play an important role in software development. They help us see how the system works with volatile dependencies, such as databases. To run the integration test with the database, we need somewhere to create this database. It can be deployed on a virtual machine or even on a local host. However, it’s best to use Testcontainers framework.

  • The 16-Byte Rule: Unraveling the Performance Mystery of C# Structures

    #csharp #benchmark

    Many C# developers are familiar with the following statements. By default, when passing to or returning from a method, an instance of a value type is copied, while an instance of a reference type is passed by reference. This has led to a belief that utilizing structures may degrade the overall app performance, especially if the structure has a size greater than 16 bytes. The discussion about this is still ongoing. In this article, we will try to find the truth.

  • What's wrong with the Options pattern in C#?

    #csharp

    In .NET, there is a so-called Options pattern that simplifies the way we handle application configuration. To use it, developers just need to follow three steps. First, add the necessary configuration provider. Second, set up Service Provider using Configure extension method. Third, inject either IOptions<T>, or IOptionsMonitor<T>, or IOptionsSnapshot<T> into the target class through constructor injecting.

  • What is ReadOnlySpan<T> in C# and how fast is it comparing to strings?

    #csharp #benchmark

    I already wrote an article about the fastest way of extracting substrings in C#. Now I want to investigate Span structures more. Recently, Microsoft released the .NET 8 platform which has several new extension methods for ReadOnlySpan<T>. So I want to compare the performance of MemoryExtensions methods with counterparts in string class.

  • Fastest way to extract a substring in C#

    #csharp #benchmark

    Today, we’ll dive back into a microbenchmarking and a concise article about performance in C#. Our focus will be on strings and the most effective way for extracting a substring from the original string.

  • Performance issues when using a method as a parameter in C#. Are they real?

    #csharp #benchmark

    There is an article on Habr about performance issues when passing a method as a parameter in C#. The author showed that passing an instance method as a parameter inside for loops may degrade performance and increase memory consumption due to unnecessary object allocations in the heap. In this short article, I want to repeat the original benchmark and compare how things have changed since the .NET 7 release.

  • How to call Program.Main method if you're using top-level statements

    #csharp

    Lately, I’ve been writing a lot of services that use top-level statements. The code with this kind of syntax sugar simplifies the Main method and improves readability. However, on the other hand, it makes it more difficult to create integration tests for the services. There isn’t simply way to call the Main method and pass the necessary arguments.

  • Create secure React SPA + ASP.NET Web API with Keycloak OAuth2

    #csharp #aspnet #typescript #react #docker #oauth2 #keycloak

    This is a step-by-step guide how to create a full stack secure application with OAuth2 authentication.

  • Understanding Domain-Driven Design. From Anemic Domain Model to Rich Domain Model.

    #csharp #ddd

    I recently read the book Learning Domain-Driven Design on the advice of my mate, who is more experienced in development than I am. I’ve already written a small review about this book in my Telegram channel (it’s in Russian). Now, I’m going to write a series of articles about how Domain-Driven Design (DDD) can improve your code and software development process. This is the first article in this series.

  • Impact of EF mapping strategy on SQL queries performance

    #csharp #efcore #sqlserver

    Entity Framework (EF) is a popular object-relational mapping framework used to interact with databases in .NET applications. EF offers different mapping strategies, each of which affects the database schema and how EF interacts with the hierarchy of .NET types. In this article, we will examine how these mapping strategies affects performance in SQL Server.

  • How to create text annotations using React and TypeScript

    #typescript #react

    I changed my job last November and became a Full Stack Developer in a new team. Now I have lots of work related with frontend, especially with React and TypeScript. A few weeks ago, I had a task to implement annotations support in our application that we are developing. This article briefly describes the approaches that can be used to create an application with text annotations.

  • Как создать блог на GitHub

    #blogging #github #jekyll #markdown #html

    Многие программисты имеют свой блог, в которых пишут свои заметки. Очень часто блог реализован на Jekyll, Hugo или Gatsby.js, а для хранения, деплоя и хостинга используется GitHub и GitLab. В этом гайде я расскажу, как реализован мой блог на Jekyll и GitHub.

  • Функциональное программирование на F# (часть 2)

    #dotnet #fsharp #csharp #functional_programming

    В прошлой статье мы написали модуль для расчёта ряда Фибоначчи практически не углубляясь в детали того, что из себя представляет F# и чем он отличается от кода на C#. В этой статье мы рассмотрим основные принципы функционального программирования, некоторые базовые языковые конструкции F# и исследуем скомпилированный код.

  • Функциональное программирование на F# (часть 1)

    #dotnet #fsharp #csharp #functional_programming

    Недавно прочитал книгу 1 “Unit Testing Principles, Practices, and Patterns” Владимира Хорикова. Книга классная, фундаментальная. В плане полезности для .NET backend разработчиков, по-моему, стоит на уровне CLR via C#, Dependency Injection in .NET, Patterns of Enterprise Application Architecture и т.д. Помимо вопросов тестирования, она также вкратце объясняет вопросы функциональной архитектуры и то, как такая архитектура положительно влияет на возможность тестирования кода. Ранее мне не приходилось сталкиваться с функциональными языками программирования, но после прочтения книги очень захотелось поработать с ними. Поскольку я C# разработчик, то проще всего было начать изучать функциональное программирование с другой разработкой Microsoft - языка F#. В этой статье мы попробуем реализовать один и тот же алгоритм в функциональном стиле на C# и F# и сравнить результат.

  • Коварный enum в .NET

    #dotnet #csharp #wcf

    Перечисления - это такой тип данных, который выглядит очень просто и его легко использовать. Вот только за этой простотой скрывается коварность. Почему? Потому что enum - это ValueType, а ValueType в C#, как известно, не наследуется. Необдуманное использование типов, которые нарушают принцип Open / Closed, может создать проблемы в вашем проекте в будущем.