Intro This post will be simple and try to act as a discussion starter on unit testing static methods. I’m not the greatest fan of making static stuff, mainly because I’ve been burned by it in the past (the fact is that static was being used badly in those cases, but even so, if I can, I’ll avoid it) but I understand it’s the best way to do things sometimes.

Categories: dotnet testing
Just think how many times you had to write some code to handle errors, and that handling required more than just logging and proceed with life as if nothing happened. If retries are required, or a cool down time, that’s a good amount of logic to roll for those situations. Well, there’s a NuGet for that (I guess that’s our version of there’s an app for that). Polly is a “library that allows developers to express transient exception and fault handling policies such as Retry, Retry Forever, Wait and Retry, or Circuit Breaker in a fluent manner.

Categories: dotnet libraries
Castle Core is a library that provides some utilities but I’ll just talk about using one of them, the DynamicProxy. If the post on BenchmarkDotNet was in the race for golden shovel award, a post on Castle DynamicProxy is a sure winner, but I feel like it :) Castle DynamicProxy is a a “lightweight runtime proxy generator”, that enables you to do a kind of aspect oriented programming, allowing for some code to be executed before or after a method is invoked on a proxied interface.

Categories: dotnet libraries
(The redirect tag in the title means this post is just a share of another post) So, how do you use the HttpClient (.NET)? Like this? 1 2 3 4 5 using (var client = new HttpClient()) { var result = await client.GetAsync("http://xpto.com/api/stuff"); //... } Well, so do I. And it’s wrong. Check out this article that tells you all about why. tl;dr Use a singleton instance. Oh, and after that one, this is also a good (important) related read.

Categories: dotnet redirect
This will probably earn me what some friends of mine call a golden shovel (an award for finding out something everyone already knows) but since I just recently found out about it, I’ll write about it anyway. Several times I felt the need to benchmark some portions of code so I could see if a way of doing something could be a slow down cause for an application (many of those times were when I wanted to use some reflection to simplify the code and some colleagues were afraid reflection was going to have a negative impact on performance).

Categories: dotnet libraries
To finish up this series of posts I’ll just go by a couple of extra things I needed to do to get the, mostly functional by now, site to work better. The main points are: Getting some certificates to get the site working on https. Using a mail server to overcome an issue with WordPress running on Docker. Get the site on HTTPS Everybody likes (or should) when you go to a web site and it uses HTTPS, even more so when there are private stuff going down the wire (like user credentials).

Categories: infrastructure