Distributing applications that depend on Microsoft.Playwright

  • Gérald Barré
To use Playwright, you need to install the NuGet package and the browsers. The documentation tells us to use the following command to install the browsers: # Create project dotnet new console -n PlaywrightDemo cd PlaywrightDemo # Install dependencies, build project and download necessary browsers. dotnet add package Microsoft.Playwright dotnet build dotnet tool install --global Microsoft.Playwright.CLI… [read more]

Updating your project to use File Scoped Namespaces

  • Gérald Barré
File Scoped Namespace is a new feature of C# 10. The idea is to remove one level of indentation from source files when they contain only one namespace in it. The goal is to reduce horizontal and vertical scrolling and make the code more readable. namespace MyProject { class Demo { } } // File Scoped Namespace namespace MyProject; class Demo { } Most of the files have only one namespace, so File Scoped… [read more]

Monitoring a .NET application using OpenTelemetry

  • Gérald Barré
note: The samples in this post instrument an ASP.NET Core application, but you can instrument any kind of application using OpenTelemetry What is OpenTelemetry? OpenTelemetry is a set of APIs, SDKs, tooling and integrations that are designed for the creation and management of telemetry data such as traces, metrics, and logs. The project provides a vendor-agnostic implementation that can be configured to… [read more]

File upload with progress bar in Blazor

  • Gérald Barré
Uploading files may take times. The users want to have visibility on what's happening, so it is good to show them about the progress. The simplest way to do it is to show a progress bar. In this post, we'll use the InputFile component to upload files and some custom code to show the progress bar. The result looks like this: Blazor comes with the InputFile component. This component allows you to upload… [read more]

Visual Studio Tips and tricks: Subword navigation

  • Gérald Barré
Starting with Visual Studio 2022, you can navigate between subwords using the Subword Navigation feature. This is very convenient when you want to move the caret to a part of an identifier, for example. So PascalCaseIdentifier has 3 sub-words, Pascal, Case, and Identifier. Using subword navigation, you can move the caret to the next or previous subword. Note that it also works with other separators, such… [read more]

Creating a search engine for websites using Elasticsearch and Playwright

  • Gérald Barré
Searching for information on internal website is often not an easy task. Indeed, you can't use your favorite search engine to find information. So, you need to provide your own solution. Of course, you can't rebuild Google or Bing 😦 But, you can still provide a sufficient search engine. In this serie, I'll show how to quickly create a search engine for your internal websites using Playwright and… [read more]

Generate PDF files using an html template and Playwright

  • Gérald Barré
There are many ways to generate PDF files. You can use a PDF library, but generating a PDF manually is not trivial. You can use a report library, but they are often paid solution and not trivial to use for simple needs. In this post, we'll use an html template and Playwright to generate a PDF file. Using a browser to convert an html file to a PDF file is very convenient as it allows to use all html/CSS… [read more]