From 86ae730b1e642e64be64720200c49bb383387c34 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 24 Mar 2022 12:59:40 +0100 Subject: [PATCH] fix string.Empty back to null --- .../Packaging/PackageDataInstallation.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs index 5bc0fe211a..1a72fa19b5 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs @@ -218,7 +218,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging IDictionary importedContentTypes, IContentTypeBaseService typeService, IContentServiceBase service) - where TContentBase : class?, IContentBase + where TContentBase : class, IContentBase where TContentTypeComposition : IContentTypeComposition { var contents = new List(); @@ -378,7 +378,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging ? contentType.CompositionPropertyTypes.ToDictionary(x => x.Alias, x => x) : contentType.PropertyTypes.ToDictionary(x => x.Alias, x => x); - var foundLanguages = new HashSet(); + var foundLanguages = new HashSet(); foreach (var property in properties) { string propertyTypeAlias = property.Name.LocalName; @@ -387,14 +387,14 @@ namespace Umbraco.Cms.Infrastructure.Packaging var propertyValue = property.Value; // Handle properties language attributes - var propertyLang = property.Attribute(XName.Get("lang"))?.Value ?? string.Empty; + var propertyLang = property.Attribute(XName.Get("lang"))?.Value ?? null; foundLanguages.Add(propertyLang); if (propTypes.TryGetValue(propertyTypeAlias, out var propertyType)) { // set property value // Skip unsupported language variation, otherwise we'll get a "not supported error" // We allow null, because that's invariant - if (installedLanguages.InvariantContains(propertyLang) || propertyLang is null) + if ( propertyLang is null || installedLanguages.InvariantContains(propertyLang)) { content.SetValue(propertyTypeAlias, propertyValue, propertyLang); } @@ -404,7 +404,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging foreach (var propertyLang in foundLanguages) { - if (string.IsNullOrEmpty(content.GetCultureName(propertyLang)) && + if (string.IsNullOrEmpty(content.GetCultureName(propertyLang)) && propertyLang is not null && installedLanguages.InvariantContains(propertyLang)) { content.SetCultureName(nodeName, propertyLang);