Visualizing the code coverage results from Azure Pipelines in Visual Studio

  • Gérald Barré
In a previous posts, I explained how to computing code coverage for a .NET Core project with Azure DevOps and Coverlet. In this post, the code coverage visualization could be done directly in Azure DevOps. As a developer, you want to see these results directly into the IDE. Download the code coverage file from the build artifacts Open the file in Visual Studio In the "Code Coverage Results" tool window,… [read more]

Packaging a Roslyn Analyzer with NuGet package references

  • Gérald Barré
Roslyn Analyzers are packaged as NuGet packages. If you are new to Roslyn Analyzers, you can check previous posts of the series. If your Roslyn analyzer has a dependency on another NuGet package, you need to customize the way your analyzer is packaged. Indeed, if you add a <PackageReference> to your project, Roslyn won't be able to resolve the referenced package at runtime. In this case, you'll get the… [read more]

Automatically generate a form from an object in Blazor

  • Gérald Barré
Blazor provides building blocks for creating forms. It includes editor components, model validation, and model binding. When you want to create a form, you need to create an object to store the form data and create the razor component with labels and editors for each property. This is tedious when you want to quickly create a basic form. To speed up this process, I've created a generic form component.… [read more]

Simplifying paths handling in .NET code with the FullPath type

  • Gérald Barré
In my projects, I often deal with paths. However, there are many traps when working with path: A path can be absolute or relative (c:\a\b, .\a\b) A path can contain navigation segments (., ..) A path can end with a directory separator or not (c:\a or c:\a\) A path can contain empty segments (c:\a\\b) A path can alternate between multiple directory separators on Windows (c:\a/b\c) A path can be… [read more]

Canceling background tasks when a user navigates away from a Blazor component

  • Gérald Barré
In an application, you don't want to waste resources. When an ongoing operation is not needed anymore, you should cancel it. For instance, if your application downloads data to show them in a view, and the user navigates away from this view, you should cancel the download. In a .NET application, the way to cancel operation is to use a CancellationToken. You can create a CancellationToken using the… [read more]

Running GitHub Super-Linter in Azure Pipelines

  • Gérald Barré
GitHub Super-Linter is a simple combination of various linters to help validate your source code. The end goal of this tool: Prevent broken code from being uploaded to your repository Help establish coding best practices across multiple languages Build guidelines for code layout and format Automate the process to help streamline code reviews Instead of using many linters individually in your CI, you can… [read more]