Understanding the impact of Roslyn Analyzers on the build time

  • Gérald Barré
Roslyn analyzers analyze your code for style, quality and maintainability, design and other issues. .NET includes built-ins analyzers (Microsoft.CodeAnalysis.NetAnalyzers), and it's very common to include a few other analyzers such as Microsoft.VisualStudio.Threading.Analyzers, Meziantou.Analyzer, or StyleCop.Analyzers. Roslyn analyzers runs while building the projects. If you enable lots of rules, it… [read more]

Debouncing / Throttling JavaScript events in a Blazor application

  • Gérald Barré
Debouncing and throttling are used to prevent too many events from being processing. For instance, when a user types text in a search bar, you may want to wait until they stop writing for a few milliseconds before executing the search request. This is what debouncing is made for. When using debounce, you will wait for a certain inactivity time before processing an event. In Blazor, there are 2 ways to use… [read more]

Building .NET projects using the Microsoft.Build.Traversal SDK

  • Gérald Barré
Your continuous integration script often looks like dotnet build mysolution.sln and dotnet test mysolution.sln. In my case, I have a solution that contains multiple class libraries and a few WPF projects. I want to create NuGet packages and also test projects on Windows, Linux, and Mac. However, you cannot build WPF projects on Linux or Mac. This means dotnet build fail on these platforms. One way to deal… [read more]

Tracking Cloudflare Worker requests using Application Insights

  • Gérald Barré
This website is hosted on a static website hosting provider and I use Cloudflare CDN to improve the performance. These 2 services allow me to host this website for free even if I got more and more visitors. However, I do not have lots of analytics. For instance, I want to know where the user comes from using the HTTP referer header or if they got a 404. Google Analytics is useful but most users use an… [read more]

Using raw html with isolated CSS in Blazor

  • Gérald Barré
In a project I had to create something similar to a syntax highlighter for a Blazor application. The code takes a string and highlights some parts of it. So, the idea is to create a component which outputs a raw html fragment that uses <span class="style-1">text</span> to colorize some parts of the string. Also, it should use CSS isolation as the style is specific to the component. I've already written… [read more]

Binding decimal numbers using the oninput event in Blazor

  • Gérald Barré
I needed to bind an <input type=number> in a Blazor application. I want to get the value as soon as the user changes the value. There is no problem for integer values. However, this is not as simple for decimal values. First attempt: <input type=number> First, I started with a basic solution. I use an input element and set the oninput event to bind the value as soon as the user change the value. <input… [read more]