Add null checks when writing summary text

This commit is contained in:
Ronald Barendse
2021-09-15 11:03:28 +02:00
parent af0f263e3c
commit c2a184482c

View File

@@ -39,8 +39,8 @@ namespace Umbraco.Cms.Core.Packaging
void WriteConflicts<T>(IEnumerable<T> source, Func<T, string> selector, string message, bool appendLine = true)
{
var result = source.Select(selector).ToList();
if (result.Count > 0)
var result = source?.Select(selector).ToList();
if (result?.Count > 0)
{
sb.Append(message);
sb.Append(string.Join(", ", result));
@@ -55,7 +55,7 @@ namespace Umbraco.Cms.Core.Packaging
void WriteCount<T>(string message, IEnumerable<T> source, bool appendLine = true)
{
sb.Append(message);
sb.Append(source.Count());
sb.Append(source?.Count() ?? 0);
if (appendLine)
{
@@ -63,9 +63,9 @@ namespace Umbraco.Cms.Core.Packaging
}
}
WriteConflicts(Warnings.ConflictingMacros, x => x.Alias, "Conflicting macros found, they will be overwritten: ");
WriteConflicts(Warnings.ConflictingTemplates, x => x.Alias, "Conflicting templates found, they will be overwritten: ");
WriteConflicts(Warnings.ConflictingStylesheets, x => x.Alias, "Conflicting stylesheets found, they will be overwritten: ");
WriteConflicts(Warnings?.ConflictingMacros, x => x.Alias, "Conflicting macros found, they will be overwritten: ");
WriteConflicts(Warnings?.ConflictingTemplates, x => x.Alias, "Conflicting templates found, they will be overwritten: ");
WriteConflicts(Warnings?.ConflictingStylesheets, x => x.Alias, "Conflicting stylesheets found, they will be overwritten: ");
WriteCount("Data types installed: ", DataTypesInstalled);
WriteCount("Languages installed: ", LanguagesInstalled);
WriteCount("Dictionary items installed: ", DictionaryItemsInstalled);