Using the binary log to find the source of a .NET dependency

 
 
  • Gérald Barré
Understanding where a dependency comes from can be tedious. This is especially true when you have a large project with many dependencies. Recently, .NET brings a new tool dotnet nuget why to help you understand why a package is installed in your project. However, there is a better way to do it, and it doesn't requires a recent SDK. dotnet nuget why can explain why a package is included in your project:… [read more]

NuGet Packages: security risks and best practices

 
 
  • Gérald Barré
NuGet packages offer a convenient way to share code, but many developers download them without reviewing the contents or verifying updates when new versions are released. When you install a NuGet package, you are: Downloading code from unknown authors that has likely not been thoroughly reviewed by others Running it with full permissions on your local machine, potentially exposing your personal data… [read more]

Embedded Languages Supported by Roslyn

 
 
  • Gérald Barré
In a recent post, I shared how to highlight C# code in string values. Roslyn provides more built-in highlighters / code-completions in string values. Most of the supported languages are available as constants of the StringSyntaxAttribute class. To indicate the language, you can use the lang or language comment or the [StringSyntax] attribute. The languages mentioned in this post are handled by Roslyn (VS,… [read more]

Listing all cloud folders in Windows using .NET

 
 
  • Gérald Barré
Windows allows to list the OneDrive folders or folders from other cloud providers. This is done by using the StorageProviderSyncRootManager class. The StorageProviderSyncRootManager class provides a static method called GetCurrentSyncRoots that returns a list of StorageProviderSyncRoot objects, which correspond to the registered cloud folders. Before using the Windows SDK, you need to update the Target… [read more]

How to remove diacritics from a string in .NET

 
 
  • Gérald Barré
Diacritics are a way to add additional information to a character. They are used in many languages, such as French, Spanish, and German. A common usage of diacritics is to add an accent to a letter (e.g. é). In this post, I describe how to remove diacritics from a string in .NET. In the post , I already wrote about diacritics. But let give a quick reminder. A diacritic is a glyph added to a letter. For… [read more]

Understanding OverloadResolutionPriority attribute in C# 13

 
 
  • Gérald Barré
C# 13 adds support for a new attribute: [OverloadResolutionPriority]. This attribute is niche, so most of you won't use it. However, it's a nice addition to the language, and it's worth knowing about it if you are writing libraries. Let's consider this simple example: Sample.Test(); // Print: Test 1 static class Sample { public static void Test() => Console.WriteLine("Test 1"); } Now, you want to update… [read more]