diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/Assumed.cs b/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/Assumed.cs
index 8493bbb7686..5b32f5523e9 100644
--- a/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/Assumed.cs
+++ b/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/Assumed.cs
@@ -40,22 +40,37 @@ public static void True(
public static void Unreachable([CallerFilePath] string? path = null, [CallerLineNumber] int line = 0)
=> ThrowInvalidOperation(SR.This_program_location_is_thought_to_be_unreachable, path, line);
+ ///
+ /// Can be called at points that are assumed to be unreachable at runtime.
+ ///
+ ///
+ [DoesNotReturn]
+ public static void Unreachable(string message, [CallerFilePath] string? path = null, [CallerLineNumber] int line = 0)
+ => ThrowInvalidOperation(message, path, line);
+
///
/// Can be called at points that are assumed to be unreachable at runtime.
///
///
[DoesNotReturn]
public static T Unreachable([CallerFilePath] string? path = null, [CallerLineNumber] int line = 0)
- {
- ThrowInvalidOperation(SR.This_program_location_is_thought_to_be_unreachable, path, line);
- return default;
- }
+ => ThrowInvalidOperation(SR.This_program_location_is_thought_to_be_unreachable, path, line);
+
+ ///
+ /// Can be called at points that are assumed to be unreachable at runtime.
+ ///
+ ///
+ [DoesNotReturn]
+ public static T Unreachable(string message, [CallerFilePath] string? path = null, [CallerLineNumber] int line = 0)
+ => ThrowInvalidOperation(message, path, line);
[DebuggerHidden]
[DoesNotReturn]
- [MethodImpl(MethodImplOptions.NoInlining)]
private static void ThrowInvalidOperation(string message, string? path, int line)
- {
- throw new InvalidOperationException(message);
- }
+ => ThrowHelper.ThrowInvalidOperationException(message + Environment.NewLine + SR.FormatFile_0_Line_1(path, line));
+
+ [DebuggerHidden]
+ [DoesNotReturn]
+ private static T ThrowInvalidOperation(string message, string? path, int line)
+ => ThrowHelper.ThrowInvalidOperationException(message + Environment.NewLine + SR.FormatFile_0_Line_1(path, line));
}