More work on nullable references

This commit is contained in:
Nikolaj Geisle
2022-02-22 13:35:32 +01:00
parent 315e8d6fe6
commit a8cf6ee127
189 changed files with 1271 additions and 983 deletions

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
/// not serialized, manually set and used during internally
/// </summary>
[JsonIgnore]
public string? ContentTypeAlias { get; set; }
public string ContentTypeAlias { get; set; } = string.Empty;
[JsonProperty("udi")]
[JsonConverter(typeof(UdiJsonConverter))]
@@ -49,13 +49,13 @@ namespace Umbraco.Cms.Core.Models.Blocks
/// </summary>
public class BlockPropertyValue
{
public BlockPropertyValue(object value, IPropertyType propertyType)
public BlockPropertyValue(object? value, IPropertyType propertyType)
{
Value = value;
PropertyType = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
}
public object Value { get; }
public object? Value { get; }
public IPropertyType PropertyType { get; }
}
}

View File

@@ -33,7 +33,7 @@ namespace Umbraco.Cms.Core.Models
throw new InvalidDataException($"The content item {entity.NodeId} has an invalid path: {entity.Path} with parentID: {entity.ParentId}");
}
if (entity.ParentId != default(int) && pathParts[pathParts.Length - 2] != entity.ParentId.ToInvariantString())
if (entity.ParentId != default(int) && pathParts[pathParts.Length - 2] != entity.ParentId?.ToInvariantString())
{
//the 2nd last id in the path must be it's parent id
throw new InvalidDataException($"The content item {entity.NodeId} has an invalid path: {entity.Path} with parentID: {entity.ParentId}");