Make lots of models nullable

This commit is contained in:
Nikolaj Geisle
2022-01-21 11:43:58 +01:00
parent b6d5465b49
commit 936dd38c55
278 changed files with 1379 additions and 1237 deletions

View File

@@ -46,7 +46,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
/// <returns>
/// The <see cref="BlockListItem" /> with the specified content key.
/// </returns>
public BlockListItem this[Guid contentKey] => this.FirstOrDefault(x => x.Content.Key == contentKey);
public BlockListItem? this[Guid contentKey] => this.FirstOrDefault(x => x.Content.Key == contentKey);
/// <summary>
/// Gets the <see cref="BlockListItem" /> with the specified content UDI.
@@ -58,6 +58,6 @@ namespace Umbraco.Cms.Core.Models.Blocks
/// <returns>
/// The <see cref="BlockListItem" /> with the specified content UDI.
/// </returns>
public BlockListItem this[Udi contentUdi] => contentUdi is GuidUdi guidUdi ? this.FirstOrDefault(x => x.Content.Key == guidUdi.Guid) : null;
public BlockListItem? this[Udi contentUdi] => contentUdi is GuidUdi guidUdi ? this.FirstOrDefault(x => x.Content.Key == guidUdi.Guid) : null;
}
}

View File

@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
public Udi SettingsUdi { get; }
public override bool Equals(object obj) => obj is ContentAndSettingsReference reference && Equals(reference);
public override bool Equals(object? obj) => obj is ContentAndSettingsReference reference && Equals(reference);
public bool Equals(ContentAndSettingsReference other) => other != null
&& EqualityComparer<Udi>.Default.Equals(ContentUdi, other.ContentUdi)