.NET / C#

.NET / C#

I love programming in .NET / C#. Have been doing it since 2004 now. Much has changed since: the .Net framework is got more libraries, NuGet was a game-changer and even C# itself is evolving with lambda and dynamic.

And now .Net has evolved to Standard and Core with support for other platforms like Linux / Docker. Things are getting easier and faster.

There are 43 articles tagged with .NET / C#.

Data Annotation validation with dependency injection in a business service

What I love a about data annotations and validation attributes, is that the validation rules are defined very close to the class: when you open it up, you can view all the rules. The ApiController will even automatically do model validation. This is great, but I like some defense it depth; I want to be able to use those validations in my business service as well. I should not have to trust input. Let’s explore how we can make that happen.

Read the article Data Annotation validation with dependency injection in a business service

Kiota Client Unit Testing: mocking data

After implementing Kiota clients with resilience, I felt the need to spend some time on unit testing them. The Kiota docs on unit testing uses NSubstitute to override the response of the adapter. After some testing (pun intended), I did not feel satisfied with the results; we should be able to use the “normal” way of testing an HttpClient, right? In this blog, I’ll show how to use the RichardSzalay.MockHttp package together with Kiota.

Read the article Kiota Client Unit Testing: mocking data

.NET Console Application with injectable commands

Console applications are alive and kicking. Setting them up might be a bit hard. In this article I’ll explore how to create a .NET console application that provides commands using the new System.CommandLine package. This will provide arguments to command mapping out of the box. I’ll be showing how to combine it with dependency injection for even more power ⚡.

Read the article .NET Console Application with injectable commands
expand_less brightness_auto