Using the Unicode Fraction Slash instead of HTML sub/sup tags

 
 
  • Gérald Barré
When you need to display fractions in HTML, you might reach for the <sub> and <sup> tags. However, there's a simpler Unicode-based alternative: the fraction slash character (U+2044). What is the Fraction Slash? The fraction slash (⁄) is a Unicode character that automatically formats surrounding digits as a fraction. When placed between two digits, most modern browsers and fonts render it as a proper… [read more]

Blazor - How to set a base component for all Razor components

 
 
  • Gérald Barré
When building a Blazor application, you may want a custom base component for all your Razor components. This is useful for sharing common functionality like cancellation tokens, logging, or state management across all components. Instead of adding @inherits YourBaseComponent to every Razor file, you can use the _Imports.razor file to set it globally. Using _Imports.razor to set a default base component… [read more]

Disable HTTP caching by default in ASP.NET Core APIs

 
 
  • Gérald Barré
When building APIs with ASP.NET Core, it's crucial to explicitly control caching behavior. Unlike web pages where caching often improves user experience, API responses should not be cached by default unless you intentionally design them to be cacheable. Unintended caching can lead to serious issues, including stale data, security vulnerabilities, and hard-to-reproduce bugs. Understanding HTTP caching… [read more]

Suppressing Roslyn Analyzer Warnings Programmatically using DiagnosticSuppressor

 
 
  • Gérald Barré
Roslyn analyzers are great for enforcing coding standards and finding bugs. However, they can sometimes report false positives or warnings you want to ignore in specific contexts. You can suppress these warnings using #pragma directives or [SuppressMessage] attributes, but both approaches require modifying the source code. A DiagnosticSuppressor is a Roslyn component that suppresses diagnostics reported… [read more]

Accessing files from the action repository in a GitHub Composite Action

 
 
  • Gérald Barré
GitHub Actions allows you to create reusable actions. One of the easiest ways to do this is to use Composite Actions, which let you combine multiple steps into a single action. This reduces code duplication across your workflows. When creating a composite action, you may need to reference files stored in the action repository, such as a PowerShell or Bash script. By default, when an action runs, the… [read more]