From 109d2f191eeb9e0943402db7da71635007a98ccc Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 6 May 2022 18:04:26 +0200 Subject: [PATCH] Further NRT updates for Deploy (#12375) * Nullability modifications to grid cell values and connector. * Nullable updates to IDataTypeConfigurationConnector. * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> --- src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector.cs | 4 ++-- src/Umbraco.Infrastructure/Deploy/IGridCellValueConnector.cs | 4 ++-- src/Umbraco.Infrastructure/Models/GridValue.cs | 4 ++-- .../PropertyEditors/GridPropertyEditor.cs | 4 ++-- .../Templates/HtmlMacroParameterParser.cs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector.cs b/src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector.cs index 548a6d80f1..87a00e7969 100644 --- a/src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector.cs +++ b/src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector.cs @@ -22,13 +22,13 @@ namespace Umbraco.Cms.Core.Deploy /// /// The datatype. /// The dependencies. - string ToArtifact(IDataType dataType, ICollection dependencies); + string? ToArtifact(IDataType dataType, ICollection dependencies); /// /// Gets the actual datatype configuration corresponding to the artifact configuration. /// /// The datatype. /// The artifact configuration. - object FromArtifact(IDataType dataType, string configuration); + object? FromArtifact(IDataType dataType, string? configuration); } } diff --git a/src/Umbraco.Infrastructure/Deploy/IGridCellValueConnector.cs b/src/Umbraco.Infrastructure/Deploy/IGridCellValueConnector.cs index 40c0b98474..94dabf7b4f 100644 --- a/src/Umbraco.Infrastructure/Deploy/IGridCellValueConnector.cs +++ b/src/Umbraco.Infrastructure/Deploy/IGridCellValueConnector.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Core.Deploy @@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.Deploy /// The dependencies of the property. /// The grid cell value to be deployed. /// Note that - string GetValue(GridValue.GridControl gridControl, ICollection dependencies); + string? GetValue(GridValue.GridControl gridControl, ICollection dependencies); /// /// Allows you to modify the value of a control being deployed. diff --git a/src/Umbraco.Infrastructure/Models/GridValue.cs b/src/Umbraco.Infrastructure/Models/GridValue.cs index e873287ffb..a83d235b55 100644 --- a/src/Umbraco.Infrastructure/Models/GridValue.cs +++ b/src/Umbraco.Infrastructure/Models/GridValue.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -63,7 +63,7 @@ namespace Umbraco.Cms.Core.Models public class GridControl { [JsonProperty("value")] - public JToken Value { get; set; } = null!; + public JToken? Value { get; set; } [JsonProperty("editor")] public GridEditor Editor { get; set; } = null!; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs index ca2dcefbbf..a0423a41f0 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs @@ -300,8 +300,8 @@ namespace Umbraco.Cms.Core.PropertyEditors if (mediaValues is not null) { - foreach (var umbracoEntityReference in mediaValues.Where(x => x.Value.HasValues) - .SelectMany(x => _mediaPickerPropertyValueEditor.GetReferences(x.Value["udi"]))) + foreach (var umbracoEntityReference in mediaValues.Where(x => x.Value?.HasValues ?? false) + .SelectMany(x => _mediaPickerPropertyValueEditor.GetReferences(x.Value!["udi"]))) { yield return umbracoEntityReference; } diff --git a/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs b/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs index fc6e08c0cd..7522585f47 100644 --- a/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs +++ b/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs @@ -57,7 +57,7 @@ namespace Umbraco.Cms.Infrastructure.Templates foreach (var macroGridControl in macroGridControls) { // Deserialise JSON of Macro Grid Control to a class - var gridMacro = macroGridControl.Value.ToObject(); + var gridMacro = macroGridControl.Value?.ToObject(); // Collect any macro parameters that contain the media udi format if (gridMacro is not null && gridMacro.MacroParameters is not null && gridMacro.MacroParameters.Any()) {