RSSAmplifier

Blog

Daniel Genezini | It works on my machine

Recent content on Daniel Genezini | It works on my machine

blog.genezini.comRSS feed ↗36 posts

Latest posts

Recovering Lost Changes with JetBrains Rider Local History

Local History is one of those IDE features you don't think about until you desperately need it. This post covers what it is, how it works, and the scenarios where it saves you: accidental rollbacks, lost uncommitted changes and rebase mistakes.

Git Revert Multiple Commits of Protected Branches with Git Restore

Protected branches, such as develop and main, are critical for maintaining the integrity of your repository. These branches cannot be reset or force-pushed due to restrictions, making it essential to create new commits to undo changes. This post explores a simple method to revert changes, using the git restore command, especially when dealing with large or complex modifications.

Creating a Maintainable Resume with Markdown and Pandoc

Keeping a professional resume updated and adaptable for various applications can be a challenging. This post demonstrates how leveraging Markdown for content and Pandoc for conversion simplifies the process, enabling you to maintain a single, clean source file that effortlessly transforms into polished PDF, DOCX, or HTML outputs.

Down the Rabbit Hole of creating a Home Lab

Setting up a home lab is an incredible journey that opens up countless learning opportunities in system administration, networking, security, and modern deployment practices. While it might seem daunting at first, the knowledge gained is invaluable for any tech enthusiast or IT professional. In this post, I'll share a practical overview of how I use my home lab, highlighting the real-world…

Lightweight Docker in WSL without Docker Desktop

Docker Desktop provides many features, but it is also heavy and slow to start. This made me remove it and install only Docker Engine directly in WSL, reducing startup time from minutes to seconds. In this post I'll show how to do it, some configuration tips, how to share the Docker socket across WSL distros (like Rancher Desktop and Podman Desktop do automatically), and a comparison with those…

Colorful terminals with Oh My Posh and Windows Terminal

Oh My Posh is a tool that not only enhance the appearance of your shell, but also offers useful integrations that makes the use more intuitive and helps us be more productive. I use it in WSL and in my home server and customized it to easily identify what shell I'm in:

Server-side rendered SPAs with ASP.NET and no Javascript

Single-page applications (SPA) provide better user experience by removing full-page loads, giving smooth transitions between pages and performance improvements depending on the scale of the application, but they come at some costs which may not be worth for some application types. The main cost is the added complexity of a SPA framework like Angular or Vue. In this post, I'll show how to use…

Integration tests with AWS S3 buckets using Localstack and Testcontainers

As I explained previously in this article, in integration tests, we should mock unmanaged dependencies (dependencies that are external to our system and not controlled by us, like APIs) but test against real managed dependencies (dependencies that are controlled by our system, like databases, queues, etc). This improves the reliability of the integration tests because the communication with these…

Lessons learned from building a static code analyzer for C#

Static code analyzers are tools used to analyze software code without executing it. They can examine the code to find code smells, vulnerabilities, potential errors, and code out of a defined standard, for example. They work by parsing the source code and evaluating its syntax (structure of the code) and semantic (meaning of the code). Roslyn, the C# compiler, provides tools for developing Roslyn…

Building a Who's that Pokémon game for Android with .NET MAUI and Blazor Hybrid

Blazor was initially developed to build interactive web applications using C#, but can now be used in many platforms when used together with .NET MAUI. In this post, I'll show how to use Blazor Hybrid to develop a Who's that Pokémon game for Android.

How to run scripts on SQL Server container startup

Unlike MySQL and PostgreSQL, which execute scripts in the /docker-entrypoint-initdb.d/ directory after initialization, the SQL Server container image doesn't provide a built-in mechanism for running scripts at startup. In this post, I'll show how to create a custom container image that waits for SQL Server startup and runs a pre-configured script. In addition, I'll show how to use this custom…

Real-time charts with Blazor, SignalR and ApexCharts

SignalR is a free open-source library for ASP.NET Core that allows the server to push real-time asynchronous messages to connected clients. It is an abstraction layer on top of WebSockets, making it easier to use and providing fallback to other forms of communication when necessary (server-sent events and long polling). In this post, I'll show how to build a Blazor WebAssembly app that displays…

Easier Git rebase of messy branches

Even when working with short lived branches, repositories with constant changes can cause lots of conflicts and result in outdated branches hard to rebase. In this post, I'll show a way to rebase those branches with much less effort.

Why my WireMock mocks aren't working?

WireMock.Net is a great tool to remove external dependencies when writing integration tests, but because it is highly configurable, it can be hard to find why its mocks aren't working. In this post, I'll explain how to troubleshoot problems in its configuration and show some common problems that happen in my day-to-day work.

.NET and AWS S3 with LocalStack: How to develop with local S3 buckets

LocalStack is an open-source framework that allows us to emulate the major AWS services locally, making it easier to develop and test cloud applications without incurring the cost and complexity of deploying to a real cloud environment. In this post, I'll show how to configure it to emulate S3 buckets and how to interact with those buckets from a C# application.

How to use C# 11 features in .NET 6 or older versions (even .NET Framework 2.0)

At each release, C# adds features that help us make our codes cleaner, more readable and more maintainable. The problem is that, because some features are dependent of runtime implementations, C# versions are generally tied to .NET runtime versions. For example, C# 11 is enabled only in .NET 7 and above. In this post, I'll show how to use C# 11 in older runtime version (even .NET Framework 2.0).

Compile-time null safety: How to avoid NullReferenceException in C#

