JetBrains Rider 2025.3 Help

Code inspection: Convert extension methods to extension block

C# 14 introduces extension blocks as a new way to declare extension methods, which is an elegant way to declare several methods for the same extended type. Therefore, JetBrains Rider suggests converting several existing extension methods that target the same extended type into a single extension block.

public static class StringExtensions { public static bool IsNullOrEmpty(this string str) { return string.IsNullOrEmpty(str); } public static bool IsNullOrWhiteSpace(this string str) { return string.IsNullOrWhiteSpace(str); } public static string TrimStart(this string str, string prefix) { if (str.StartsWith(prefix)) return str.Substring(prefix.Length); return str; } }
public static class StringExtensions { extension(string str) { public bool IsNullOrEmpty() { return string.IsNullOrEmpty(str); } public bool IsNullOrWhiteSpace() { return string.IsNullOrWhiteSpace(str); } public string TrimStart(string prefix) { if (str.StartsWith(prefix)) return str.Substring(prefix.Length); return str; } } }
12 November 2025