* Fix #12454 by having Coalesce handle null values * Allow null values in Html.Coalesce #12454
This commit is contained in:
committed by
Bjarke Berg
parent
963d4c5051
commit
d810d66e9a
@@ -89,10 +89,10 @@ public sealed class HtmlStringUtilities
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string Coalesce(params object[] args)
|
||||
public string Coalesce(params object?[] args)
|
||||
{
|
||||
var arg = args
|
||||
.Select(x => x.ToString())
|
||||
.Select(x => x?.ToString())
|
||||
.FirstOrDefault(x => string.IsNullOrWhiteSpace(x) == false);
|
||||
|
||||
return arg ?? string.Empty;
|
||||
|
||||
@@ -910,7 +910,7 @@ public static class HtmlHelperRenderExtensions
|
||||
/// <summary>
|
||||
/// Will take the first non-null value in the collection and return the value of it.
|
||||
/// </summary>
|
||||
public static string Coalesce(this IHtmlHelper helper, params object[] args)
|
||||
public static string Coalesce(this IHtmlHelper helper, params object?[] args)
|
||||
=> s_stringUtilities.Coalesce(args);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user