<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>.NET on Daniel Genezini</title><link>https://genezini.com/categories/dotnet/</link><description>Recent content in .NET on Daniel Genezini</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>2022 Daniel Genezini All rights reserved</copyright><lastBuildDate>Wed, 11 Oct 2023 08:20:00 -0300</lastBuildDate><atom:link href="https://genezini.com/categories/dotnet/index.xml" rel="self" type="application/rss+xml"/><item><title>Server-side rendered SPAs with ASP.NET and no Javascript</title><link>https://genezini.com/blog/p/server-side-rendered-spas-with-asp.net-and-no-javascript/</link><pubDate>Wed, 11 Oct 2023 08:20:00 -0300</pubDate><guid>https://genezini.com/blog/p/server-side-rendered-spas-with-asp.net-and-no-javascript/</guid><description>&lt;img src="https://genezini.com/blog/p/server-side-rendered-spas-with-asp.net-and-no-javascript/cover.jpg" alt="Featured image of post 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 ASP.NET and HTMX to build single-page applications without using JavaScript and SPA frameworks.</description></item><item><title>Integration tests with AWS S3 buckets using Localstack and Testcontainers</title><link>https://genezini.com/blog/p/integration-tests-with-aws-s3-buckets-using-localstack-and-testcontainers/</link><pubDate>Mon, 31 Jul 2023 20:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/integration-tests-with-aws-s3-buckets-using-localstack-and-testcontainers/</guid><description>&lt;img src="https://genezini.com/blog/p/integration-tests-with-aws-s3-buckets-using-localstack-and-testcontainers/cover.jpg" alt="Featured image of post 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 dependencies are a complex part of the system and can break with a package update, a database update or a change in a queue message format.
In this post, I'll show how to use Localstack and Testcontainers to emulate an AWS environment for use in integration tests.</description></item><item><title>Lessons learned from building a static code analyzer for C#</title><link>https://genezini.com/blog/p/lessons-learned-from-building-a-static-code-analyzer-for-csharp/</link><pubDate>Wed, 12 Jul 2023 20:15:00 -0300</pubDate><guid>https://genezini.com/blog/p/lessons-learned-from-building-a-static-code-analyzer-for-csharp/</guid><description>&lt;img src="https://genezini.com/blog/p/lessons-learned-from-building-a-static-code-analyzer-for-csharp/cover.jpg" alt="Featured image of post 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 Analyzers (Static code analyzers for Roslyn), giving access to the syntax and semantic of the code, that can be executed at development and build time, providing feedback in near real-time to the developers.
In this post, I'll show a Roslyn Analyzer I built for using Discriminated Unions in C#, requiring to check the union type before access, and talk about some lessons learned while developing it.</description></item><item><title>Building a Who's that Pokémon game for Android with .NET MAUI and Blazor Hybrid</title><link>https://genezini.com/blog/p/building-a-whos-that-pokemon-game-for-android-with-net-maui-and-blazor-hybrid/</link><pubDate>Wed, 28 Jun 2023 06:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/building-a-whos-that-pokemon-game-for-android-with-net-maui-and-blazor-hybrid/</guid><description>&lt;img src="https://genezini.com/blog/p/building-a-whos-that-pokemon-game-for-android-with-net-maui-and-blazor-hybrid/cover.jpg" alt="Featured image of post 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.</description></item><item><title>Why my WireMock mocks aren't working?</title><link>https://genezini.com/blog/p/why-my-wiremock-mocks-arent-working/</link><pubDate>Tue, 11 Apr 2023 08:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/why-my-wiremock-mocks-arent-working/</guid><description>&lt;img src="https://genezini.com/blog/p/why-my-wiremock-mocks-arent-working/cover.jpg" alt="Featured image of post 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.</description></item><item><title>.NET and AWS S3 with LocalStack: How to develop with local S3 buckets</title><link>https://genezini.com/blog/p/dotnet-and-aws-s3-with-localstack-how-to-develop-with-local-s3-buckets/</link><pubDate>Mon, 13 Feb 2023 07:30:00 -0300</pubDate><guid>https://genezini.com/blog/p/dotnet-and-aws-s3-with-localstack-how-to-develop-with-local-s3-buckets/</guid><description>&lt;img src="https://genezini.com/blog/p/dotnet-and-aws-s3-with-localstack-how-to-develop-with-local-s3-buckets/cover.jpg" alt="Featured image of post .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.</description></item><item><title>How to use C# 11 features in .NET 6 or older versions (even .NET Framework 2.0)</title><link>https://genezini.com/blog/p/how-to-use-c-sharp-11-features-in-dotnet-6-or-older-versions/</link><pubDate>Mon, 06 Feb 2023 07:30:00 -0300</pubDate><guid>https://genezini.com/blog/p/how-to-use-c-sharp-11-features-in-dotnet-6-or-older-versions/</guid><description>&lt;img src="https://genezini.com/blog/p/how-to-use-c-sharp-11-features-in-dotnet-6-or-older-versions/cover.jpg" alt="Featured image of post 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).</description></item><item><title>How to run disposable databases for your tests. Improve your integration tests accuracy with Testcontainers</title><link>https://genezini.com/blog/p/how-to-run-disposable-databases-for-your-tests.-improve-your-integration-tests-accuracy-with-testcontainers/</link><pubDate>Mon, 09 Jan 2023 07:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/how-to-run-disposable-databases-for-your-tests.-improve-your-integration-tests-accuracy-with-testcontainers/</guid><description>&lt;img src="https://genezini.com/blog/p/how-to-run-disposable-databases-for-your-tests.-improve-your-integration-tests-accuracy-with-testcontainers/cover.jpg" alt="Featured image of post 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.</description></item><item><title>Time-out requests in ASP.NET Core with cancellation tokens</title><link>https://genezini.com/blog/p/time-out-requests-in-asp.net-core-with-cancellation-tokens/</link><pubDate>Tue, 20 Dec 2022 06:45:00 -0300</pubDate><guid>https://genezini.com/blog/p/time-out-requests-in-asp.net-core-with-cancellation-tokens/</guid><description>&lt;img src="https://genezini.com/blog/p/time-out-requests-in-asp.net-core-with-cancellation-tokens/cover.jpg" alt="Featured image of post 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 time-outs.</description></item><item><title>Canceling abandoned requests in ASP.NET Core</title><link>https://genezini.com/blog/p/canceling-abandoned-requests-in-asp.net-core/</link><pubDate>Mon, 12 Dec 2022 07:30:00 -0300</pubDate><guid>https://genezini.com/blog/p/canceling-abandoned-requests-in-asp.net-core/</guid><description>&lt;img src="https://genezini.com/blog/p/canceling-abandoned-requests-in-asp.net-core/cover.jpg" alt="Featured image of post 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.</description></item><item><title>Analyzing and enforcing .NET code coverage with coverlet</title><link>https://genezini.com/blog/p/analyzing-and-enforcing-.net-code-coverage-with-coverlet/</link><pubDate>Thu, 03 Nov 2022 08:10:00 -0300</pubDate><guid>https://genezini.com/blog/p/analyzing-and-enforcing-.net-code-coverage-with-coverlet/</guid><description>&lt;img src="https://genezini.com/blog/p/analyzing-and-enforcing-.net-code-coverage-with-coverlet/cover.png" alt="Featured image of post 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 has to be decoupled.
In this last post of this series, I'll show how to analyze and enforce a minimum code coverage in our applications, and how to use integration tests to increase our testing surface.</description></item><item><title>Enforcing .NET code style rules at compile time</title><link>https://genezini.com/blog/p/enforcing-.net-code-style-rules-at-compile-time/</link><pubDate>Tue, 25 Oct 2022 08:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/enforcing-.net-code-style-rules-at-compile-time/</guid><description>&lt;img src="https://genezini.com/blog/p/enforcing-.net-code-style-rules-at-compile-time/cover.png" alt="Featured image of post 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 standards of code quality and code style on your code, throwing errors at compile time if any rules are not being respected and not allowing the code to be pushed to protected branches of the repository.</description></item><item><title>Defining formatting rules in .NET with EditorConfig</title><link>https://genezini.com/blog/p/defining-formatting-rules-in-.net-with-editorconfig/</link><pubDate>Tue, 18 Oct 2022 08:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/defining-formatting-rules-in-.net-with-editorconfig/</guid><description>&lt;img src="https://genezini.com/blog/p/defining-formatting-rules-in-.net-with-editorconfig/cover.png" alt="Featured image of post 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 this post I'll show how to maintain a standard for everyone who works in the code, no matter the editor used, and in a next post I'll show how to enforce these (and other) rules on build and in the continuous integration pipeline.</description></item><item><title>Integration tests without API dependencies with ASP.NET Core and WireMock.Net</title><link>https://genezini.com/blog/p/integration-tests-without-api-dependencies-with-asp.net-core-and-wiremock.net/</link><pubDate>Sun, 25 Sep 2022 08:00:00 -0300</pubDate><guid>https://genezini.com/blog/p/integration-tests-without-api-dependencies-with-asp.net-core-and-wiremock.net/</guid><description>&lt;img src="https://genezini.com/blog/p/integration-tests-without-api-dependencies-with-asp.net-core-and-wiremock.net/cover.jpg" alt="Featured image of post 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.</description></item></channel></rss>