From c6e7e139e9e223dc15bf9f2b30e376188f850c8b Mon Sep 17 00:00:00 2001
From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Date: Fri, 1 Apr 2022 14:49:39 +0200
Subject: [PATCH] Fix up build errors
---
src/Umbraco.Core/GuidUtils.cs | 6 +++---
src/Umbraco.Core/IO/IMediaPathScheme.cs | 2 +-
src/Umbraco.Core/IO/MediaFileManager.cs | 2 +-
.../MediaPathSchemes/CombinedGuidsMediaPathScheme.cs | 2 +-
.../IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs | 4 ++--
.../IO/MediaPathSchemes/UniqueMediaPathScheme.cs | 2 +-
src/Umbraco.Core/Models/Editors/ContentPropertyData.cs | 4 ++--
.../PropertyEditors/FileUploadPropertyValueEditor.cs | 2 +-
.../PropertyEditors/ImageCropperPropertyValueEditor.cs | 2 +-
.../Controllers/BackOfficeServerVariables.cs | 10 +++++-----
.../Controllers/ContentControllerBase.cs | 7 ++++---
11 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/Umbraco.Core/GuidUtils.cs b/src/Umbraco.Core/GuidUtils.cs
index 347ddd573e..31e168966b 100644
--- a/src/Umbraco.Core/GuidUtils.cs
+++ b/src/Umbraco.Core/GuidUtils.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Core
/// The seconds guid.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Guid? Combine(Guid? a, Guid? b)
+ public static Guid? Combine(Guid a, Guid b)
{
var ad = new DecomposedGuid(a);
var bd = new DecomposedGuid(b);
@@ -34,11 +34,11 @@ namespace Umbraco.Cms.Core
[StructLayout(LayoutKind.Explicit)]
private struct DecomposedGuid
{
- [FieldOffset(00)] public Guid? Value;
+ [FieldOffset(00)] public Guid Value;
[FieldOffset(00)] public long Hi;
[FieldOffset(08)] public long Lo;
- public DecomposedGuid(Guid? value) : this() => this.Value = value;
+ public DecomposedGuid(Guid value) : this() => this.Value = value;
}
private static readonly char[] Base32Table =
diff --git a/src/Umbraco.Core/IO/IMediaPathScheme.cs b/src/Umbraco.Core/IO/IMediaPathScheme.cs
index 61ab191d77..da9a06d1b1 100644
--- a/src/Umbraco.Core/IO/IMediaPathScheme.cs
+++ b/src/Umbraco.Core/IO/IMediaPathScheme.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Cms.Core.IO
/// The file name.
///
/// The filesystem-relative complete file path.
- string GetFilePath(MediaFileManager fileManager, Guid? itemGuid, Guid? propertyGuid, string filename);
+ string GetFilePath(MediaFileManager fileManager, Guid itemGuid, Guid propertyGuid, string filename);
///
/// Gets the directory that can be deleted when the file is deleted.
diff --git a/src/Umbraco.Core/IO/MediaFileManager.cs b/src/Umbraco.Core/IO/MediaFileManager.cs
index 01b6f09424..c3462913ff 100644
--- a/src/Umbraco.Core/IO/MediaFileManager.cs
+++ b/src/Umbraco.Core/IO/MediaFileManager.cs
@@ -102,7 +102,7 @@ namespace Umbraco.Cms.Core.IO
/// The unique identifier of the property type owning the file.
/// The filesystem-relative path to the media file.
/// With the old media path scheme, this CREATES a new media path each time it is invoked.
- public string GetMediaPath(string? filename, Guid? cuid, Guid? puid)
+ public string GetMediaPath(string? filename, Guid cuid, Guid puid)
{
filename = Path.GetFileName(filename);
if (filename == null)
diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs b/src/Umbraco.Core/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs
index afbdb371bc..01579adb82 100644
--- a/src/Umbraco.Core/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs
+++ b/src/Umbraco.Core/IO/MediaPathSchemes/CombinedGuidsMediaPathScheme.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Cms.Core.IO.MediaPathSchemes
public class CombinedGuidsMediaPathScheme : IMediaPathScheme
{
///
- public string GetFilePath(MediaFileManager fileManager, Guid? itemGuid, Guid? propertyGuid, string filename)
+ public string GetFilePath(MediaFileManager fileManager, Guid itemGuid, Guid propertyGuid, string filename)
{
// assumes that cuid and puid keys can be trusted - and that a single property type
// for a single content cannot store two different files with the same name
diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs b/src/Umbraco.Core/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs
index 49921b299a..1ee821e3ed 100644
--- a/src/Umbraco.Core/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs
+++ b/src/Umbraco.Core/IO/MediaPathSchemes/TwoGuidsMediaPathScheme.cs
@@ -12,9 +12,9 @@ namespace Umbraco.Cms.Core.IO.MediaPathSchemes
public class TwoGuidsMediaPathScheme : IMediaPathScheme
{
///
- public string GetFilePath(MediaFileManager fileManager, Guid? itemGuid, Guid? propertyGuid, string filename)
+ public string GetFilePath(MediaFileManager fileManager, Guid itemGuid, Guid propertyGuid, string filename)
{
- return Path.Combine(itemGuid?.ToString("N"), propertyGuid?.ToString("N"), filename).Replace('\\', '/');
+ return Path.Combine(itemGuid.ToString("N"), propertyGuid.ToString("N"), filename).Replace('\\', '/');
}
///
diff --git a/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs b/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs
index feee7091c0..a3fe36bde9 100644
--- a/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs
+++ b/src/Umbraco.Core/IO/MediaPathSchemes/UniqueMediaPathScheme.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Core.IO.MediaPathSchemes
private const int DirectoryLength = 8;
///
- public string GetFilePath(MediaFileManager fileManager, Guid? itemGuid, Guid? propertyGuid, string filename)
+ public string GetFilePath(MediaFileManager fileManager, Guid itemGuid, Guid propertyGuid, string filename)
{
var combinedGuid = GuidUtils.Combine(itemGuid, propertyGuid);
var directory = GuidUtils.ToBase32String(combinedGuid, DirectoryLength);
diff --git a/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs b/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs
index 532bda8e13..0255cfd40e 100644
--- a/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs
+++ b/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs
@@ -30,12 +30,12 @@ namespace Umbraco.Cms.Core.Models.Editors
///
/// Gets or sets the unique identifier of the content owning the property.
///
- public Guid? ContentKey { get; set; }
+ public Guid ContentKey { get; set; }
///
/// Gets or sets the unique identifier of the property type.
///
- public Guid? PropertyTypeKey { get; set; }
+ public Guid PropertyTypeKey { get; set; }
///
/// Gets or sets the uploaded files.
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs
index 668986fbb5..573b4ac736 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs
@@ -112,7 +112,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
}
- private string? ProcessFile(ContentPropertyFile file, object? dataTypeConfiguration, Guid? cuid, Guid? puid)
+ private string? ProcessFile(ContentPropertyFile file, object? dataTypeConfiguration, Guid cuid, Guid puid)
{
// process the file
// no file, invalid file, reject change
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs
index 8a13ded02f..c9635ee121 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs
@@ -175,7 +175,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
return editorJson.ToString(Formatting.None);
}
- private string? ProcessFile(ContentPropertyFile file, Guid? cuid, Guid? puid)
+ private string? ProcessFile(ContentPropertyFile file, Guid cuid, Guid puid)
{
// process the file
// no file, invalid file, reject change
diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
index 37c35d1f1f..0a8606f01f 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
@@ -210,7 +210,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
},
{
"iconApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetIcon("") ?? new IconModel())
+ controller => controller.GetIcon("")!)
},
{
"imagesApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
@@ -266,7 +266,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
},
{
"memberApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetByKey(Guid.Empty) ?? new MemberDisplay())
+ controller => controller.GetByKey(Guid.Empty)!)
},
{
"packageApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
@@ -274,7 +274,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
},
{
"relationApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetById(0) ?? new RelationDisplay())
+ controller => controller.GetById(0)!)
},
{
"rteApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
@@ -358,7 +358,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
},
{
"languageApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetAllLanguages() ?? Enumerable.Empty())
+ controller => controller.GetAllLanguages()!)
},
{
"relationTypeApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
@@ -378,7 +378,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
},
{
"imageUrlGeneratorApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetCropUrl(string.Empty, null, null, null) ?? string.Empty)
+ controller => controller.GetCropUrl(string.Empty, null, null, null)!)
},
{
"elementTypeApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl(
diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentControllerBase.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentControllerBase.cs
index 6e4784eb09..8678972c2c 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/ContentControllerBase.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/ContentControllerBase.cs
@@ -121,7 +121,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
// get the property
- IProperty? property = contentItem.PersistedContent?.Properties[propertyDto.Alias];
+ IProperty property = contentItem.PersistedContent.Properties[propertyDto.Alias]!;
// prepare files, if any matching property and culture
ContentPropertyFile[] files = contentItem.UploadedFiles
@@ -133,11 +133,12 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
file.FileName = file.FileName?.ToSafeFileName(ShortStringHelper);
}
+
// create the property data for the property editor
var data = new ContentPropertyData(propertyDto.Value, propertyDto.DataType?.Configuration)
{
- ContentKey = contentItem.PersistedContent?.Key,
- PropertyTypeKey = property?.PropertyType.Key,
+ ContentKey = contentItem.PersistedContent!.Key,
+ PropertyTypeKey = property.PropertyType.Key,
Files = files
};