diff --git a/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
index 919320ec34..24b4637055 100644
--- a/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Core.Cache
/// The repository PerformGetAll method.
/// The entity with the specified identifier, if it exits, else null.
/// First considers the cache then the repository.
- TEntity? Get(TId id, Func performGet, Func> performGetAll);
+ TEntity? Get(TId? id, Func performGet, Func?> performGetAll);
///
/// Gets an entity from the cache.
@@ -33,7 +33,7 @@ namespace Umbraco.Cms.Core.Cache
/// The repository PerformGetAll method.
/// A value indicating whether an entity with the specified identifier exists.
/// First considers the cache then the repository.
- bool Exists(TId id, Func performExists, Func> performGetAll);
+ bool Exists(TId id, Func performExists, Func?> performGetAll);
///
/// Creates an entity.
@@ -66,7 +66,7 @@ namespace Umbraco.Cms.Core.Cache
/// The repository PerformGetAll method.
/// If is empty, all entities, else the entities with the specified identifiers.
/// Get all the entities. Either from the cache or the repository depending on the implementation.
- TEntity?[] GetAll(TId[] ids, Func> performGetAll);
+ TEntity[]? GetAll(TId[]? ids, Func?> performGetAll);
///
/// Clears the entire cache.
diff --git a/src/Umbraco.Core/Enum.cs b/src/Umbraco.Core/Enum.cs
index 787d157254..9ca1111a30 100644
--- a/src/Umbraco.Core/Enum.cs
+++ b/src/Umbraco.Core/Enum.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Umbraco.Cms.Core
diff --git a/src/Umbraco.Core/Extensions/StringExtensions.cs b/src/Umbraco.Core/Extensions/StringExtensions.cs
index cd629288e6..a2be76e109 100644
--- a/src/Umbraco.Core/Extensions/StringExtensions.cs
+++ b/src/Umbraco.Core/Extensions/StringExtensions.cs
@@ -548,7 +548,7 @@ namespace Umbraco.Extensions
/// The compare.
/// The compare to.
///
- public static bool InvariantEquals(this string compare, string? compareTo)
+ public static bool InvariantEquals(this string? compare, string? compareTo)
{
return String.Equals(compare, compareTo, StringComparison.InvariantCultureIgnoreCase);
}
diff --git a/src/Umbraco.Core/IO/IFileSystem.cs b/src/Umbraco.Core/IO/IFileSystem.cs
index 232827300c..853b91f663 100644
--- a/src/Umbraco.Core/IO/IFileSystem.cs
+++ b/src/Umbraco.Core/IO/IFileSystem.cs
@@ -97,7 +97,7 @@ namespace Umbraco.Cms.Core.IO
///
/// True if the file exists and the user has permission to view it; otherwise false.
///
- bool FileExists(string path);
+ bool FileExists(string? path);
///
/// Returns the application relative path to the file.
diff --git a/src/Umbraco.Core/Mapping/IUmbracoMapper.cs b/src/Umbraco.Core/Mapping/IUmbracoMapper.cs
index 5c3e980ac3..3b5b3f2ad3 100644
--- a/src/Umbraco.Core/Mapping/IUmbracoMapper.cs
+++ b/src/Umbraco.Core/Mapping/IUmbracoMapper.cs
@@ -131,7 +131,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The type of the target objects.
/// The source objects.
/// A list containing the target objects.
- List MapEnumerable(IEnumerable source);
+ List MapEnumerable(IEnumerable source);
///
/// Maps an enumerable of source objects to a new list of target objects.
@@ -141,7 +141,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source objects.
/// A mapper context preparation method.
/// A list containing the target objects.
- List MapEnumerable(IEnumerable source, Action f);
+ List MapEnumerable(IEnumerable source, Action f);
///
/// Maps an enumerable of source objects to a new list of target objects.
@@ -151,6 +151,6 @@ namespace Umbraco.Cms.Core.Mapping
/// The source objects.
/// A mapper context.
/// A list containing the target objects.
- List MapEnumerable(IEnumerable source, MapperContext context);
+ List MapEnumerable(IEnumerable source, MapperContext context);
}
}
diff --git a/src/Umbraco.Core/Models/ContentEditing/RollbackVersion.cs b/src/Umbraco.Core/Models/ContentEditing/RollbackVersion.cs
index 762c806dc9..ca0e3ff9af 100644
--- a/src/Umbraco.Core/Models/ContentEditing/RollbackVersion.cs
+++ b/src/Umbraco.Core/Models/ContentEditing/RollbackVersion.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
public int VersionId { get; set; }
[DataMember(Name = "versionDate")]
- public DateTime VersionDate { get; set; }
+ public DateTime? VersionDate { get; set; }
[DataMember(Name = "versionAuthorId")]
public int VersionAuthorId { get; set; }
diff --git a/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs b/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs
index 8001da7db8..5fec2930b5 100644
--- a/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs
+++ b/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Extensions
///
public static class ContentRepositoryExtensions
{
- public static void SetCultureInfo(this IContentBase content, string culture, string? name, DateTime date)
+ public static void SetCultureInfo(this IContentBase content, string? culture, string? name, DateTime date)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
@@ -203,7 +203,7 @@ namespace Umbraco.Extensions
}
}
- public static void SetPublishInfo(this IContent content, string? culture, string name, DateTime date)
+ public static void SetPublishInfo(this IContent content, string? culture, string? name, DateTime date)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
@@ -215,13 +215,13 @@ namespace Umbraco.Extensions
}
// sets the edited cultures on the content
- public static void SetCultureEdited(this IContent content, IEnumerable cultures)
+ public static void SetCultureEdited(this IContent content, IEnumerable cultures)
{
if (cultures == null)
content.EditedCultures = null;
else
{
- var editedCultures = new HashSet(cultures.Where(x => !x.IsNullOrWhiteSpace()), StringComparer.OrdinalIgnoreCase);
+ var editedCultures = new HashSet(cultures.Where(x => !x.IsNullOrWhiteSpace())!, StringComparer.OrdinalIgnoreCase);
content.EditedCultures = editedCultures.Count > 0 ? editedCultures : null;
}
}
diff --git a/src/Umbraco.Core/Models/DictionaryItem.cs b/src/Umbraco.Core/Models/DictionaryItem.cs
index 79f922ecb7..359d6de01c 100644
--- a/src/Umbraco.Core/Models/DictionaryItem.cs
+++ b/src/Umbraco.Core/Models/DictionaryItem.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Core.Models
public Func? GetLanguage { get; set; }
private Guid? _parentId;
private string _itemKey;
- private IEnumerable? _translations;
+ private IEnumerable _translations;
public DictionaryItem(string itemKey)
: this(null, itemKey)
@@ -60,7 +60,7 @@ namespace Umbraco.Cms.Core.Models
/// Gets or sets a list of translations for the Dictionary Item
///
[DataMember]
- public IEnumerable? Translations
+ public IEnumerable Translations
{
get { return _translations; }
set
diff --git a/src/Umbraco.Core/Models/Entities/EntityBase.cs b/src/Umbraco.Core/Models/Entities/EntityBase.cs
index 57b9eeae1f..9461fc1651 100644
--- a/src/Umbraco.Core/Models/Entities/EntityBase.cs
+++ b/src/Umbraco.Core/Models/Entities/EntityBase.cs
@@ -19,8 +19,8 @@ namespace Umbraco.Cms.Core.Models.Entities
private bool _hasIdentity;
private int _id;
private Guid _key;
- private DateTime _createDate;
- private DateTime _updateDate;
+ private DateTime? _createDate;
+ private DateTime? _updateDate;
///
[DataMember]
@@ -50,7 +50,7 @@ namespace Umbraco.Cms.Core.Models.Entities
///
[DataMember]
- public DateTime CreateDate
+ public DateTime? CreateDate
{
get => _createDate;
set => SetPropertyValueAndDetectChanges(value, ref _createDate, nameof(CreateDate));
@@ -58,7 +58,7 @@ namespace Umbraco.Cms.Core.Models.Entities
///
[DataMember]
- public DateTime UpdateDate
+ public DateTime? UpdateDate
{
get => _updateDate;
set => SetPropertyValueAndDetectChanges(value, ref _updateDate, nameof(UpdateDate));
diff --git a/src/Umbraco.Core/Models/EntityContainer.cs b/src/Umbraco.Core/Models/EntityContainer.cs
index 31a72356db..114d78605c 100644
--- a/src/Umbraco.Core/Models/EntityContainer.cs
+++ b/src/Umbraco.Core/Models/EntityContainer.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Initializes a new instance of an class.
///
- public EntityContainer(int id, Guid uniqueId, int parentId, string path, int level, int sortOrder, Guid containedObjectType, string name, int userId)
+ public EntityContainer(int id, Guid uniqueId, int parentId, string path, int level, int sortOrder, Guid containedObjectType, string? name, int userId)
: this(containedObjectType)
{
Id = id;
diff --git a/src/Umbraco.Core/Models/File.cs b/src/Umbraco.Core/Models/File.cs
index ec493ad937..3865d4eee7 100644
--- a/src/Umbraco.Core/Models/File.cs
+++ b/src/Umbraco.Core/Models/File.cs
@@ -19,9 +19,9 @@ namespace Umbraco.Cms.Core.Models
// cannot simply use HasIdentity as some classes (eg Script) override it
// in a weird way.
private string? _content;
- public Func? GetFileContent { get; set; }
+ public Func? GetFileContent { get; set; }
- protected File(string path, Func? getFileContent = null)
+ protected File(string path, Func? getFileContent = null)
{
_path = SanitizePath(path);
_originalPath = _path;
diff --git a/src/Umbraco.Core/Models/IDictionaryItem.cs b/src/Umbraco.Core/Models/IDictionaryItem.cs
index 5b0d868f83..f299ce2ac5 100644
--- a/src/Umbraco.Core/Models/IDictionaryItem.cs
+++ b/src/Umbraco.Core/Models/IDictionaryItem.cs
@@ -23,6 +23,6 @@ namespace Umbraco.Cms.Core.Models
/// Gets or sets a list of translations for the Dictionary Item
///
[DataMember]
- IEnumerable? Translations { get; set; }
+ IEnumerable Translations { get; set; }
}
}
diff --git a/src/Umbraco.Core/Models/IRedirectUrl.cs b/src/Umbraco.Core/Models/IRedirectUrl.cs
index f2e4e131a7..18498837b4 100644
--- a/src/Umbraco.Core/Models/IRedirectUrl.cs
+++ b/src/Umbraco.Core/Models/IRedirectUrl.cs
@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Is a proper Umbraco route eg /path/to/foo or 123/path/tofoo.
[DataMember]
- string? Url { get; set; }
+ string Url { get; set; }
}
}
diff --git a/src/Umbraco.Core/Models/ITag.cs b/src/Umbraco.Core/Models/ITag.cs
index fdef14fec0..79840481bb 100644
--- a/src/Umbraco.Core/Models/ITag.cs
+++ b/src/Umbraco.Core/Models/ITag.cs
@@ -12,13 +12,13 @@ namespace Umbraco.Cms.Core.Models
/// Gets or sets the tag group.
///
[DataMember]
- string? Group { get; set; }
+ string Group { get; set; }
///
/// Gets or sets the tag text.
///
[DataMember]
- string? Text { get; set; }
+ string Text { get; set; }
///
/// Gets or sets the tag language.
diff --git a/src/Umbraco.Core/Models/ITwoFactorLogin.cs b/src/Umbraco.Core/Models/ITwoFactorLogin.cs
index 92b798fe0d..ca005309b2 100644
--- a/src/Umbraco.Core/Models/ITwoFactorLogin.cs
+++ b/src/Umbraco.Core/Models/ITwoFactorLogin.cs
@@ -5,8 +5,8 @@ namespace Umbraco.Cms.Core.Models
{
public interface ITwoFactorLogin: IEntity, IRememberBeingDirty
{
- string? ProviderName { get; }
- string? Secret { get; }
+ string ProviderName { get; }
+ string Secret { get; }
Guid UserOrMemberKey { get; }
}
}
diff --git a/src/Umbraco.Core/Models/LogViewerQuery.cs b/src/Umbraco.Core/Models/LogViewerQuery.cs
index 05009733ae..e9c0dc3180 100644
--- a/src/Umbraco.Core/Models/LogViewerQuery.cs
+++ b/src/Umbraco.Core/Models/LogViewerQuery.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Cms.Core.Models
private string? _name;
private string? _query;
- public LogViewerQuery(string name, string query)
+ public LogViewerQuery(string? name, string? query)
{
Name = name;
_query = query;
diff --git a/src/Umbraco.Core/Models/Media.cs b/src/Umbraco.Core/Models/Media.cs
index 60542d78cb..926fe2ef09 100644
--- a/src/Umbraco.Core/Models/Media.cs
+++ b/src/Umbraco.Core/Models/Media.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Cms.Core.Models
/// name of the Media object
/// Id of the Parent IMedia
/// MediaType for the current Media object
- public Media(string? name, int parentId, IMediaType mediaType)
+ public Media(string? name, int parentId, IMediaType? mediaType)
: this(name, parentId, mediaType, new PropertyCollection())
{ }
@@ -48,7 +48,7 @@ namespace Umbraco.Cms.Core.Models
/// Id of the Parent IMedia
/// MediaType for the current Media object
/// Collection of properties
- public Media(string? name, int parentId, IMediaType mediaType, IPropertyCollection properties)
+ public Media(string? name, int parentId, IMediaType? mediaType, IPropertyCollection properties)
: base(name, parentId, mediaType, properties)
{ }
diff --git a/src/Umbraco.Core/Models/Member.cs b/src/Umbraco.Core/Models/Member.cs
index c4eca5d2d1..00d1fe93fe 100644
--- a/src/Umbraco.Core/Models/Member.cs
+++ b/src/Umbraco.Core/Models/Member.cs
@@ -131,7 +131,7 @@ namespace Umbraco.Cms.Core.Models
/// The password value passed in to this parameter should be the encoded/encrypted/hashed format of the member's password
///
///
- public Member(string? name, string email, string username, string rawPasswordValue, IMemberType contentType)
+ public Member(string? name, string email, string username, string? rawPasswordValue, IMemberType? contentType)
: base(name, -1, contentType, new PropertyCollection())
{
_email = email;
@@ -362,7 +362,7 @@ namespace Umbraco.Cms.Core.Models
/// Part of the standard properties collection.
///
[DataMember]
- public DateTime LastLoginDate
+ public DateTime? LastLoginDate
{
get
{
@@ -398,7 +398,7 @@ namespace Umbraco.Cms.Core.Models
/// Part of the standard properties collection.
///
[DataMember]
- public DateTime LastPasswordChangeDate
+ public DateTime? LastPasswordChangeDate
{
get
{
diff --git a/src/Umbraco.Core/Models/Membership/IUser.cs b/src/Umbraco.Core/Models/Membership/IUser.cs
index c7c68dabda..ca41d892e7 100644
--- a/src/Umbraco.Core/Models/Membership/IUser.cs
+++ b/src/Umbraco.Core/Models/Membership/IUser.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Core.Models.Membership
{
UserState UserState { get; }
- string? Name { get; set; }
+ string Name { get; set; }
int SessionTimeout { get; set; }
int[]? StartContentIds { get; set; }
int[]? StartMediaIds { get; set; }
diff --git a/src/Umbraco.Core/Models/Notification.cs b/src/Umbraco.Core/Models/Notification.cs
index b65064f266..95091efe1f 100644
--- a/src/Umbraco.Core/Models/Notification.cs
+++ b/src/Umbraco.Core/Models/Notification.cs
@@ -4,7 +4,7 @@ namespace Umbraco.Cms.Core.Models
{
public class Notification
{
- public Notification(int entityId, int userId, string action, Guid entityType)
+ public Notification(int entityId, int userId, string action, Guid? entityType)
{
EntityId = entityId;
UserId = userId;
@@ -15,6 +15,6 @@ namespace Umbraco.Cms.Core.Models
public int EntityId { get; private set; }
public int UserId { get; private set; }
public string Action { get; private set; }
- public Guid EntityType { get; private set; }
+ public Guid? EntityType { get; private set; }
}
}
diff --git a/src/Umbraco.Core/Models/PartialView.cs b/src/Umbraco.Core/Models/PartialView.cs
index d78a6603bb..ffa9412c51 100644
--- a/src/Umbraco.Core/Models/PartialView.cs
+++ b/src/Umbraco.Core/Models/PartialView.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Core.Models
: this(viewType, path, null)
{ }
- public PartialView(PartialViewType viewType, string path, Func? getFileContent)
+ public PartialView(PartialViewType viewType, string path, Func? getFileContent)
: base(path, getFileContent)
{
ViewType = viewType;
diff --git a/src/Umbraco.Core/Models/Property.cs b/src/Umbraco.Core/Models/Property.cs
index 1fd52add4b..6633aecb6d 100644
--- a/src/Umbraco.Core/Models/Property.cs
+++ b/src/Umbraco.Core/Models/Property.cs
@@ -76,7 +76,7 @@ namespace Umbraco.Cms.Core.Models
///
public class InitialPropertyValue
{
- public InitialPropertyValue(string culture, string? segment, bool published, object? value)
+ public InitialPropertyValue(string? culture, string? segment, bool published, object? value)
{
Culture = culture;
Segment = segment;
@@ -84,7 +84,7 @@ namespace Umbraco.Cms.Core.Models
Value = value;
}
- public string Culture { get; }
+ public string? Culture { get; }
public string? Segment { get; }
public bool Published { get; }
public object? Value { get; }
diff --git a/src/Umbraco.Core/Models/Relation.cs b/src/Umbraco.Core/Models/Relation.cs
index 54227db910..7cb447ccc3 100644
--- a/src/Umbraco.Core/Models/Relation.cs
+++ b/src/Umbraco.Core/Models/Relation.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Core.Models
//NOTE: The datetime column from umbracoRelation is set on CreateDate on the Entity
private int _parentId;
private int _childId;
- private IRelationType _relationType;
+ private IRelationType? _relationType;
private string? _comment;
///
@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Models
///
///
///
- public Relation(int parentId, int childId, Guid parentObjectType, Guid childObjectType, IRelationType relationType)
+ public Relation(int parentId, int childId, Guid parentObjectType, Guid childObjectType, IRelationType? relationType)
{
_parentId = parentId;
_childId = childId;
diff --git a/src/Umbraco.Core/Models/Script.cs b/src/Umbraco.Core/Models/Script.cs
index 9f1bad9e99..0d121368f8 100644
--- a/src/Umbraco.Core/Models/Script.cs
+++ b/src/Umbraco.Core/Models/Script.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Core.Models
: this(path, (Func?) null)
{ }
- public Script(string path, Func? getFileContent)
+ public Script(string path, Func? getFileContent)
: base(path, getFileContent)
{ }
diff --git a/src/Umbraco.Core/Models/ServerRegistration.cs b/src/Umbraco.Core/Models/ServerRegistration.cs
index 553460eb5b..cc86ee6bdd 100644
--- a/src/Umbraco.Core/Models/ServerRegistration.cs
+++ b/src/Umbraco.Core/Models/ServerRegistration.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Cms.Core.Models
/// The date and time the registration was last accessed.
/// A value indicating whether the registration is active.
/// A value indicating whether the registration is master.
- public ServerRegistration(int id, string? serverAddress, string? serverIdentity, DateTime registered, DateTime accessed, bool isActive, bool isSchedulingPublisher)
+ public ServerRegistration(int id, string? serverAddress, string? serverIdentity, DateTime? registered, DateTime? accessed, bool isActive, bool isSchedulingPublisher)
{
UpdateDate = accessed;
CreateDate = registered;
diff --git a/src/Umbraco.Core/Models/Stylesheet.cs b/src/Umbraco.Core/Models/Stylesheet.cs
index 18f9420d75..7b1d971434 100644
--- a/src/Umbraco.Core/Models/Stylesheet.cs
+++ b/src/Umbraco.Core/Models/Stylesheet.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Cms.Core.Models
: this(path, null)
{ }
- public Stylesheet(string path, Func? getFileContent)
+ public Stylesheet(string path, Func? getFileContent)
: base(string.IsNullOrEmpty(path) ? path : path.EnsureEndsWith(".css"), getFileContent)
{
InitializeProperties();
diff --git a/src/Umbraco.Core/Models/TaggedProperty.cs b/src/Umbraco.Core/Models/TaggedProperty.cs
index d2c5dc0b23..24ef9ccc45 100644
--- a/src/Umbraco.Core/Models/TaggedProperty.cs
+++ b/src/Umbraco.Core/Models/TaggedProperty.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Initializes a new instance of the class.
///
- public TaggedProperty(int propertyTypeId, string propertyTypeAlias, IEnumerable tags)
+ public TaggedProperty(int propertyTypeId, string? propertyTypeAlias, IEnumerable tags)
{
PropertyTypeId = propertyTypeId;
PropertyTypeAlias = propertyTypeAlias;
@@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Gets the alias of the property type.
///
- public string PropertyTypeAlias { get; }
+ public string? PropertyTypeAlias { get; }
///
/// Gets the tags.
diff --git a/src/Umbraco.Core/Models/Template.cs b/src/Umbraco.Core/Models/Template.cs
index d2029fa801..b2e3f16de9 100644
--- a/src/Umbraco.Core/Models/Template.cs
+++ b/src/Umbraco.Core/Models/Template.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Cms.Core.Models
: this(shortStringHelper, name, alias, null)
{ }
- public Template(IShortStringHelper shortStringHelper, string? name, string alias, Func? getFileContent)
+ public Template(IShortStringHelper shortStringHelper, string? name, string alias, Func? getFileContent)
: base(string.Empty, getFileContent)
{
_shortStringHelper = shortStringHelper;
diff --git a/src/Umbraco.Core/Models/TwoFactorLogin.cs b/src/Umbraco.Core/Models/TwoFactorLogin.cs
index 350a5f2f1a..c38105626c 100644
--- a/src/Umbraco.Core/Models/TwoFactorLogin.cs
+++ b/src/Umbraco.Core/Models/TwoFactorLogin.cs
@@ -5,8 +5,8 @@ namespace Umbraco.Cms.Core.Models
{
public class TwoFactorLogin : EntityBase, ITwoFactorLogin
{
- public string? ProviderName { get; set; }
- public string? Secret { get; set; }
+ public string ProviderName { get; set; } = null!;
+ public string Secret { get; set; } = null!;
public Guid UserOrMemberKey { get; set; }
public bool Confirmed { get; set; }
}
diff --git a/src/Umbraco.Core/Persistence/IQueryRepository.cs b/src/Umbraco.Core/Persistence/IQueryRepository.cs
index 9513573908..6623fbf0fc 100644
--- a/src/Umbraco.Core/Persistence/IQueryRepository.cs
+++ b/src/Umbraco.Core/Persistence/IQueryRepository.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Cms.Core.Persistence
///
/// Gets entities.
///
- IEnumerable Get(IQuery query);
+ IEnumerable? Get(IQuery query);
///
/// Counts entities.
diff --git a/src/Umbraco.Core/Persistence/IReadRepository.cs b/src/Umbraco.Core/Persistence/IReadRepository.cs
index 3e495f7e36..57a25f3f81 100644
--- a/src/Umbraco.Core/Persistence/IReadRepository.cs
+++ b/src/Umbraco.Core/Persistence/IReadRepository.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Core.Persistence
///
/// Gets entities.
///
- IEnumerable GetMany(params TId?[] ids);
+ IEnumerable? GetMany(params TId[]? ids);
///
/// Gets a value indicating whether an entity exists.
diff --git a/src/Umbraco.Core/Persistence/Querying/IQuery.cs b/src/Umbraco.Core/Persistence/Querying/IQuery.cs
index c55d14001d..d2a3b0830f 100644
--- a/src/Umbraco.Core/Persistence/Querying/IQuery.cs
+++ b/src/Umbraco.Core/Persistence/Querying/IQuery.cs
@@ -30,7 +30,7 @@ namespace Umbraco.Cms.Core.Persistence.Querying
///
///
/// This instance so calls to this method are chainable
- IQuery WhereIn(Expression> fieldSelector, IEnumerable values);
+ IQuery WhereIn(Expression> fieldSelector, IEnumerable? values);
///
/// Adds a set of OR-ed where clauses to the query.
diff --git a/src/Umbraco.Core/Persistence/Repositories/IContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IContentRepository.cs
index be12da3203..b753d35544 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IContentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IContentRepository.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// Gets a version.
///
- TEntity GetVersion(int versionId);
+ TEntity? GetVersion(int versionId);
///
/// Deletes a version.
@@ -54,7 +54,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// Gets the recycle bin content.
///
- IEnumerable GetRecycleBin();
+ IEnumerable? GetRecycleBin();
///
/// Gets the count of content items of a given content type.
diff --git a/src/Umbraco.Core/Persistence/Repositories/IContentTypeCommonRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IContentTypeCommonRepository.cs
index 955ad47a72..7bdfa294c8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IContentTypeCommonRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IContentTypeCommonRepository.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// Gets and cache all types.
///
- IEnumerable GetAllTypes();
+ IEnumerable? GetAllTypes();
///
/// Clears the cache.
diff --git a/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs
index c448b39ce9..555624b1a0 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs
@@ -6,8 +6,8 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface IDictionaryRepository : IReadWriteQueryRepository
{
- IDictionaryItem Get(Guid uniqueId);
- IDictionaryItem Get(string key);
+ IDictionaryItem? Get(Guid uniqueId);
+ IDictionaryItem? Get(string key);
IEnumerable GetDictionaryItemDescendants(Guid? parentId);
Dictionary GetDictionaryItemKeyMap();
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IDocumentVersionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IDocumentVersionRepository.cs
index 38f425d5a1..ee46db3690 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IDocumentVersionRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IDocumentVersionRepository.cs
@@ -8,17 +8,17 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// Gets a list of all historic content versions.
///
- public IReadOnlyCollection GetDocumentVersionsEligibleForCleanup();
+ public IReadOnlyCollection? GetDocumentVersionsEligibleForCleanup();
///
/// Gets cleanup policy override settings per content type.
///
- public IReadOnlyCollection GetCleanupPolicies();
+ public IReadOnlyCollection? GetCleanupPolicies();
///
/// Gets paginated content versions for given content id paginated.
///
- public IEnumerable GetPagedItemsByContentId(int contentId, long pageIndex, int pageSize, out long totalRecords, int? languageId = null);
+ public IEnumerable? GetPagedItemsByContentId(int contentId, long pageIndex, int pageSize, out long totalRecords, int? languageId = null);
///
/// Deletes multiple content versions by ID.
@@ -33,6 +33,6 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// Gets the content version metadata for a specific version.
///
- ContentVersionMeta Get(int versionId);
+ ContentVersionMeta? Get(int versionId);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IDomainRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IDomainRepository.cs
index a0827f95c1..007c2928a4 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IDomainRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IDomainRepository.cs
@@ -5,9 +5,9 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface IDomainRepository : IReadWriteQueryRepository
{
- IDomain GetByName(string domainName);
+ IDomain? GetByName(string domainName);
bool Exists(string domainName);
- IEnumerable GetAll(bool includeWildcards);
- IEnumerable GetAssignedDomains(int contentId, bool includeWildcards);
+ IEnumerable? GetAll(bool includeWildcards);
+ IEnumerable? GetAssignedDomains(int contentId, bool includeWildcards);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IEntityContainerRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IEntityContainerRepository.cs
index 36a07c2fe9..6b8ece1bfd 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IEntityContainerRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IEntityContainerRepository.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface IEntityContainerRepository : IReadRepository, IWriteRepository
{
- EntityContainer Get(Guid id);
+ EntityContainer? Get(Guid id);
IEnumerable Get(string name, int level);
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs
index 30efd080d9..8eeab0b834 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IEntityRepository.cs
@@ -9,10 +9,10 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface IEntityRepository : IRepository
{
- IEntitySlim Get(int id);
- IEntitySlim Get(Guid key);
- IEntitySlim Get(int id, Guid objectTypeId);
- IEntitySlim Get(Guid key, Guid objectTypeId);
+ IEntitySlim? Get(int id);
+ IEntitySlim? Get(Guid key);
+ IEntitySlim? Get(int id, Guid objectTypeId);
+ IEntitySlim? Get(Guid key, Guid objectTypeId);
IEnumerable GetAll(Guid objectType, params int[] ids);
IEnumerable GetAll(Guid objectType, params Guid[] keys);
diff --git a/src/Umbraco.Core/Persistence/Repositories/IFileRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IFileRepository.cs
index ce76086ed2..0ecff83bf8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IFileRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IFileRepository.cs
@@ -4,7 +4,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface IFileRepository
{
- Stream GetFileContentStream(string filepath);
+ Stream? GetFileContentStream(string filepath);
void SetFileContent(string filepath, Stream content);
diff --git a/src/Umbraco.Core/Persistence/Repositories/IKeyValueRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IKeyValueRepository.cs
index 0b0f9193fa..94001609d6 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IKeyValueRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IKeyValueRepository.cs
@@ -10,6 +10,6 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
///
///
- IReadOnlyDictionary FindByKeyPrefix(string keyPrefix);
+ IReadOnlyDictionary? FindByKeyPrefix(string keyPrefix);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs
index eeaeed82bb..1be32de989 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs
@@ -4,7 +4,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface ILanguageRepository : IReadWriteQueryRepository
{
- ILanguage GetByIsoCode(string isoCode);
+ ILanguage? GetByIsoCode(string isoCode);
///
/// Gets a language identifier from its ISO code.
@@ -20,7 +20,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// This can be optimized and bypass all deep cloning.
///
- string GetIsoCodeById(int? id, bool throwOnNotFound = true);
+ string? GetIsoCodeById(int? id, bool throwOnNotFound = true);
///
/// Gets the default language ISO code.
diff --git a/src/Umbraco.Core/Persistence/Repositories/ILogViewerQueryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ILogViewerQueryRepository.cs
index d21cd2aa1e..8e3d779b9d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ILogViewerQueryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ILogViewerQueryRepository.cs
@@ -4,6 +4,6 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface ILogViewerQueryRepository : IReadWriteQueryRepository
{
- ILogViewerQuery GetByName(string name);
+ ILogViewerQuery? GetByName(string name);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IMediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMediaRepository.cs
index d07f2a68c7..ad268c6292 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IMediaRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IMediaRepository.cs
@@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface IMediaRepository : IContentRepository, IReadRepository
{
- IMedia GetMediaByPath(string mediaPath);
+ IMedia? GetMediaByPath(string mediaPath);
bool RecycleBinSmells();
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IMemberGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMemberGroupRepository.cs
index 2c80106aab..2307ff2b8b 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IMemberGroupRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IMemberGroupRepository.cs
@@ -11,20 +11,20 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
///
///
- IMemberGroup Get(Guid uniqueId);
+ IMemberGroup? Get(Guid uniqueId);
///
/// Gets a member group by it's name
///
///
///
- IMemberGroup GetByName(string name);
+ IMemberGroup? GetByName(string name);
///
/// Creates the new member group if it doesn't already exist
///
///
- IMemberGroup CreateIfNotExists(string roleName);
+ IMemberGroup? CreateIfNotExists(string roleName);
///
/// Returns the member groups for a given member
diff --git a/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs
index 9b24d60a9f..f6cf00c5bf 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
int[] GetMemberIds(string[] names);
- IMember GetByUsername(string username);
+ IMember? GetByUsername(string username);
///
/// Finds members in a given role
diff --git a/src/Umbraco.Core/Persistence/Repositories/INotificationsRepository.cs b/src/Umbraco.Core/Persistence/Repositories/INotificationsRepository.cs
index 18585b06a0..be1a00a130 100644
--- a/src/Umbraco.Core/Persistence/Repositories/INotificationsRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/INotificationsRepository.cs
@@ -12,9 +12,9 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
int DeleteNotifications(IUser user);
int DeleteNotifications(IEntity entity);
int DeleteNotifications(IUser user, IEntity entity);
- IEnumerable GetEntityNotifications(IEntity entity);
- IEnumerable GetUserNotifications(IUser user);
- IEnumerable GetUsersNotifications(IEnumerable userIds, string? action, IEnumerable nodeIds, Guid objectType);
+ IEnumerable? GetEntityNotifications(IEntity entity);
+ IEnumerable? GetUserNotifications(IUser user);
+ IEnumerable? GetUsersNotifications(IEnumerable userIds, string? action, IEnumerable nodeIds, Guid objectType);
IEnumerable SetNotifications(IUser user, IEntity entity, string[] actions);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IRedirectUrlRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IRedirectUrlRepository.cs
index d02fe72bc8..17be5b3856 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IRedirectUrlRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IRedirectUrlRepository.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
/// The content unique key.
/// The culture.
///
- IRedirectUrl Get(string url, Guid contentKey, string? culture);
+ IRedirectUrl? Get(string url, Guid contentKey, string? culture);
///
/// Deletes a redirect URL.
@@ -40,7 +40,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// The Umbraco redirect URL route.
/// The most recent redirect URL corresponding to the route.
- IRedirectUrl GetMostRecentUrl(string url);
+ IRedirectUrl? GetMostRecentUrl(string url);
///
/// Gets the most recent redirect URL corresponding to an Umbraco redirect URL route.
@@ -48,7 +48,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
/// The Umbraco redirect URL route.
/// The culture the domain is associated with
/// The most recent redirect URL corresponding to the route.
- IRedirectUrl GetMostRecentUrl(string url, string culture);
+ IRedirectUrl? GetMostRecentUrl(string url, string culture);
///
/// Gets all redirect URLs for a content item.
diff --git a/src/Umbraco.Core/Persistence/Repositories/ITagRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ITagRepository.cs
index d9794ed1bd..e2fa2e4406 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ITagRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ITagRepository.cs
@@ -50,12 +50,12 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// Gets a tagged entity.
///
- TaggedEntity GetTaggedEntityByKey(Guid key);
+ TaggedEntity? GetTaggedEntityByKey(Guid key);
///
/// Gets a tagged entity.
///
- TaggedEntity GetTaggedEntityById(int id);
+ TaggedEntity? GetTaggedEntityById(int id);
/// Gets all entities of a type, tagged with any tag in the specified group.
IEnumerable GetTaggedEntitiesByTagGroup(TaggableObjectTypes objectType, string group, string? culture = null);
diff --git a/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs
index 34b061a50e..fd206d5aff 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs
@@ -5,11 +5,11 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface ITemplateRepository : IReadWriteQueryRepository, IFileRepository
{
- ITemplate Get(string? alias);
+ ITemplate? Get(string? alias);
- IEnumerable GetAll(params string[] aliases);
+ IEnumerable? GetAll(params string[] aliases);
- IEnumerable GetChildren(int masterTemplateId);
+ IEnumerable? GetChildren(int masterTemplateId);
IEnumerable GetDescendants(int masterTemplateId);
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs
index 6f2cd75bdb..f90596b1f8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
///
///
- IUserGroup Get(string alias);
+ IUserGroup? Get(string alias);
///
/// This is useful when an entire section is removed from config
diff --git a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
index 1c74f8430e..f5649526d9 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
@@ -83,7 +83,7 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// A non cached instance
///
- IUser GetByUsername(string username, bool includeSecurityData);
+ IUser? GetByUsername(string username, bool includeSecurityData);
///
/// Returns a user by id
@@ -95,10 +95,10 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// A non cached instance
///
- IUser Get(int? id, bool includeSecurityData);
+ IUser? Get(int? id, bool includeSecurityData);
- IProfile GetProfile(string username);
- IProfile GetProfile(int id);
+ IProfile? GetProfile(string username);
+ IProfile? GetProfile(int id);
IDictionary GetUserStates();
Guid CreateLoginSession(int? userId, string requestingIpAddress, bool cleanStaleSessions = true);
diff --git a/src/Umbraco.Core/Persistence/SqlExtensionsStatics.cs b/src/Umbraco.Core/Persistence/SqlExtensionsStatics.cs
index ef20e93282..cec65de33f 100644
--- a/src/Umbraco.Core/Persistence/SqlExtensionsStatics.cs
+++ b/src/Umbraco.Core/Persistence/SqlExtensionsStatics.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Cms.Core.Persistence
///
/// The field to alias.
/// The alias.
- public static object Alias(object field, string alias) => field;
+ public static object Alias(object? field, string alias) => field;
///
/// Produces Sql text.
diff --git a/src/Umbraco.Core/Scoping/IScopeProvider.cs b/src/Umbraco.Core/Scoping/IScopeProvider.cs
index c9c30662b4..d4bfee3886 100644
--- a/src/Umbraco.Core/Scoping/IScopeProvider.cs
+++ b/src/Umbraco.Core/Scoping/IScopeProvider.cs
@@ -85,7 +85,7 @@ namespace Umbraco.Cms.Core.Scoping
///
/// Creates an instance of
///
- IQuery CreateQuery();
+ IQuery? CreateQuery();
#if DEBUG_SCOPES
diff --git a/src/Umbraco.Core/Security/IdentityUserLogin.cs b/src/Umbraco.Core/Security/IdentityUserLogin.cs
index 402660ead9..efe0dcbf66 100644
--- a/src/Umbraco.Core/Security/IdentityUserLogin.cs
+++ b/src/Umbraco.Core/Security/IdentityUserLogin.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Cms.Core.Security
///
/// Initializes a new instance of the class.
///
- public IdentityUserLogin(int id, string loginProvider, string providerKey, string userId, DateTime createDate)
+ public IdentityUserLogin(int id, string loginProvider, string providerKey, string userId, DateTime? createDate)
{
Id = id;
LoginProvider = loginProvider;
diff --git a/src/Umbraco.Core/Services/IAuditService.cs b/src/Umbraco.Core/Services/IAuditService.cs
index 8af4058c12..cbc3db8239 100644
--- a/src/Umbraco.Core/Services/IAuditService.cs
+++ b/src/Umbraco.Core/Services/IAuditService.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Cms.Core.Services
{
void Add(AuditType type, int userId, int objectId, string? entityType, string comment, string? parameters = null);
- IEnumerable GetLogs(int objectId);
+ IEnumerable? GetLogs(int objectId);
IEnumerable GetUserLogs(int userId, AuditType type, DateTime? sinceDate = null);
IEnumerable GetLogs(AuditType type, DateTime? sinceDate = null);
void CleanLogs(int maximumAgeOfLogsInMinutes);
diff --git a/src/Umbraco.Core/Services/IDataTypeService.cs b/src/Umbraco.Core/Services/IDataTypeService.cs
index f7c222925c..56766bbe23 100644
--- a/src/Umbraco.Core/Services/IDataTypeService.cs
+++ b/src/Umbraco.Core/Services/IDataTypeService.cs
@@ -20,10 +20,10 @@ namespace Umbraco.Cms.Core.Services
Attempt?> CreateContainer(int parentId, Guid key, string name, int userId = Constants.Security.SuperUserId);
Attempt SaveContainer(EntityContainer container, int userId = Constants.Security.SuperUserId);
EntityContainer? GetContainer(int containerId);
- EntityContainer GetContainer(Guid containerId);
+ EntityContainer? GetContainer(Guid containerId);
IEnumerable GetContainers(string folderName, int level);
- IEnumerable GetContainers(IDataType dataType);
- IEnumerable GetContainers(int[] containerIds);
+ IEnumerable? GetContainers(IDataType dataType);
+ IEnumerable? GetContainers(int[] containerIds);
Attempt DeleteContainer(int containerId, int userId = Constants.Security.SuperUserId);
Attempt?> RenameContainer(int id, string name, int userId = Constants.Security.SuperUserId);
@@ -53,7 +53,7 @@ namespace Umbraco.Cms.Core.Services
///
/// Optional array of Ids
/// An enumerable list of objects
- IEnumerable GetAll(params int[] ids);
+ IEnumerable? GetAll(params int[] ids);
///
/// Saves an
@@ -85,7 +85,7 @@ namespace Umbraco.Cms.Core.Services
///
/// Alias of the property editor
/// Collection of objects with a matching control id
- IEnumerable GetByEditorAlias(string propertyEditorAlias);
+ IEnumerable? GetByEditorAlias(string propertyEditorAlias);
Attempt?> Move(IDataType toMove, int parentId);
}
diff --git a/src/Umbraco.Core/Services/IServerRegistrationService.cs b/src/Umbraco.Core/Services/IServerRegistrationService.cs
index d5cfd9f7a7..f9aaf7e33f 100644
--- a/src/Umbraco.Core/Services/IServerRegistrationService.cs
+++ b/src/Umbraco.Core/Services/IServerRegistrationService.cs
@@ -35,7 +35,7 @@ namespace Umbraco.Cms.Core.Services
/// time the current server is touched, and the period depends on the configuration. Use the
/// parameter to force a cache refresh and reload active servers
/// from the database.
- IEnumerable GetActiveServers(bool refresh = false);
+ IEnumerable? GetActiveServers(bool refresh = false);
///
/// Gets the role of the current server.
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs
index 5962638d57..21da2f797a 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs
@@ -33,12 +33,12 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
var result = _databaseBuilder.CreateSchemaAndData();
- if (result.Success == false)
+ if (result?.Success == false)
{
throw new InstallException("The database failed to install. ERROR: " + result.Message);
}
- if (result.RequiresUpgrade == false)
+ if (result?.RequiresUpgrade == false)
{
return Task.FromResult(null);
}
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs
index d50624d0c2..693cd1cbde 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs
@@ -84,7 +84,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
// a connection string was present, determine whether this is an install/upgrade
// return true (upgrade) if there is an installed version, else false (install)
var result = _databaseBuilder.ValidateSchema();
- return result.DetermineHasInstalledVersion();
+ return result?.DetermineHasInstalledVersion() ?? false;
}
//no connection string configured, probably a fresh install
diff --git a/src/Umbraco.Infrastructure/Install/UnattendedUpgrader.cs b/src/Umbraco.Infrastructure/Install/UnattendedUpgrader.cs
index 5f5c8f16a8..312106ecca 100644
--- a/src/Umbraco.Infrastructure/Install/UnattendedUpgrader.cs
+++ b/src/Umbraco.Infrastructure/Install/UnattendedUpgrader.cs
@@ -56,8 +56,8 @@ namespace Umbraco.Cms.Infrastructure.Install
"Starting unattended upgrade.",
"Unattended upgrade completed."))
{
- DatabaseBuilder.Result result = _databaseBuilder.UpgradeSchemaAndData(plan);
- if (result.Success == false)
+ DatabaseBuilder.Result? result = _databaseBuilder.UpgradeSchemaAndData(plan);
+ if (result?.Success == false)
{
var innerException = new UnattendedInstallException("An error occurred while running the unattended upgrade.\n" + result.Message);
_runtimeState.Configure(Core.RuntimeLevel.BootFailed, Core.RuntimeLevelReason.BootFailedOnException, innerException);
diff --git a/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs b/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs
index 249b01f60f..c0436838e0 100644
--- a/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs
+++ b/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs
@@ -107,7 +107,7 @@ namespace Umbraco.Cms.Core.Mapping
var sourceCtors = DefineCtors(sourceType);
if (ctor != null)
- sourceCtors[targetType] = (source, context) => ctor((TSource)source, context);
+ sourceCtors[targetType] = (source, context) => ctor((TSource)source, context)!;
var sourceMaps = DefineMaps(sourceType);
sourceMaps[targetType] = (source, target, context) => map((TSource)source, (TTarget)target, context);
@@ -221,13 +221,14 @@ namespace Umbraco.Cms.Core.Mapping
var ienumerableOfT = typeof(IEnumerable<>);
- bool IsIEnumerableOfT(Type type) =>
+ bool IsIEnumerableOfT(Type? type) =>
+ type is not null &&
type.IsGenericType &&
type.GenericTypeArguments.Length == 1 &&
type.GetGenericTypeDefinition() == ienumerableOfT;
// try to get source as an IEnumerable
- var sourceIEnumerable = IsIEnumerableOfT(sourceType) ? sourceType : sourceType.GetInterfaces().FirstOrDefault(IsIEnumerableOfT);
+ var sourceIEnumerable = IsIEnumerableOfT(sourceType) ? sourceType : sourceType?.GetInterfaces().FirstOrDefault(IsIEnumerableOfT);
// if source is an IEnumerable and target is T[] or IEnumerable, we can create a map
if (sourceIEnumerable != null && IsEnumerableOrArrayOfType(targetType))
@@ -340,8 +341,12 @@ namespace Umbraco.Cms.Core.Mapping
throw new InvalidOperationException($"Don't know how to map {typeof(TSource).FullName} to {typeof(TTarget).FullName}.");
}
- private Func
public class MigrationPlan
{
- private readonly Dictionary _transitions = new Dictionary(StringComparer.InvariantCultureIgnoreCase);
+ private readonly Dictionary _transitions = new Dictionary(StringComparer.InvariantCultureIgnoreCase);
private readonly List _postMigrationTypes = new List();
- private string _prevState;
- private string _finalState;
+ private string? _prevState;
+ private string? _finalState;
///
/// Initializes a new instance of the class.
@@ -46,7 +46,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
///
/// Gets the transitions.
///
- public IReadOnlyDictionary Transitions => _transitions;
+ public IReadOnlyDictionary Transitions => _transitions;
public IReadOnlyList PostMigrationTypes => _postMigrationTypes;
@@ -56,7 +56,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
public string Name { get; }
// adds a transition
- private MigrationPlan Add(string sourceState, string targetState, Type migration)
+ private MigrationPlan Add(string? sourceState, string targetState, Type? migration)
{
if (sourceState == null)
throw new ArgumentNullException(nameof(sourceState), $"{nameof(sourceState)} is null, {nameof(MigrationPlan)}.{nameof(MigrationPlan.From)} must not have been called.");
@@ -118,7 +118,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
///
/// Adds a transition to a target state through a migration.
///
- public MigrationPlan To(string targetState, Type migration)
+ public MigrationPlan To(string targetState, Type? migration)
=> Add(_prevState, targetState, migration);
public MigrationPlan To(Guid targetState, Type migration)
@@ -127,7 +127,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
///
/// Sets the starting state.
///
- public MigrationPlan From(string sourceState)
+ public MigrationPlan From(string? sourceState)
{
_prevState = sourceState ?? throw new ArgumentNullException(nameof(sourceState));
return this;
@@ -192,18 +192,18 @@ namespace Umbraco.Cms.Infrastructure.Migrations
while (state != endState)
{
- if (visited.Contains(state))
+ if (state is null || visited.Contains(state))
throw new InvalidOperationException("A loop was detected in the copied chain.");
visited.Add(state);
if (!_transitions.TryGetValue(state, out var transition))
throw new InvalidOperationException($"There is no transition from state \"{state}\".");
- var newTargetState = transition.TargetState == endState
+ var newTargetState = transition?.TargetState == endState
? targetState
: CreateRandomState();
- To(newTargetState, transition.MigrationType);
- state = transition.TargetState;
+ To(newTargetState, transition?.MigrationType);
+ state = transition?.TargetState;
}
return this;
@@ -255,7 +255,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
if (_finalState == null)
Validate();
- return _finalState;
+ return _finalState!;
}
}
@@ -272,7 +272,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
// that is not null and does not match any source state. such a target state has
// been registered as a source state with a null transition. so there should be only
// one.
- string finalState = null;
+ string? finalState = null;
foreach (var kvp in _transitions.Where(x => x.Value == null))
{
if (finalState == null)
@@ -302,7 +302,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
verified.AddRange(visited);
}
- _finalState = finalState;
+ _finalState = finalState!;
}
///
@@ -317,9 +317,9 @@ namespace Umbraco.Cms.Infrastructure.Migrations
/// Follows a path (for tests and debugging).
///
/// Does the same thing Execute does, but does not actually execute migrations.
- internal IReadOnlyList FollowPath(string fromState = null, string toState = null)
+ internal IReadOnlyList FollowPath(string? fromState = null, string? toState = null)
{
- toState = toState.NullOrWhiteSpaceAsNull();
+ toState = toState?.NullOrWhiteSpaceAsNull();
Validate();
diff --git a/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs b/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
index 358d7d0281..8834c68191 100644
--- a/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
+++ b/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
@@ -52,7 +52,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
_logger.LogInformation("At {OrigState}", string.IsNullOrWhiteSpace(nextState) ? "origin" : nextState);
- if (!plan.Transitions.TryGetValue(nextState, out MigrationPlan.Transition transition))
+ if (!plan.Transitions.TryGetValue(nextState, out MigrationPlan.Transition? transition))
{
plan.ThrowOnUnknownInitialState(nextState);
}
@@ -65,7 +65,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
// that packages notification handlers may explode because that package isn't fully installed yet.
using (scope.Notifications.Suppress())
{
- var context = new MigrationContext(plan, _scopeAccessor.AmbientScope.Database, _loggerFactory.CreateLogger());
+ var context = new MigrationContext(plan, _scopeAccessor.AmbientScope?.Database, _loggerFactory.CreateLogger());
while (transition != null)
{
diff --git a/src/Umbraco.Infrastructure/Migrations/PostMigrations/DeleteLogViewerQueryFile.cs b/src/Umbraco.Infrastructure/Migrations/PostMigrations/DeleteLogViewerQueryFile.cs
index ef4e3de38e..3531959dbb 100644
--- a/src/Umbraco.Infrastructure/Migrations/PostMigrations/DeleteLogViewerQueryFile.cs
+++ b/src/Umbraco.Infrastructure/Migrations/PostMigrations/DeleteLogViewerQueryFile.cs
@@ -1,6 +1,6 @@
using System.IO;
using Umbraco.Cms.Core.Hosting;
-using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_0_0;
+// using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_0_0;
namespace Umbraco.Cms.Infrastructure.Migrations.PostMigrations
{
diff --git a/src/Umbraco.Infrastructure/Models/PathValidationExtensions.cs b/src/Umbraco.Infrastructure/Models/PathValidationExtensions.cs
index 61b14d15ab..e7286d683f 100644
--- a/src/Umbraco.Infrastructure/Models/PathValidationExtensions.cs
+++ b/src/Umbraco.Infrastructure/Models/PathValidationExtensions.cs
@@ -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}");
diff --git a/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs
index 0af21b7eb2..bb9866e116 100644
--- a/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs
+++ b/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
_parser = parser ?? throw new ArgumentNullException(nameof(parser));
}
- public CompiledPackage ReadPackage(XDocument packageXmlFile)
+ public CompiledPackage ReadPackage(XDocument? packageXmlFile)
{
if (packageXmlFile == null)
throw new ArgumentNullException(nameof(packageXmlFile));
@@ -73,7 +73,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
packageDefinition.PartialViews.Add(x.Path);
packageDefinition.ContentNodeId = installationSummary.ContentInstalled.FirstOrDefault()?.Id.ToInvariantString();
-
+
foreach (var x in installationSummary.MediaInstalled)
packageDefinition.MediaUdis.Add(x.GetUdi());
diff --git a/src/Umbraco.Infrastructure/Packaging/PendingPackageMigrations.cs b/src/Umbraco.Infrastructure/Packaging/PendingPackageMigrations.cs
index 2635287db0..efefcfcc7a 100644
--- a/src/Umbraco.Infrastructure/Packaging/PendingPackageMigrations.cs
+++ b/src/Umbraco.Infrastructure/Packaging/PendingPackageMigrations.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Core.Packaging
{
_logger = logger;
_packageMigrationPlans = packageMigrationPlans;
-
+
}
///
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Core.Packaging
/// These are the key/value pairs from the keyvalue storage of migration names and their final values
///
///
- public IReadOnlyList GetPendingPackageMigrations(IReadOnlyDictionary keyValues)
+ public IReadOnlyList GetPendingPackageMigrations(IReadOnlyDictionary? keyValues)
{
var packageMigrationPlans = _packageMigrationPlans.ToList();
@@ -35,9 +35,9 @@ namespace Umbraco.Cms.Core.Packaging
foreach (PackageMigrationPlan plan in packageMigrationPlans)
{
- string currentMigrationState = null;
+ string? currentMigrationState = null;
var planKeyValueKey = Constants.Conventions.Migrations.KeyValuePrefix + plan.Name;
- if (keyValues.TryGetValue(planKeyValueKey, out var value))
+ if (keyValues?.TryGetValue(planKeyValueKey, out var value) ?? false)
{
currentMigrationState = value;
diff --git a/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs b/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
index 1957e17655..f03b60d778 100644
--- a/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
+++ b/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
@@ -40,12 +40,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The containing the input row set's schema information
/// requires to function correctly.
///
- private DataTable _schemaTable = new DataTable();
+ private DataTable? _schemaTable = new DataTable();
///
/// The mapping from the row set input to the target table's columns.
///
- private List _columnMappings = new List();
+ private List? _columnMappings = new List();
#endregion
@@ -61,7 +61,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
{
get
{
- if (this._columnMappings.Count == 0)
+ if (this._columnMappings?.Count == 0)
{
// Need to add the column definitions and mappings.
AddSchemaTableRows();
@@ -71,10 +71,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence
throw new InvalidOperationException("AddSchemaTableRows did not add rows.");
}
- Debug.Assert(this._schemaTable.Rows.Count == FieldCount);
+ Debug.Assert(this._schemaTable?.Rows.Count == FieldCount);
}
- return new ReadOnlyCollection(_columnMappings);
+ return new ReadOnlyCollection(_columnMappings!);
}
}
@@ -213,11 +213,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence
bool isKey,
bool allowDbNull,
SqlDbType providerType,
- string udtSchema,
- string udtType,
- string xmlSchemaCollectionDatabase,
- string xmlSchemaCollectionOwningSchema,
- string xmlSchemaCollectionName)
+ string? udtSchema,
+ string? udtType,
+ string? xmlSchemaCollectionDatabase,
+ string? xmlSchemaCollectionOwningSchema,
+ string? xmlSchemaCollectionName)
{
if (string.IsNullOrEmpty(columnName))
{
@@ -236,7 +236,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
throw new ArgumentOutOfRangeException("columnSize");
}
- List allowedOptionalColumnList;
+ List? allowedOptionalColumnList;
if (BulkDataReader.AllowedOptionalColumnCombinations.TryGetValue(providerType, out allowedOptionalColumnList))
{
@@ -629,7 +629,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
}
- this._schemaTable.Rows.Add(columnName,
+ this._schemaTable?.Rows.Add(columnName,
_schemaTable.Rows.Count,
columnSize,
numericPrecision,
@@ -658,7 +658,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
xmlSchemaCollectionOwningSchema,
xmlSchemaCollectionName);
- this._columnMappings.Add(new SqlBulkCopyColumnMapping(columnName, columnName));
+ this._columnMappings?.Add(new SqlBulkCopyColumnMapping(columnName, columnName));
}
#endregion
@@ -910,8 +910,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence
object data = GetValue(i);
char? dataAsChar = data as char?;
- char[] dataAsCharArray = data as char[];
- string dataAsString = data as string;
+ char[]? dataAsCharArray = data as char[];
+ string? dataAsString = data as string;
if (dataAsChar.HasValue)
{
@@ -1015,7 +1015,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
throw new ArgumentOutOfRangeException("i");
}
- return null;
+ return null!;
}
///
@@ -1306,7 +1306,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
throw new InvalidOperationException("The IDataReader is closed.");
}
- if (_schemaTable.Rows.Count == 0)
+ if (_schemaTable?.Rows.Count == 0)
{
// Need to add the column definitions and mappings
_schemaTable.TableName = TableName;
@@ -1316,7 +1316,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
Debug.Assert(_schemaTable.Rows.Count == FieldCount);
}
- return _schemaTable;
+ return _schemaTable!;
}
///
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexAttribute.cs
index 6d1db2dc5f..053e5b825d 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexAttribute.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexAttribute.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations
/// Overrides default naming of indexes:
/// IX_tableName
///
- public string Name { get; set; }//Overrides default naming of indexes: IX_tableName
+ public string? Name { get; set; }//Overrides default naming of indexes: IX_tableName
///
/// Gets or sets the type of index to create
@@ -30,11 +30,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations
///
/// Gets or sets the column name(s) for the current index
///
- public string ForColumns { get; set; }
+ public string? ForColumns { get; set; }
///
/// Gets or sets the column name(s) for the columns to include in the index
///
- public string IncludeColumns { get; set; }
+ public string? IncludeColumns { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs
index 092a06a57c..4ab479b8fd 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs
@@ -11,8 +11,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseModelDefinitions
Indexes = new List();
}
- public virtual string? Name { get; set; }
- public virtual string? SchemaName { get; set; }
+ public virtual string Name { get; set; } = null!;
+ public virtual string SchemaName { get; set; } = null!;
public virtual ICollection Columns { get; set; }
public virtual ICollection ForeignKeys { get; set; }
public virtual ICollection Indexes { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/DbProviderFactoryCreator.cs b/src/Umbraco.Infrastructure/Persistence/DbProviderFactoryCreator.cs
index e54c1f5fbc..f3f0902456 100644
--- a/src/Umbraco.Infrastructure/Persistence/DbProviderFactoryCreator.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DbProviderFactoryCreator.cs
@@ -29,7 +29,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
_providerSpecificMapperFactories = providerSpecificMapperFactories.ToDictionary(x => x.ProviderName);
}
- public DbProviderFactory CreateFactory(string providerName)
+ public DbProviderFactory? CreateFactory(string? providerName)
{
if (string.IsNullOrEmpty(providerName))
return null;
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs
index cc826bc3c2..ead7948191 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs
@@ -30,14 +30,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("createDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime CreateDate { get; set; }
+ public DateTime? CreateDate { get; set; }
[Column("updateDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime UpdateDate { get; set; }
+ public DateTime? UpdateDate { get; set; }
[ResultColumn]
[Reference(ReferenceType.Many, ReferenceMemberName = "AccessId")]
- public List Rules { get; set; }
+ public List Rules { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
index 307f91337b..a730fe97f6 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
@@ -27,10 +27,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("createDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime CreateDate { get; set; }
+ public DateTime? CreateDate { get; set; }
[Column("updateDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime UpdateDate { get; set; }
+ public DateTime? UpdateDate { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs
index 4d0c8b2e6e..32307efb2b 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs
@@ -28,10 +28,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
// this is convenient to carry the culture around, but has no db counterpart
[Ignore]
- public string Culture { get; set; }
+ public string? Culture { get; set; }
[Column("name")]
- public string Name { get; set; }
+ public string? Name { get; set; }
[Column("date")] // TODO: db rename to 'updateDate'
public DateTime UpdateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs
index 63f2802af6..a000811c55 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs
@@ -44,11 +44,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("text")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Text { get; set; }
+ public string? Text { get; set; }
[ResultColumn]
[Reference(ReferenceType.OneToOne, ColumnName = "NodeId", ReferenceMemberName = "NodeId")]
- public ContentDto ContentDto { get; set; }
+ public ContentDto? ContentDto { get; set; }
[Column("preventCleanup")]
[Constraint(Default = "0")]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentCultureVariationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentCultureVariationDto.cs
index 3a494718b1..e13d19ae34 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentCultureVariationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentCultureVariationDto.cs
@@ -26,7 +26,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
// this is convenient to carry the culture around, but has no db counterpart
[Ignore]
- public string Culture { get; set; }
+ public string? Culture { get; set; }
// authority on whether a culture has been edited
[Column("edited")]
@@ -47,6 +47,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
// (otherwise, it's the published one, 'cos we need to have one)
[Column("name")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Name { get; set; }
+ public string? Name { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs
index 415721811d..b23f9a6c04 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs
@@ -13,14 +13,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("key")]
[Length(256)]
[PrimaryKeyColumn(AutoIncrement = false, Clustered = true)]
- public string Key { get; set; }
+ public string? Key { get; set; }
[Column("value")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Value { get; set; }
+ public string? Value { get; set; }
[Column("updated")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime UpdateDate { get; set; }
+ public DateTime? UpdateDate { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs
index 2174fb6303..3b2009f3da 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs
@@ -33,7 +33,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("entityType")]
[Length(50)]
[NullSetting(NullSetting = NullSettings.Null)]
- public string EntityType { get; set; }
+ public string? EntityType { get; set; }
// TODO: Should we have an index on this since we allow searching on it?
[Column("Datestamp")]
@@ -43,12 +43,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
// TODO: Should we have an index on this since we allow searching on it?
[Column("logHeader")]
[Length(50)]
- public string Header { get; set; }
+ public string Header { get; set; } = null!;
[Column("logComment")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(4000)]
- public string Comment { get; set; }
+ public string? Comment { get; set; }
///
/// Used to store additional data parameters for the log
@@ -56,6 +56,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("parameters")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(500)]
- public string Parameters { get; set; }
+ public string? Parameters { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/LogViewerQueryDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/LogViewerQueryDto.cs
index 71642c8b73..66b4a1902c 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/LogViewerQueryDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/LogViewerQueryDto.cs
@@ -14,9 +14,9 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("name")]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_LogViewerQuery_name")]
- public string Name { get; set; }
+ public string? Name { get; set; }
[Column("query")]
- public string Query { get; set; }
+ public string? Query { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
index 959a6c5f6a..538510c417 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
@@ -19,18 +19,18 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("Email")]
[Length(1000)]
[Constraint(Default = "''")]
- public string Email { get; set; }
+ public string Email { get; set; } = null!;
[Column("LoginName")]
[Length(1000)]
[Constraint(Default = "''")]
[Index(IndexTypes.NonClustered, Name = "IX_cmsMember_LoginName")]
- public string LoginName { get; set; }
+ public string LoginName { get; set; } = null!;
[Column("Password")]
[Length(1000)]
[Constraint(Default = "''")]
- public string Password { get; set; }
+ public string? Password { get; set; }
///
/// This will represent a JSON structure of how the password has been created (i.e hash algorithm, iterations)
@@ -53,10 +53,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[ResultColumn]
[Reference(ReferenceType.OneToOne, ReferenceMemberName = "NodeId")]
- public ContentDto ContentDto { get; set; }
+ public ContentDto ContentDto { get; set; } = null!;
[ResultColumn]
[Reference(ReferenceType.OneToOne, ReferenceMemberName = "NodeId")]
- public ContentVersionDto ContentVersionDto { get; set; }
+ public ContentVersionDto ContentVersionDto { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
index b5b1d42b49..bd41a2a297 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("parentId")]
[ForeignKey(typeof(NodeDto))]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_ParentId")]
- public int? ParentId { get; set; }
+ public int ParentId { get; set; }
// NOTE: This index is primarily for the nucache data lookup, see https://github.com/umbraco/Umbraco-CMS/pull/8365#issuecomment-673404177
[Column("level")]
@@ -37,7 +37,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("path")]
[Length(150)]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_Path")]
- public string Path { get; set; }
+ public string Path { get; set; } = null!;
[Column("sortOrder")]
public int SortOrder { get; set; }
@@ -63,6 +63,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("createDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime CreateDate { get; set; }
+ public DateTime? CreateDate { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs
index 211a52a8a1..435e072307 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("culture")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Culture { get; set; } = null!;
+ public string? Culture { get; set; }
[Column("urlHash")]
[NullSetting(NullSetting = NullSettings.NotNull)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs
index 8929238665..d872801163 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs
@@ -29,11 +29,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("datetime")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime Datetime { get; set; }
+ public DateTime? Datetime { get; set; }
[Column("comment")]
[Length(1000)]
- public string Comment { get; set; }
+ public string? Comment { get; set; }
[ResultColumn]
[Column("parentObjectType")]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
index 89ef0039ab..b50d3ca3d2 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
@@ -25,10 +25,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("registeredDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime DateRegistered { get; set; }
+ public DateTime? DateRegistered { get; set; }
[Column("lastNotifiedDate")]
- public DateTime DateAccessed { get; set; }
+ public DateTime? DateAccessed { get; set; }
[Column("isActive")]
[Index(IndexTypes.NonClustered)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/TwoFactorLoginDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/TwoFactorLoginDto.cs
index 1202fe2a19..09f6647bfe 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/TwoFactorLoginDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/TwoFactorLoginDto.cs
@@ -22,12 +22,13 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("providerName")]
[Length(400)]
[NullSetting(NullSetting = NullSettings.NotNull)]
- [Index(IndexTypes.UniqueNonClustered, ForColumns = "providerName,userOrMemberKey", Name = "IX_" + TableName + "_ProviderName")]
- public string ProviderName { get; set; }
+ [Index(IndexTypes.UniqueNonClustered, ForColumns = "providerName,userOrMemberKey",
+ Name = "IX_" + TableName + "_ProviderName")]
+ public string ProviderName { get; set; } = null!;
[Column("secret")]
[Length(400)]
[NullSetting(NullSetting = NullSettings.NotNull)]
- public string Secret { get; set; }
+ public string Secret { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
index 3c313794e0..d3e687aee5 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
public bool NoConsole { get; set; }
[Column("userName")]
- public string? UserName { get; set; }
+ public string UserName { get; set; } = null!;
[Column("userLogin")]
[Length(125)]
@@ -93,12 +93,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("createDate")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime CreateDate { get; set; }
+ public DateTime CreateDate { get; set; } = DateTime.Now;
[Column("updateDate")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
- public DateTime UpdateDate { get; set; }
+ public DateTime UpdateDate { get; set; } = DateTime.Now;
///
/// Will hold the media file system relative path of the users custom avatar if they uploaded one
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
index fb3e866272..ea2c01ea92 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
///
/// Builds an IContent item from a dto and content type.
///
- public static Content BuildEntity(DocumentDto dto, IContentType contentType)
+ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
{
var contentDto = dto.ContentDto;
var nodeDto = contentDto.NodeDto;
@@ -72,7 +72,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
///
/// Builds an IMedia item from a dto and content type.
///
- public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType contentType)
+ public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType? contentType)
{
var nodeDto = dto.NodeDto;
var contentVersionDto = dto.ContentVersionDto;
@@ -113,7 +113,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
///
/// Builds an IMedia item from a dto and content type.
///
- public static Member BuildEntity(MemberDto dto, IMemberType contentType)
+ public static Member BuildEntity(MemberDto dto, IMemberType? contentType)
{
var nodeDto = dto.ContentDto.NodeDto;
var contentVersionDto = dto.ContentVersionDto;
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs
index f0f3249318..1b8708c640 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs
@@ -11,11 +11,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
{
internal static class PropertyFactory
{
- public static IEnumerable BuildEntities(IPropertyType[] propertyTypes, IReadOnlyCollection dtos, int publishedVersionId, ILanguageRepository languageRepository)
+ public static IEnumerable BuildEntities(IPropertyType[]? propertyTypes, IReadOnlyCollection dtos, int publishedVersionId, ILanguageRepository languageRepository)
{
var properties = new List();
var xdtos = dtos.GroupBy(x => x.PropertyTypeId).ToDictionary(x => x.Key, x => (IEnumerable)x);
+ if (propertyTypes is null)
+ {
+ return properties;
+ }
foreach (var propertyType in propertyTypes)
{
var values = new List();
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/RelationFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/RelationFactory.cs
index 63d3292160..dbe0c0af78 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/RelationFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/RelationFactory.cs
@@ -5,7 +5,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
{
internal static class RelationFactory
{
- public static IRelation BuildEntity(RelationDto dto, IRelationType relationType)
+ public static IRelation BuildEntity(RelationDto dto, IRelationType? relationType)
{
var entity = new Relation(dto.ParentId, dto.ChildId, dto.ParentObjectType, dto.ChildObjectType, relationType);
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs
index b50d013198..ba129257c7 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
#region Implementation of IEntityFactory
- public static Template BuildEntity(IShortStringHelper shortStringHelper, TemplateDto dto, IEnumerable childDefinitions, Func getFileContent)
+ public static Template BuildEntity(IShortStringHelper shortStringHelper, TemplateDto dto, IEnumerable childDefinitions, Func getFileContent)
{
var template = new Template(shortStringHelper, dto.NodeDto.Text, dto.Alias, getFileContent);
@@ -29,7 +29,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
template.IsMasterTemplate = childDefinitions.Any(x => x.ParentId == dto.NodeId);
if (dto.NodeDto.ParentId > 0)
- template.MasterTemplateId = new Lazy(() => dto.NodeDto.ParentId.Value);
+ template.MasterTemplateId = new Lazy(() => dto.NodeDto.ParentId);
// reset dirty initial properties (U4-1946)
template.ResetDirtyProperties(false);
@@ -73,7 +73,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
NodeId = entity.Id,
Level = 1,
NodeObjectType = nodeObjectTypeId,
- ParentId = entity.MasterTemplateId?.Value,
+ ParentId = entity.MasterTemplateId?.Value ?? 0,
Path = entity.Path,
Text = entity.Name,
Trashed = false,
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryDbConnection.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryDbConnection.cs
index cfd078b81c..bd03c44c7a 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryDbConnection.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryDbConnection.cs
@@ -1,6 +1,7 @@
using System;
using System.Data;
using System.Data.Common;
+using System.Diagnostics.CodeAnalysis;
using Transaction = System.Transactions.Transaction;
namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
@@ -9,9 +10,9 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
{
private DbConnection _inner;
private readonly RetryPolicy _conRetryPolicy;
- private readonly RetryPolicy _cmdRetryPolicy;
+ private readonly RetryPolicy? _cmdRetryPolicy;
- public RetryDbConnection(DbConnection connection, RetryPolicy conRetryPolicy, RetryPolicy cmdRetryPolicy)
+ public RetryDbConnection(DbConnection connection, RetryPolicy? conRetryPolicy, RetryPolicy? cmdRetryPolicy)
{
_inner = connection;
_inner.StateChange += StateChangeHandler;
@@ -22,6 +23,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
public DbConnection Inner { get { return _inner; } }
+ [AllowNull]
public override string ConnectionString { get { return _inner.ConnectionString; } set { _inner.ConnectionString = value; } }
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
@@ -71,11 +73,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
_inner.StateChange -= StateChangeHandler;
_inner.Dispose();
}
- _inner = null;
base.Dispose(disposing);
}
- public override void EnlistTransaction(Transaction transaction)
+ public override void EnlistTransaction(Transaction? transaction)
{
_inner.EnlistTransaction(transaction);
}
@@ -90,7 +91,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
return _inner.GetSchema(collectionName);
}
- public override DataTable GetSchema(string collectionName, string[] restrictionValues)
+ public override DataTable GetSchema(string collectionName, string?[] restrictionValues)
{
return _inner.GetSchema(collectionName, restrictionValues);
}
@@ -130,7 +131,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
private DbCommand _inner;
private readonly RetryPolicy _cmdRetryPolicy;
- public FaultHandlingDbCommand(RetryDbConnection connection, DbCommand command, RetryPolicy cmdRetryPolicy)
+ public FaultHandlingDbCommand(RetryDbConnection connection, DbCommand command, RetryPolicy? cmdRetryPolicy)
{
_connection = connection;
_inner = command;
@@ -142,8 +143,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
protected override void Dispose(bool disposing)
{
if (disposing)
- _inner?.Dispose();
- _inner = null;
+ _inner.Dispose();
+ _inner = null!;
base.Dispose(disposing);
}
@@ -152,6 +153,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
_inner.Cancel();
}
+ [AllowNull]
public override string CommandText
{
get => _inner.CommandText;
@@ -170,6 +172,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
set => _inner.CommandType = value;
}
+ [AllowNull]
protected override DbConnection DbConnection
{
get => _connection;
@@ -190,7 +193,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
protected override DbParameterCollection DbParameterCollection => _inner.Parameters;
- protected override DbTransaction DbTransaction
+ protected override DbTransaction? DbTransaction
{
get => _inner.Transaction;
set => _inner.Transaction = value;
@@ -208,7 +211,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
return Execute(() => _inner.ExecuteNonQuery());
}
- public override object ExecuteScalar()
+ public override object? ExecuteScalar()
{
return Execute(() => _inner.ExecuteScalar());
}
@@ -219,7 +222,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
{
_connection.Ensure();
return f();
- });
+ })!;
}
public override void Prepare()
diff --git a/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs b/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs
index 2de1bcef16..52daf7e351 100644
--- a/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs
+++ b/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
public interface IDbProviderFactoryCreator
{
- DbProviderFactory CreateFactory(string? providerName);
+ DbProviderFactory? CreateFactory(string? providerName);
ISqlSyntaxProvider GetSqlSyntaxProvider(string providerName);
IBulkSqlInsertProvider CreateBulkSqlInsertProvider(string providerName);
void CreateDatabase(string providerName, string connectionString);
diff --git a/src/Umbraco.Infrastructure/Persistence/ISqlContext.cs b/src/Umbraco.Infrastructure/Persistence/ISqlContext.cs
index 8a6bfb8420..9178ba8ae7 100644
--- a/src/Umbraco.Infrastructure/Persistence/ISqlContext.cs
+++ b/src/Umbraco.Infrastructure/Persistence/ISqlContext.cs
@@ -48,6 +48,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
/// Gets the mappers.
///
- IMapperCollection Mappers { get; }
+ IMapperCollection? Mappers { get; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/IUmbracoDatabaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/IUmbracoDatabaseFactory.cs
index a86deb8802..10af5a7421 100644
--- a/src/Umbraco.Infrastructure/Persistence/IUmbracoDatabaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/IUmbracoDatabaseFactory.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The new database must be disposed after being used.
/// Creating a database causes the factory to initialize if it is not already initialized.
///
- IUmbracoDatabase CreateDatabase();
+ IUmbracoDatabase? CreateDatabase();
///
/// Gets a value indicating whether the database factory is configured, i.e. whether
@@ -33,13 +33,13 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// Gets the connection string.
///
/// May return null if the database factory is not configured.
- string ConnectionString { get; }
+ string? ConnectionString { get; }
///
/// Gets the provider name.
///
/// May return null if the database factory is not configured.
- string ProviderName { get; }
+ string? ProviderName { get; }
///
/// Gets a value indicating whether the database factory is configured (see ),
@@ -59,7 +59,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
/// Getting the causes the factory to initialize if it is not already initialized.
///
- ISqlContext SqlContext { get; }
+ ISqlContext? SqlContext { get; }
///
/// Gets the .
@@ -67,7 +67,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
/// Getting the causes the factory to initialize if it is not already initialized.
///
- IBulkSqlInsertProvider BulkSqlInsertProvider { get; }
+ IBulkSqlInsertProvider? BulkSqlInsertProvider { get; }
///
/// Configures the database factory for upgrades.
diff --git a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs
index fe616b56f6..709940f3cc 100644
--- a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs
+++ b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
{
private int _version;
private bool _hasVersion;
- private string _exe;
+ private string? _exe;
#region Availability & Version
@@ -123,7 +123,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
/// The name of existing LocalDb instances.
/// Thrown when LocalDb is not available.
- public string[] GetInstances()
+ public string[]? GetInstances()
{
EnsureAvailable();
var rc = ExecuteSqlLocalDb("i", out var output, out var error); // info
@@ -218,7 +218,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The name of the instance.
/// The instance with the specified name if it exists, otherwise null.
/// Thrown when LocalDb is not available.
- public Instance GetInstance(string instanceName)
+ public Instance? GetInstance(string instanceName)
{
EnsureAvailable();
return InstanceExists(instanceName) ? new Instance(instanceName) : null;
@@ -500,7 +500,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The name of the database.
/// The directory containing the database files.
/// Thrown when a database with the specified name does not exist.
- public string DetachDatabase(string databaseName)
+ public string? DetachDatabase(string databaseName)
{
using (var conn = new SqlConnection(_masterCstr))
using (var cmd = conn.CreateCommand())
@@ -547,8 +547,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The MDF filename.
/// The LDF filename.
public void GetFilenames(string databaseName,
- out string mdfName, out string ldfName,
- out string mdfFilename, out string ldfFilename)
+ out string? mdfName, out string? ldfName,
+ out string? mdfFilename, out string? ldfFilename)
{
using (var conn = new SqlConnection(_masterCstr))
using (var cmd = conn.CreateCommand())
@@ -587,13 +587,13 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The Sql Command.
/// The name of the database.
/// The full filename of the MDF file, if the database exists, otherwise null.
- private static string GetDatabase(SqlCommand cmd, string databaseName)
+ private static string? GetDatabase(SqlCommand cmd, string databaseName)
{
SetCommand(cmd, @"
SELECT name, filename FROM master.dbo.sysdatabases WHERE ('[' + name + ']' = @0 OR name = @0)",
databaseName);
- string mdf = null;
+ string? mdf = null;
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
@@ -613,7 +613,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The name of the database.
/// The name of the database (MDF) file.
/// The name of the log (LDF) file.
- private static void ExecuteDropDatabase(SqlCommand cmd, string databaseName, string mdf, string ldf = null)
+ private static void ExecuteDropDatabase(SqlCommand cmd, string databaseName, string mdf, string? ldf = null)
{
try
{
@@ -736,8 +736,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// The MDF filename.
/// The LDF filename.
private void GetFilenames(SqlCommand cmd, string databaseName,
- out string mdfName, out string ldfName,
- out string mdfFilename, out string ldfFilename)
+ out string? mdfName, out string? ldfName,
+ out string? mdfFilename, out string? ldfFilename)
{
mdfName = ldfName = mdfFilename = ldfFilename = null;
@@ -786,8 +786,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence
/// Extensions are used eg to copy MyDatabase.mdf to MyDatabase.mdf.temp.
///
public void CopyDatabaseFiles(string databaseName, string filesPath,
- string targetDatabaseName = null, string targetFilesPath = null,
- string sourceExtension = null, string targetExtension = null,
+ string? targetDatabaseName = null, string? targetFilesPath = null,
+ string? sourceExtension = null, string? targetExtension = null,
bool overwrite = false, bool delete = false)
{
var nop = (targetFilesPath == null || targetFilesPath == filesPath)
@@ -847,7 +847,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
/// Extensions are used eg to copy MyDatabase.mdf to MyDatabase.mdf.temp.
///
- public bool DatabaseFilesExist(string databaseName, string filesPath, string extension = null)
+ public bool DatabaseFilesExist(string databaseName, string filesPath, string? extension = null)
{
GetDatabaseFiles(databaseName, filesPath,
out _, out _, out _, out var mdfFilename, out var ldfFilename);
diff --git a/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
index bc0deb56f1..f046ee9548 100644
--- a/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Mappers
protected abstract void DefineMaps();
- internal string Map(string propertyName)
+ internal string Map(string? propertyName)
{
lock (_definedLock)
{
@@ -47,7 +47,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Mappers
if (!_maps.TryGetValue(GetType(), out var mapperMaps))
throw new InvalidOperationException($"No maps defined for mapper {GetType().FullName}.");
- if (!mapperMaps.TryGetValue(propertyName, out var mappedName))
+ if (propertyName is null || !mapperMaps.TryGetValue(propertyName, out var mappedName))
throw new InvalidOperationException($"No map defined by mapper {GetType().FullName} for property {propertyName}.");
return mappedName;
}
diff --git a/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
index 0159245bfd..7537ffc48f 100644
--- a/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Extensions
/// NPoco's normal Page returns a List{T} but sometimes we don't want all that in memory and instead want to
/// iterate over each row with a reader using Query vs Fetch.
///
- public static IEnumerable QueryPaged(this IDatabase database, long pageSize, Sql sql, Sql sqlCount)
+ public static IEnumerable QueryPaged(this IDatabase database, long pageSize, Sql sql, Sql? sqlCount)
{
var sqlString = sql.SQL;
var sqlArgs = sql.Arguments;
@@ -131,8 +131,8 @@ namespace Umbraco.Extensions
///
public static RecordPersistenceType InsertOrUpdate(this IUmbracoDatabase db,
T poco,
- string updateCommand,
- object updateArgs)
+ string? updateCommand,
+ object? updateArgs)
where T : class
{
if (poco == null)
@@ -142,9 +142,9 @@ namespace Umbraco.Extensions
// in any case, no point trying to update if there's no primary key!
// try to update
- var rowCount = updateCommand.IsNullOrWhiteSpace()
+ var rowCount = updateCommand.IsNullOrWhiteSpace() || updateArgs is null
? db.Update(poco)
- : db.Update(updateCommand, updateArgs);
+ : db.Update(updateCommand!, updateArgs);
if (rowCount > 0)
return RecordPersistenceType.Update;
@@ -166,9 +166,9 @@ namespace Umbraco.Extensions
// RC2 race cond here: another thread may remove the record
// try to update
- rowCount = updateCommand.IsNullOrWhiteSpace()
+ rowCount = updateCommand.IsNullOrWhiteSpace() || updateArgs is null
? db.Update(poco)
- : db.Update(updateCommand, updateArgs);
+ : db.Update(updateCommand!, updateArgs);
if (rowCount > 0)
return RecordPersistenceType.Update;
@@ -229,7 +229,7 @@ namespace Umbraco.Extensions
///
///
///
- public static TTransaction GetTypedTransaction(IDbTransaction transaction)
+ public static TTransaction GetTypedTransaction(IDbTransaction? transaction)
where TTransaction : class, IDbTransaction
{
var t = transaction;
@@ -243,7 +243,7 @@ namespace Umbraco.Extensions
t = profiled.WrappedTransaction;
break;
default:
- throw new NotSupportedException(transaction.GetType().FullName);
+ throw new NotSupportedException(transaction?.GetType().FullName);
}
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs b/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
index 72b3f2cf5f..7c4498292b 100644
--- a/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
@@ -55,7 +55,7 @@ namespace Umbraco.Extensions
/// An expression specifying the field.
/// The values.
/// The Sql statement.
- public static Sql WhereIn(this Sql sql, Expression> field, IEnumerable values)
+ public static Sql WhereIn(this Sql sql, Expression> field, IEnumerable? values)
{
var fieldName = sql.SqlContext.SqlSyntax.GetFieldName(field);
sql.Where(fieldName + " IN (@values)", new { values });
@@ -70,7 +70,7 @@ namespace Umbraco.Extensions
/// An expression specifying the field.
/// A subquery returning the value.
/// The Sql statement.
- public static Sql WhereIn(this Sql sql, Expression> field, Sql values)
+ public static Sql WhereIn(this Sql sql, Expression> field, Sql? values)
{
return sql.WhereIn(field, values, false);
}
@@ -83,7 +83,7 @@ namespace Umbraco.Extensions
/// An expression specifying the field.
/// The values.
/// The Sql statement.
- public static Sql WhereNotIn(this Sql sql, Expression> field, IEnumerable values)
+ public static Sql WhereNotIn(this Sql sql, Expression> field, IEnumerable values)
{
var fieldName = sql.SqlContext.SqlSyntax.GetFieldName(field);
sql.Where(fieldName + " NOT IN (@values)", new { values });
@@ -98,7 +98,7 @@ namespace Umbraco.Extensions
/// An expression specifying the field.
/// A subquery returning the value.
/// The Sql statement.
- public static Sql WhereNotIn(this Sql sql, Expression> field, Sql values)
+ public static Sql WhereNotIn(this Sql sql, Expression> field, Sql values)
{
return sql.WhereIn(field, values, true);
}
@@ -111,7 +111,7 @@ namespace Umbraco.Extensions
/// Expressions specifying the fields.
/// The values.
/// The Sql statement.
- public static Sql WhereAnyIn(this Sql sql, Expression>[] fields, IEnumerable values)
+ public static Sql WhereAnyIn(this Sql sql, Expression>[] fields, IEnumerable values)
{
var sqlSyntax = sql.SqlContext.SqlSyntax;
var fieldNames = fields.Select(x => sqlSyntax.GetFieldName(x)).ToArray();
@@ -128,10 +128,10 @@ namespace Umbraco.Extensions
return sql;
}
- private static Sql WhereIn(this Sql sql, Expression> fieldSelector, Sql valuesSql, bool not)
+ private static Sql WhereIn(this Sql sql, Expression> fieldSelector, Sql? valuesSql, bool not)
{
var fieldName = sql.SqlContext.SqlSyntax.GetFieldName(fieldSelector);
- sql.Where(fieldName + (not ? " NOT" : "") +" IN (" + valuesSql.SQL + ")", valuesSql.Arguments);
+ sql.Where(fieldName + (not ? " NOT" : "") +" IN (" + valuesSql?.SQL + ")", valuesSql?.Arguments);
return sql;
}
@@ -167,7 +167,7 @@ namespace Umbraco.Extensions
/// Expression specifying the field.
/// An optional alias for the table.
/// The Sql statement.
- public static Sql WhereNotNull(this Sql sql, Expression> field, string? tableAlias = null)
+ public static Sql WhereNotNull(this Sql sql, Expression> field, string? tableAlias = null)
{
return sql.WhereNull(field, tableAlias, true);
}
@@ -181,7 +181,7 @@ namespace Umbraco.Extensions
/// An optional alias for the table.
/// A value indicating whether to NOT NULL.
/// The Sql statement.
- public static Sql WhereNull(this Sql sql, Expression> field, string? tableAlias = null, bool not = false)
+ public static Sql WhereNull(this Sql sql, Expression> field, string? tableAlias = null, bool not = false)
{
var column = sql.GetColumns(columnExpressions: new[] { field }, tableAlias: tableAlias, withAlias: false).First();
return sql.Where("(" + column + " IS " + (not ? "NOT " : "") + "NULL)");
@@ -222,7 +222,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// An expression specifying the field.
/// The Sql statement.
- public static Sql OrderBy(this Sql sql, Expression> field)
+ public static Sql OrderBy(this Sql sql, Expression> field)
{
return sql.OrderBy("(" + sql.SqlContext.SqlSyntax.GetFieldName(field) + ")");
}
@@ -234,7 +234,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// Expression specifying the fields.
/// The Sql statement.
- public static Sql OrderBy(this Sql sql, params Expression>[] fields)
+ public static Sql OrderBy(this Sql sql, params Expression>[] fields)
{
var sqlSyntax = sql.SqlContext.SqlSyntax;
var columns = fields.Length == 0
@@ -250,7 +250,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// An expression specifying the field.
/// The Sql statement.
- public static Sql OrderByDescending(this Sql sql, Expression> field)
+ public static Sql OrderByDescending(this Sql sql, Expression> field)
{
return sql.OrderBy("(" + sql.SqlContext.SqlSyntax.GetFieldName(field) + ") DESC");
}
@@ -262,7 +262,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// Expression specifying the fields.
/// The Sql statement.
- public static Sql OrderByDescending(this Sql sql, params Expression>[] fields)
+ public static Sql OrderByDescending(this Sql sql, params Expression>[] fields)
{
var sqlSyntax = sql.SqlContext.SqlSyntax;
var columns = fields.Length == 0
@@ -277,7 +277,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// Fields.
/// The Sql statement.
- public static Sql OrderByDescending(this Sql sql, params string[] fields)
+ public static Sql OrderByDescending(this Sql sql, params string?[] fields)
{
return sql.Append("ORDER BY " + string.Join(", ", fields.Select(x => x + " DESC")));
}
@@ -289,7 +289,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// An expression specifying the field.
/// The Sql statement.
- public static Sql GroupBy(this Sql sql, Expression> field)
+ public static Sql GroupBy(this Sql sql, Expression> field)
{
return sql.GroupBy(sql.SqlContext.SqlSyntax.GetFieldName(field));
}
@@ -301,7 +301,7 @@ namespace Umbraco.Extensions
/// The Sql statement.
/// Expression specifying the fields.
/// The Sql statement.
- public static Sql GroupBy(this Sql sql, params Expression>[] fields)
+ public static Sql GroupBy(this Sql sql, params Expression>[] fields)
{
var sqlSyntax = sql.SqlContext.SqlSyntax;
var columns = fields.Length == 0
@@ -317,7 +317,7 @@ namespace Umbraco.Extensions
///