Tuesday, November 16, 2021

How to use BenchmarkDotNet

If you want to measure the performance of your .NET code, you can use the BenchmarkDotNet NuGet package. Let's see what you can do with it.

Friday, November 12, 2021

Why do we need MediatR?

Recently I came across using the MediatR package in our source code. This interested me. Why should I use MediatR? What advantages can it give me? Here we'll discuss these topics.

Friday, October 1, 2021

How to use certificates in ASP.NET Core

Recently, the use of the HTTPS protocol for your Web resources is a mandatory requirement for all relatively large Web projects. This technology is based on so called certificates. Previously, you had to pay to get a certificate for your Web server. But now we have services like Let's Encrypt where you can get your certificate for free. This is why the price is no longer a reason not to use HTTPS.

In the simplest case, a certificate allows you to establish protected connection between client and server. But this is not all it is capable of. For example, I saw an online course on Pluralsight called Microservices Security. And there was one thing mentioned there, which is called Mutual Transport Layer Security. It not only allows client to make sure that it is interacting with the correct server, but also allows the server to authenticate the client.

This is why developers must know how to work with certificates. And it is for this reason that I decided to write this article. I want it to be a place where one can find basic knowledge about certificates. I don't think that experts can find something interesting here, but I hope that it will be useful for beginners and those who want to refresh their knowledge.

How to use dependency injection in any .NET application

 If you work with ASP.NET applications, you know that it uses dependency injection mechanism. It is very convenient in many cases. But you may want to use the same mechanism in other types of applications: console, desktop, ... Here I'll show you how you can do it.

Thursday, April 15, 2021

Description of the enumeration members in Swashbuckle

Swagger is a great thing! It allows us to easily see the API of our service, generate a client for it in different languages and even work with the service through the UI. In ASP.NET Core we have NuGet package Swashbuckle.AspNetCore for the support of Swagger.

But there is one thing I don't like about this implementation. Swashbuckle can show me descriptions of methods, parameters, and classes based on XML comments in the .NET code. But it does not show the descriptions of the enum members.

Let me show you what I mean.

Wednesday, January 22, 2020

Constant reservation and Git hooks using C#

Let me tell you a story. Once upon a time, there were two developers: Sam and Bob. They worked with a project where a database was. When a developer wanted to make changes to the database structure they had to create a step file stepNNN.sql, where NNN was some number. To avoid collisions of the numbers between different developers they had a simple Web application. Each developer before starting to write an SQL file should go to the application and reserve a new number for their modifications.

That was a time for Sam and Bob to make changes in the database. And Sam obediently went to the Web application and reserved number 333. But Bob forgot to do it. He just used 333 for his new step file. It happened that Bob was the first who committed his changes into the version control system. When Sam was ready to commit it appeared that step333.sql already existed. He contacted Bob, explained to him that step 333 was already reserved and asked Bob to fix the collision. But Bob answered:

- Hey, man. You know, my code is already in the 'master' branch, many developers already took it. And also it is already on production. Could you just fix your code instead?

Have you noticed it? The person who followed all the rules was the one who was punished. Sam had to change his files, modify his local database, etc. Personally, I hate such situations. Let's see how we can avoid it.

Monday, May 6, 2019

NLog: rules and filters

In Confirmit we use NLog library for logging in .NET applications. Although there is a documentation for this library, I found it hard to understand how the loggers work. In this article, I’ll try to explain, how rules and filters are used by NLog. Let’s start.