JetBrains Rider 2025.3 Help

Code inspection: Move 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 moving extension methods that target a specific extended type into the extension block that match that extended type. For example:

public static class StringExtensions { extension(string str) { public bool IsNullOrEmpty() { return string.IsNullOrEmpty(str); } public bool IsNullOrWhiteSpace() { 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