Softwares can fail at two different moments: compile time and runtime. In the context of errors, null is a problem because the effects of not handling them right are perceived only at runtime. In this post, I'll show how to use a C# language feature to move the null errors to compile time and help us avoid them at runtime.

Improve your coding experience: More 10 VS Code extensions to try

One of the reasons VS Code is so popular is because of its extensibility. It allows us to install extentions that can do basicaly anything and improve our productivity and workflow. In this post, I'll increase the list of extensions from my previous post and show more 10 extensions that are worth trying.

How to run disposable databases for your tests. Improve your integration tests accuracy with Testcontainers

Integration tests are essential to ensure that the different components of our system work together as expected and continue to work after changes. In this post, I'll explain how to spin up disposable database containers to use in integration tests.

Git Aliases: a time-saving secret weapon for improved workflow and productivity

Git is a powerful tool with lots of commands and customizable options. Fortunately, to make our lives easier, we can create aliases to simplify these commands. In this post I'll explain how Git aliases work and show the aliases I currently use.

Don't box your logs

.NET's default interface for logging (ILogger) can log any number and type of parameters in the log messages. Because of this, the parameters are passed as object to the log implementation, causing the boxing of value types. In this post, I'll show how .NET Core removed the need for boxing when logging, focusing on the .NET 6 source generators.

7 tips for improving your productivity with Git

Git is the most popular source control system with an incredible 93.87% of adoption by developers (according to StackOverflow's 2022 Survey). It's a really powerful system with lots of hidden features not known by most of us developers. In this post, I'll show some of these features that will make your work easier when using Git.

Time-out requests in ASP.NET Core with cancellation tokens

When ASP.NET Core is running in an AWS Lambda and receiving requests through an AWS API Gateway, the application is not notified of an API Gateway time-out and keeps processing the request, completing it eventually. This will leave metrics and logs of a successful request when the client received a time-out error. In this post, I'll show how to solve this problem with cancellation tokens and…

Interesting Links - 03 (16-Dec-2022)

Interesting links of the week of 16-Dec-2022

Canceling abandoned requests in ASP.NET Core

When a client makes an HTTP request, the client can abort the request, leaving the server processing if it's not prepared to handle this scenario; wasting its resources that could be used to process other jobs. In this post, I'll show how to use Cancellation Tokens to cancel running requests that were aborted by clients.

Interesting Links - 02 (09-Dec-2022)

Interesting links of the week of 09-Dec-2022

Interesting Links - 01 (02-Dec-2022)

Interesting links of the week of 02-Dec-2022

Keep your diagrams updated with continuous delivery

Changing software diagrams is hard. The simple act of adding a new box may require us to drag all the existing boxes and reorganize the diagram. This is one of the main reasons to why software diagrams are constantly left deprecated after the first stages of the development process. In this post I'll show how defining diagrams as code can help in designing and updating software diagrams, and how…

Cleaner representation of software architectures with the C4 Model

Diagrams are a great way to visually communicate something. However, the majority of software architecture diagrams don't really express what they intend to, lacking description of its elements and with lots of implicit notations only understood by who drew the diagram. Also, they try to express more than one vision (high level, infrastructure, flow order, etc) in only one diagram, making it even…

Playing with module federation and Blazor components

With the release of .NET 7, Microsoft included a feature to render Blazor components in JavaScript applications (RegisterCustomElement<T>). This helps those who want to slowly migrate JavaScript applications to Blazor, but unfortunately, won't work for exposing Blazor components as microfrontends, as it works only for JavaScript applications deployed together with the Blazor application. In this…

Analyzing and enforcing .NET code coverage with coverlet

Automated software tests are a requirement for ensuring we are delivering a product with quality to our users. It helps in finding bugs and requirements not fulfilled at development time, but also decreases the cost of maintenance by making the future changes to our code safer. Besides, the act of writing testable code alone increases the quality of the code we are writing because testable code…

Enforcing .NET code style rules at compile time

Static code analysis is a great tool for spotting some kinds of error in your code, for example, not disposing of objects that implement IDisposable. Also, it helps to enforce and validate if the code written is following a defined standard, for example, using PascalCase for class names and camelCase for parameter names. In this post I'll show how to use Roslyn Analyzers with C# to enforce some…

Defining formatting rules in .NET with EditorConfig

When working with other people and multiple editors/IDEs, it is common to have different editor settings, losing consistency in formatting styles of the code. For example: Using tabs/spaces and different sizes of indentation, making your code harder to read; Using different encoding between files, causing hard to find bugs at runtime (showing invalid characters) and breaking automated tests. In…

VS Code extensions worth trying out

Visual Studio Code is the most used IDE according to the Stack Overflow 2022's Developer Survey and it has lots of extensions to help us be more productive. Even developers who use another main IDE probably use VS Code for some part of their jobs. In this post I'll show some of the extensions that I use to work, study and write this blog.

Working on multiple Git branches in parallel

When working on a project, many times we have to switch to a different branch to help a colleague, fix a bug, or to work on another feature (because of a change in priorities or blocks). In these situations, we have some options: Clone again to another folder: This was the option that I used up until some time ago, but if you are working on a big code base, it may take some time to download the…

Integration tests without API dependencies with ASP.NET Core and WireMock.Net

Although there are many definitions about the scope of an integration test, Martin Fowler defines Narrow integration tests, where the integration with other systems are tested using mocks, and Broad integration tests, where they communicate using real APIs. In this post, I'll explain how to create mocks for HTTP APIs in narrow integration tests using the WireMock.Net library.