From b442a60403194f04905c090bbaca9cdac56fdbe2 Mon Sep 17 00:00:00 2001
From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Date: Fri, 18 Feb 2022 14:32:51 +0100
Subject: [PATCH] Start work on nullable-reference types in Infrastructure
project
---
.../Cache/IRepositoryCachePolicy.cs | 2 +-
.../Configuration/IConfigManipulator.cs | 2 +-
.../Configuration/IUmbracoVersion.cs | 4 +-
.../Configuration/UmbracoVersion.cs | 4 +-
.../Extensions/EnumerableExtensions.cs | 2 +-
.../PublishedSnapshotAccessorExtensions.cs | 4 +-
.../Install/Models/DatabaseModel.cs | 8 +--
src/Umbraco.Core/Install/Models/UserModel.cs | 4 +-
src/Umbraco.Core/Manifest/IManifestParser.cs | 2 +-
src/Umbraco.Core/Manifest/PackageManifest.cs | 4 +-
src/Umbraco.Core/Mapping/IUmbracoMapper.cs | 12 ++---
src/Umbraco.Core/Media/IImageUrlGenerator.cs | 2 +-
src/Umbraco.Core/Models/Content.cs | 4 +-
src/Umbraco.Core/Models/ContentBase.cs | 4 +-
src/Umbraco.Core/Models/DataType.cs | 2 +-
.../Models/Email/NotificationEmailModel.cs | 16 +++---
.../Models/Entities/ITreeEntity.cs | 2 +-
.../Models/IDictionaryTranslation.cs | 2 +-
src/Umbraco.Core/Models/IMacro.cs | 2 +-
.../Models/IPropertyCollection.cs | 3 +-
src/Umbraco.Core/Models/IPropertyType.cs | 2 +-
src/Umbraco.Core/Models/Macro.cs | 2 +-
src/Umbraco.Core/Models/MacroProperty.cs | 2 +-
src/Umbraco.Core/Models/Member.cs | 2 +-
.../Models/Membership/IMembershipUser.cs | 2 +-
.../Models/Membership/ReadOnlyUserGroup.cs | 4 +-
src/Umbraco.Core/Models/Membership/User.cs | 8 +--
.../Models/Membership/UserGroup.cs | 4 +-
.../Models/Packaging/CompiledPackage.cs | 30 +++++------
.../Packaging/CompiledPackageContentBase.cs | 2 +-
src/Umbraco.Core/Models/Property.cs | 6 +--
src/Umbraco.Core/Models/PropertyType.cs | 7 +--
.../IPublishedPropertyType.cs | 2 +-
.../Models/PublishedContent/ModelType.cs | 6 +--
src/Umbraco.Core/Models/ServerRegistration.cs | 2 +-
src/Umbraco.Core/Models/Tag.cs | 2 +-
.../Packaging/PackageDefinition.cs | 2 +-
.../PropertyEditors/ConfigurationEditor.cs | 2 +-
.../PropertyEditors/DataEditor.cs | 4 +-
.../PropertyEditors/DataValueEditor.cs | 12 ++---
.../IPropertyIndexValueFactory.cs | 2 +-
.../MediaPicker3Configuration.cs | 2 +-
.../PublishedCache/IPublishedSnapshot.cs | 2 +-
src/Umbraco.Core/Routing/WebPath.cs | 2 +-
src/Umbraco.Core/Services/IAuditService.cs | 2 +-
.../Services/IPackagingService.cs | 2 +-
.../Cache/DefaultRepositoryCachePolicy.cs | 17 ++++---
.../Cache/FullDataSetRepositoryCachePolicy.cs | 14 +++---
.../Cache/RepositoryCachePolicyBase.cs | 6 +--
.../Configuration/JsonConfigManipulator.cs | 44 ++++++++++------
.../Events/MigrationEventArgs.cs | 17 ++++---
.../Examine/BaseValueSetBuilder.cs | 14 +++---
.../Examine/ContentIndexPopulator.cs | 2 +-
.../Examine/ContentValueSetBuilder.cs | 6 +--
.../Examine/ContentValueSetValidator.cs | 18 +++----
.../Examine/ExamineExtensions.cs | 2 +-
.../Examine/ExamineUmbracoIndexingHandler.cs | 8 +--
.../Examine/GenericIndexDiagnostics.cs | 4 +-
.../Examine/IBackOfficeExamineSearcher.cs | 2 +-
.../Examine/IIndexDiagnostics.cs | 2 +-
.../Examine/MediaValueSetBuilder.cs | 4 +-
.../Examine/MemberValueSetBuilder.cs | 2 +-
.../Examine/NoopBackOfficeExamineSearcher.cs | 2 +-
.../Examine/ValueSetValidator.cs | 18 +++----
.../Extensions/EmailMessageExtensions.cs | 17 ++++---
.../Extensions/ObjectJsonExtensions.cs | 2 +-
.../HostedServices/BackgroundTaskQueue.cs | 4 +-
.../HostedServices/ContentVersionCleanup.cs | 2 +-
.../HostedServices/HealthCheckNotifier.cs | 2 +-
.../HostedServices/IBackgroundTaskQueue.cs | 2 +-
.../HostedServices/KeepAlive.cs | 4 +-
.../HostedServices/LogScrubber.cs | 2 +-
.../HostedServices/QueuedHostedService.cs | 7 ++-
.../RecurringHostedServiceBase.cs | 6 +--
.../HostedServices/ReportSiteTask.cs | 6 +--
.../HostedServices/ScheduledPublishing.cs | 2 +-
.../InstructionProcessTask.cs | 2 +-
.../ServerRegistration/TouchServerTask.cs | 4 +-
.../HostedServices/TempFileCleanup.cs | 4 +-
.../IPublishedContentQuery.cs | 2 +-
.../Install/FilePermissionHelper.cs | 12 ++---
.../InstallSteps/CompleteInstallStep.cs | 2 +-
.../InstallSteps/DatabaseConfigureStep.cs | 8 +--
.../InstallSteps/DatabaseInstallStep.cs | 6 +--
.../InstallSteps/DatabaseUpgradeStep.cs | 4 +-
.../Install/InstallSteps/NewInstallStep.cs | 8 +--
.../Install/PackageMigrationRunner.cs | 4 +-
.../Install/UnattendedInstaller.cs | 2 +-
.../Enrichers/ThreadAbortExceptionEnricher.cs | 4 +-
.../Logging/Serilog/LoggerConfigExtensions.cs | 6 +--
.../Logging/Viewer/ExpressionFilter.cs | 8 +--
.../Logging/Viewer/ILogLevelLoader.cs | 4 +-
.../Logging/Viewer/ILogViewer.cs | 4 +-
.../Logging/Viewer/LogLevelLoader.cs | 10 ++--
.../Logging/Viewer/LogMessage.cs | 2 +-
.../Logging/Viewer/SavedLogSearch.cs | 4 +-
.../Logging/Viewer/SerilogJsonLogViewer.cs | 2 +-
.../Viewer/SerilogLogViewerSourceBase.cs | 6 +--
.../Mail/EmailSender.cs | 14 +++---
.../Manifest/DataEditorConverter.cs | 14 +++---
.../Manifest/ManifestParser.cs | 16 +++---
.../Manifest/ValueValidatorConverter.cs | 2 +-
.../Mapping/UmbracoMapper.cs | 16 +++---
.../Media/ImageSharpDimensionExtractor.cs | 2 +-
.../Media/ImageSharpImageUrlGenerator.cs | 2 +-
.../Migrations/Install/DatabaseBuilder.cs | 2 +-
.../Models/Blocks/BlockEditorData.cs | 3 +-
.../Models/Blocks/BlockEditorDataConverter.cs | 11 ++--
.../Models/Blocks/BlockItemData.cs | 6 +--
.../Blocks/BlockListEditorDataConverter.cs | 4 +-
.../Models/Mapping/EntityMapDefinition.cs | 11 ++--
.../ModelsBuilder/ApiVersion.cs | 2 +-
.../ModelsBuilder/Building/Builder.cs | 4 +-
.../ModelsBuilder/Building/PropertyModel.cs | 14 +++---
.../ModelsBuilder/Building/TextBuilder.cs | 6 +--
.../ModelsBuilder/Building/TypeModel.cs | 10 ++--
.../ModelsBuilder/ModelsGenerationError.cs | 4 +-
.../PublishedElementExtensions.cs | 4 +-
.../ModelsBuilder/PublishedModelUtility.cs | 2 +-
.../ModelsBuilder/TypeExtensions.cs | 2 +-
.../ImportPackageBuilderExpression.cs | 18 +++----
.../Packaging/PackageDataInstallation.cs | 2 +-
.../Persistence/BulkDataReader.cs | 8 +--
.../ForeignKeyAttribute.cs | 4 +-
.../PrimaryKeyColumnAttribute.cs | 4 +-
.../DatabaseAnnotations/SpecialDbType.cs | 2 +-
.../ColumnDefinition.cs | 2 +-
.../ConstraintDefinition.cs | 6 +--
.../DefinitionFactory.cs | 6 +--
.../ForeignKeyDefinition.cs | 10 ++--
.../TableDefinition.cs | 4 +-
.../Persistence/DbConnectionExtensions.cs | 2 +-
.../Persistence/Dtos/AccessRuleDto.cs | 4 +-
.../Persistence/Dtos/AuditEntryDto.cs | 10 ++--
.../Persistence/Dtos/ConsentDto.cs | 8 +--
.../Persistence/Dtos/ContentTypeDto.cs | 12 ++---
.../Persistence/Dtos/DataTypeDto.cs | 2 +-
.../Persistence/Dtos/ExternalLoginDto.cs | 6 +--
.../Persistence/Dtos/MacroDto.cs | 8 +--
.../Persistence/Dtos/MacroPropertyDto.cs | 6 +--
.../Persistence/Dtos/MediaVersionDto.cs | 2 +-
.../Persistence/Dtos/MemberDto.cs | 4 +-
.../Persistence/Dtos/NodeDto.cs | 6 +--
.../Persistence/Dtos/PropertyDataDto.cs | 12 ++---
.../Persistence/Dtos/PropertyTypeDto.cs | 16 +++---
.../Persistence/Dtos/PropertyTypeGroupDto.cs | 4 +-
.../Persistence/Dtos/RedirectUrlDto.cs | 6 +--
.../Persistence/Dtos/ServerRegistrationDto.cs | 4 +-
.../Persistence/Dtos/TagDto.cs | 4 +-
.../Persistence/Dtos/UserDto.cs | 18 +++----
.../Persistence/Dtos/UserGroupDto.cs | 8 +--
.../Persistence/Dtos/UserStartNodeDto.cs | 4 +-
.../Factories/ContentBaseFactory.cs | 4 +-
.../Factories/ContentTypeFactory.cs | 2 +-
.../Factories/DictionaryItemFactory.cs | 24 +++++----
.../Persistence/Factories/PropertyFactory.cs | 20 ++++----
.../Factories/PropertyGroupFactory.cs | 10 ++--
.../Factories/RelationTypeFactory.cs | 2 +-
.../Persistence/Factories/TemplateFactory.cs | 4 +-
.../Persistence/Factories/UserFactory.cs | 30 ++++++-----
.../Persistence/Factories/UserGroupFactory.cs | 2 +-
.../Persistence/FaultHandling/RetryPolicy.cs | 6 +--
.../FaultHandling/RetryStrategy.cs | 4 +-
.../Strategies/ExponentialBackoff.cs | 2 +-
.../FaultHandling/Strategies/FixedInterval.cs | 2 +-
.../FaultHandling/Strategies/Incremental.cs | 4 +-
...tworkConnectivityErrorDetectionStrategy.cs | 2 +-
...SqlAzureTransientErrorDetectionStrategy.cs | 2 +-
.../Persistence/IDbProviderFactoryCreator.cs | 2 +-
.../Persistence/Mappers/BaseMapper.cs | 2 +-
.../Persistence/Mappers/IMapperCollection.cs | 3 +-
.../Persistence/Mappers/MapperCollection.cs | 3 +-
.../Persistence/Mappers/NullableDateMapper.cs | 2 +-
.../Persistence/NPocoSqlExtensions.cs | 50 +++++++++----------
.../Querying/ExpressionVisitorBase.cs | 34 ++++++-------
.../Querying/PocoToSqlExpressionVisitor.cs | 8 +--
.../Persistence/SqlContextExtensions.cs | 8 +--
.../SqlSyntax/ISqlSyntaxProvider.cs | 6 +--
.../Persistence/SqlSyntaxExtensions.cs | 4 +-
.../BlockEditorPropertyEditor.cs | 16 +++---
.../BlockEditorPropertyHandler.cs | 2 +-
.../ColorPickerConfigurationEditor.cs | 2 +-
.../PropertyEditors/ComplexEditorValidator.cs | 2 +-
.../ConfigurationEditorOfTConfiguration.cs | 4 +-
.../ContentPickerConfigurationEditor.cs | 2 +-
.../ContentPickerPropertyEditor.cs | 2 +-
.../DateTimeConfigurationEditor.cs | 2 +-
.../GridConfigurationEditor.cs | 2 +-
.../PropertyEditors/GridPropertyEditor.cs | 2 +-
.../GridPropertyIndexValueFactory.cs | 2 +-
.../ImageCropperConfigurationEditor.cs | 2 +-
.../ImageCropperPropertyEditor.cs | 2 +-
.../ValueConverters/ImageCropperValue.cs | 8 +--
src/Umbraco.Infrastructure/Scoping/Scope.cs | 16 +++---
.../Scoping/ScopeContext.cs | 2 +-
.../Services/Implement/AuditService.cs | 8 +--
.../Umbraco.Infrastructure.csproj | 2 +
.../package-lock.json | 6 +--
.../Umbraco.Tests.AcceptanceTest/package.json | 2 +-
199 files changed, 641 insertions(+), 596 deletions(-)
diff --git a/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
index c167181be0..919320ec34 100644
--- a/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
+++ b/src/Umbraco.Core/Cache/IRepositoryCachePolicy.cs
@@ -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/Configuration/IConfigManipulator.cs b/src/Umbraco.Core/Configuration/IConfigManipulator.cs
index f0f4bcde63..c99f90e5c9 100644
--- a/src/Umbraco.Core/Configuration/IConfigManipulator.cs
+++ b/src/Umbraco.Core/Configuration/IConfigManipulator.cs
@@ -3,7 +3,7 @@
public interface IConfigManipulator
{
void RemoveConnectionString();
- void SaveConnectionString(string connectionString, string providerName);
+ void SaveConnectionString(string connectionString, string? providerName);
void SaveConfigValue(string itemPath, object value);
void SaveDisableRedirectUrlTracking(bool disable);
void SetGlobalId(string id);
diff --git a/src/Umbraco.Core/Configuration/IUmbracoVersion.cs b/src/Umbraco.Core/Configuration/IUmbracoVersion.cs
index 2468c921fa..2758d9dabf 100644
--- a/src/Umbraco.Core/Configuration/IUmbracoVersion.cs
+++ b/src/Umbraco.Core/Configuration/IUmbracoVersion.cs
@@ -8,12 +8,12 @@ namespace Umbraco.Cms.Core.Configuration
///
/// Gets the non-semantic version of the Umbraco code.
///
- Version? Version { get; }
+ Version Version { get; }
///
/// Gets the semantic version comments of the Umbraco code.
///
- string? Comment { get; }
+ string Comment { get; }
///
/// Gets the assembly version of the Umbraco code.
diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs
index efa1b7e120..4b4ad87801 100644
--- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs
+++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs
@@ -31,12 +31,12 @@ namespace Umbraco.Cms.Core.Configuration
///
/// Gets the non-semantic version of the Umbraco code.
///
- public Version? Version { get; }
+ public Version Version { get; }
///
/// Gets the semantic version comments of the Umbraco code.
///
- public string? Comment => SemanticVersion?.Prerelease;
+ public string Comment => SemanticVersion.Prerelease;
///
/// Gets the assembly version of the Umbraco code.
diff --git a/src/Umbraco.Core/Extensions/EnumerableExtensions.cs b/src/Umbraco.Core/Extensions/EnumerableExtensions.cs
index 44e17081e5..5f5598f226 100644
--- a/src/Umbraco.Core/Extensions/EnumerableExtensions.cs
+++ b/src/Umbraco.Core/Extensions/EnumerableExtensions.cs
@@ -332,7 +332,7 @@ namespace Umbraco.Extensions
///
///
///
- public static IEnumerable EmptyNull(this IEnumerable items)
+ public static IEnumerable EmptyNull(this IEnumerable? items)
{
return items ?? Enumerable.Empty();
}
diff --git a/src/Umbraco.Core/Extensions/PublishedSnapshotAccessorExtensions.cs b/src/Umbraco.Core/Extensions/PublishedSnapshotAccessorExtensions.cs
index bffa642ffe..fa7e4555e6 100644
--- a/src/Umbraco.Core/Extensions/PublishedSnapshotAccessorExtensions.cs
+++ b/src/Umbraco.Core/Extensions/PublishedSnapshotAccessorExtensions.cs
@@ -5,11 +5,11 @@ namespace Umbraco.Extensions
{
public static class PublishedSnapshotAccessorExtensions
{
- public static IPublishedSnapshot? GetRequiredPublishedSnapshot(this IPublishedSnapshotAccessor publishedSnapshotAccessor)
+ public static IPublishedSnapshot GetRequiredPublishedSnapshot(this IPublishedSnapshotAccessor publishedSnapshotAccessor)
{
if (publishedSnapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot))
{
- return publishedSnapshot;
+ return publishedSnapshot!;
}
throw new InvalidOperationException("Wasn't possible to a get a valid Snapshot");
}
diff --git a/src/Umbraco.Core/Install/Models/DatabaseModel.cs b/src/Umbraco.Core/Install/Models/DatabaseModel.cs
index 616ad5dc8b..f321e8fc89 100644
--- a/src/Umbraco.Core/Install/Models/DatabaseModel.cs
+++ b/src/Umbraco.Core/Install/Models/DatabaseModel.cs
@@ -9,16 +9,16 @@ namespace Umbraco.Cms.Core.Install.Models
public DatabaseType DatabaseType { get; set; } = DatabaseType.SqlServer;
[DataMember(Name = "server")]
- public string? Server { get; set; }
+ public string Server { get; set; } = null!;
[DataMember(Name = "databaseName")]
- public string? DatabaseName { get; set; }
+ public string DatabaseName { get; set; } = null!;
[DataMember(Name = "login")]
- public string? Login { get; set; }
+ public string Login { get; set; } = null!;
[DataMember(Name = "password")]
- public string? Password { get; set; }
+ public string Password { get; set; } = null!;
[DataMember(Name = "integratedAuth")]
public bool IntegratedAuth { get; set; }
diff --git a/src/Umbraco.Core/Install/Models/UserModel.cs b/src/Umbraco.Core/Install/Models/UserModel.cs
index 5c13c5c932..b4226fa948 100644
--- a/src/Umbraco.Core/Install/Models/UserModel.cs
+++ b/src/Umbraco.Core/Install/Models/UserModel.cs
@@ -9,10 +9,10 @@ namespace Umbraco.Cms.Core.Install.Models
public string? Name { get; set; }
[DataMember(Name = "email")]
- public string? Email { get; set; }
+ public string Email { get; set; }
[DataMember(Name = "password")]
- public string? Password { get; set; }
+ public string Password { get; set; }
[DataMember(Name = "subscribeToNewsLetter")]
public bool SubscribeToNewsLetter { get; set; }
diff --git a/src/Umbraco.Core/Manifest/IManifestParser.cs b/src/Umbraco.Core/Manifest/IManifestParser.cs
index 09d3ccbe1c..14e3d01cca 100644
--- a/src/Umbraco.Core/Manifest/IManifestParser.cs
+++ b/src/Umbraco.Core/Manifest/IManifestParser.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Manifest
/// Gets all manifests, merged into a single manifest object.
///
///
- CompositePackageManifest CombinedManifest { get; }
+ CompositePackageManifest? CombinedManifest { get; }
///
/// Parses a manifest.
diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs
index dfe6ad46e7..14ff1165cd 100644
--- a/src/Umbraco.Core/Manifest/PackageManifest.cs
+++ b/src/Umbraco.Core/Manifest/PackageManifest.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Cms.Core.Manifest
/// An optional package name. If not specified then the directory name is used.
///
[DataMember(Name = "name")]
- public string? PackageName
+ public string PackageName
{
get
{
@@ -47,7 +47,7 @@ namespace Umbraco.Cms.Core.Manifest
/// using system directory separators.
///
[IgnoreDataMember]
- public string? Source { get; set; }
+ public string Source { get; set; } = null!;
///
/// Gets or sets the version of the package
diff --git a/src/Umbraco.Core/Mapping/IUmbracoMapper.cs b/src/Umbraco.Core/Mapping/IUmbracoMapper.cs
index fdf6e099c9..5c3e980ac3 100644
--- a/src/Umbraco.Core/Mapping/IUmbracoMapper.cs
+++ b/src/Umbraco.Core/Mapping/IUmbracoMapper.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The target type.
/// The source object.
/// The target object.
- TTarget Map(object source);
+ TTarget? Map(object source);
///
/// Maps a source object to a new target object.
@@ -52,7 +52,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context preparation method.
/// The target object.
- TTarget Map(object source, Action f);
+ TTarget? Map(object source, Action f);
///
/// Maps a source object to a new target object.
@@ -61,7 +61,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context.
/// The target object.
- TTarget Map(object source, MapperContext context);
+ TTarget? Map(object source, MapperContext context);
///
/// Maps a source object to a new target object.
@@ -70,7 +70,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The target type.
/// The source object.
/// The target object.
- TTarget Map(TSource source);
+ TTarget? Map(TSource source);
///
/// Maps a source object to a new target object.
@@ -80,7 +80,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context preparation method.
/// The target object.
- TTarget Map(TSource source, Action f);
+ TTarget? Map(TSource source, Action f);
///
/// Maps a source object to a new target object.
@@ -90,7 +90,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context.
/// The target object.
- TTarget Map(TSource? source, MapperContext context);
+ TTarget? Map(TSource? source, MapperContext context);
///
/// Maps a source object to an existing target object.
diff --git a/src/Umbraco.Core/Media/IImageUrlGenerator.cs b/src/Umbraco.Core/Media/IImageUrlGenerator.cs
index bf61127561..25bb1ac899 100644
--- a/src/Umbraco.Core/Media/IImageUrlGenerator.cs
+++ b/src/Umbraco.Core/Media/IImageUrlGenerator.cs
@@ -23,6 +23,6 @@ namespace Umbraco.Cms.Core.Media
///
/// The generated image URL.
///
- string GetImageUrl(ImageUrlGenerationOptions options);
+ string? GetImageUrl(ImageUrlGenerationOptions options);
}
}
diff --git a/src/Umbraco.Core/Models/Content.cs b/src/Umbraco.Core/Models/Content.cs
index bfd6024bb6..d3b02e30a1 100644
--- a/src/Umbraco.Core/Models/Content.cs
+++ b/src/Umbraco.Core/Models/Content.cs
@@ -76,7 +76,7 @@ namespace Umbraco.Cms.Core.Models
/// Id of the Parent content
/// ContentType for the current Content object
/// An optional culture.
- public Content(string name, int parentId, IContentType contentType, string? culture = null)
+ public Content(string? name, int parentId, IContentType? contentType, string? culture = null)
: this(name, parentId, contentType, new PropertyCollection(), culture)
{ }
@@ -103,7 +103,7 @@ namespace Umbraco.Cms.Core.Models
/// ContentType for the current Content object
/// Collection of properties
/// An optional culture.
- public Content(string name, int parentId, IContentType contentType, PropertyCollection properties, string? culture = null)
+ public Content(string? name, int parentId, IContentType? contentType, PropertyCollection properties, string? culture = null)
: base(name, parentId, contentType, properties, culture)
{
if (contentType == null) throw new ArgumentNullException(nameof(contentType));
diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs
index 2dc6cb94e4..d9223130d6 100644
--- a/src/Umbraco.Core/Models/ContentBase.cs
+++ b/src/Umbraco.Core/Models/ContentBase.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Initializes a new instance of the class.
///
- protected ContentBase(string? name, int parentId, IContentTypeComposition contentType, IPropertyCollection properties, string? culture = null)
+ protected ContentBase(string? name, int parentId, IContentTypeComposition? contentType, IPropertyCollection properties, string? culture = null)
: this(name, contentType, properties, culture)
{
if (parentId == 0) throw new ArgumentOutOfRangeException(nameof(parentId));
@@ -60,7 +60,7 @@ namespace Umbraco.Cms.Core.Models
SetParent(parent);
}
- private ContentBase(string? name, IContentTypeComposition contentType, IPropertyCollection properties, string? culture = null)
+ private ContentBase(string? name, IContentTypeComposition? contentType, IPropertyCollection properties, string? culture = null)
{
ContentType = contentType?.ToSimple() ?? throw new ArgumentNullException(nameof(contentType));
diff --git a/src/Umbraco.Core/Models/DataType.cs b/src/Umbraco.Core/Models/DataType.cs
index bde06414a1..6b33f07385 100644
--- a/src/Umbraco.Core/Models/DataType.cs
+++ b/src/Umbraco.Core/Models/DataType.cs
@@ -147,7 +147,7 @@ namespace Umbraco.Cms.Core.Models
/// type, and they should be the same.
/// Think before using!
///
- public void SetLazyConfiguration(string configurationJson)
+ public void SetLazyConfiguration(string? configurationJson)
{
_hasConfiguration = false;
_configuration = null;
diff --git a/src/Umbraco.Core/Models/Email/NotificationEmailModel.cs b/src/Umbraco.Core/Models/Email/NotificationEmailModel.cs
index c19c0cd3df..f27b279c80 100644
--- a/src/Umbraco.Core/Models/Email/NotificationEmailModel.cs
+++ b/src/Umbraco.Core/Models/Email/NotificationEmailModel.cs
@@ -29,14 +29,14 @@ namespace Umbraco.Cms.Core.Models.Email
public bool HasAttachments => Attachments != null && Attachments.Count > 0;
public NotificationEmailModel(
- NotificationEmailAddress from,
- IEnumerable to,
- IEnumerable cc,
- IEnumerable bcc,
- IEnumerable replyTo,
- string subject,
- string body,
- IEnumerable attachments,
+ NotificationEmailAddress? from,
+ IEnumerable? to,
+ IEnumerable? cc,
+ IEnumerable? bcc,
+ IEnumerable? replyTo,
+ string? subject,
+ string? body,
+ IEnumerable? attachments,
bool isBodyHtml)
{
From = from;
diff --git a/src/Umbraco.Core/Models/Entities/ITreeEntity.cs b/src/Umbraco.Core/Models/Entities/ITreeEntity.cs
index 0024a7cdc4..b970f46726 100644
--- a/src/Umbraco.Core/Models/Entities/ITreeEntity.cs
+++ b/src/Umbraco.Core/Models/Entities/ITreeEntity.cs
@@ -8,7 +8,7 @@
///
/// Gets or sets the name of the entity.
///
- string? Name { get; set; }
+ string Name { get; set; }
///
/// Gets or sets the identifier of the user who created this entity.
diff --git a/src/Umbraco.Core/Models/IDictionaryTranslation.cs b/src/Umbraco.Core/Models/IDictionaryTranslation.cs
index 372bb4488d..445bafd4ba 100644
--- a/src/Umbraco.Core/Models/IDictionaryTranslation.cs
+++ b/src/Umbraco.Core/Models/IDictionaryTranslation.cs
@@ -17,6 +17,6 @@ namespace Umbraco.Cms.Core.Models
/// Gets or sets the translated text
///
[DataMember]
- string? Value { get; set; }
+ string Value { get; set; }
}
}
diff --git a/src/Umbraco.Core/Models/IMacro.cs b/src/Umbraco.Core/Models/IMacro.cs
index 229c03348a..e8102b7768 100644
--- a/src/Umbraco.Core/Models/IMacro.cs
+++ b/src/Umbraco.Core/Models/IMacro.cs
@@ -54,7 +54,7 @@ namespace Umbraco.Cms.Core.Models
/// Gets or set the path to the macro source to render
///
[DataMember]
- string? MacroSource { get; set; }
+ string MacroSource { get; set; }
///
/// Gets or sets a list of Macro Properties
diff --git a/src/Umbraco.Core/Models/IPropertyCollection.cs b/src/Umbraco.Core/Models/IPropertyCollection.cs
index 5d18de568e..d39a214fdd 100644
--- a/src/Umbraco.Core/Models/IPropertyCollection.cs
+++ b/src/Umbraco.Core/Models/IPropertyCollection.cs
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Collections.Specialized;
+using System.Diagnostics.CodeAnalysis;
namespace Umbraco.Cms.Core.Models
{
public interface IPropertyCollection : IEnumerable, IDeepCloneable, INotifyCollectionChanged
{
- bool TryGetValue(string propertyTypeAlias, out IProperty? property);
+ bool TryGetValue(string propertyTypeAlias, [MaybeNullWhen(false)] out IProperty property);
bool Contains(string key);
///
diff --git a/src/Umbraco.Core/Models/IPropertyType.cs b/src/Umbraco.Core/Models/IPropertyType.cs
index 2e70c64cd9..f807f9fce6 100644
--- a/src/Umbraco.Core/Models/IPropertyType.cs
+++ b/src/Umbraco.Core/Models/IPropertyType.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Gets of sets the name of the property type.
///
- string? Name { get; set; }
+ string Name { get; set; }
///
/// Gets of sets the alias of the property type.
diff --git a/src/Umbraco.Core/Models/Macro.cs b/src/Umbraco.Core/Models/Macro.cs
index cfea0df550..acc66b6c38 100644
--- a/src/Umbraco.Core/Models/Macro.cs
+++ b/src/Umbraco.Core/Models/Macro.cs
@@ -42,7 +42,7 @@ namespace Umbraco.Cms.Core.Models
///
///
///
- public Macro(IShortStringHelper shortStringHelper, int id, Guid key, bool useInEditor, int cacheDuration, string @alias, string name, bool cacheByPage, bool cacheByMember, bool dontRender, string macroSource)
+ public Macro(IShortStringHelper shortStringHelper, int id, Guid key, bool useInEditor, int cacheDuration, string @alias, string? name, bool cacheByPage, bool cacheByMember, bool dontRender, string macroSource)
: this(shortStringHelper)
{
Id = id;
diff --git a/src/Umbraco.Core/Models/MacroProperty.cs b/src/Umbraco.Core/Models/MacroProperty.cs
index e0f5001244..0c80f68380 100644
--- a/src/Umbraco.Core/Models/MacroProperty.cs
+++ b/src/Umbraco.Core/Models/MacroProperty.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Cms.Core.Models
///
///
///
- public MacroProperty(int id, Guid key, string @alias, string name, int sortOrder, string editorAlias)
+ public MacroProperty(int id, Guid key, string @alias, string? name, int sortOrder, string editorAlias)
{
_id = id;
_alias = alias;
diff --git a/src/Umbraco.Core/Models/Member.cs b/src/Umbraco.Core/Models/Member.cs
index 84dacb4a0a..c4eca5d2d1 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;
diff --git a/src/Umbraco.Core/Models/Membership/IMembershipUser.cs b/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
index b4a38479f6..40acb05a55 100644
--- a/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
+++ b/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Core.Models.Membership
///
/// Gets or sets the raw password value
///
- string? RawPasswordValue { get; set; }
+ string RawPasswordValue { get; set; }
///
/// The user's specific password config (i.e. algorithm type, etc...)
diff --git a/src/Umbraco.Core/Models/Membership/ReadOnlyUserGroup.cs b/src/Umbraco.Core/Models/Membership/ReadOnlyUserGroup.cs
index 261e62e604..24543337ba 100644
--- a/src/Umbraco.Core/Models/Membership/ReadOnlyUserGroup.cs
+++ b/src/Umbraco.Core/Models/Membership/ReadOnlyUserGroup.cs
@@ -6,13 +6,13 @@ namespace Umbraco.Cms.Core.Models.Membership
{
public class ReadOnlyUserGroup : IReadOnlyUserGroup, IEquatable
{
- public ReadOnlyUserGroup(int id, string? name, string? icon, int? startContentId, int? startMediaId, string @alias,
+ public ReadOnlyUserGroup(int id, string? name, string? icon, int? startContentId, int? startMediaId, string? @alias,
IEnumerable allowedSections, IEnumerable? permissions)
{
Name = name ?? string.Empty;
Icon = icon;
Id = id;
- Alias = alias;
+ Alias = alias ?? string.Empty;
AllowedSections = allowedSections.ToArray();
Permissions = permissions?.ToArray();
diff --git a/src/Umbraco.Core/Models/Membership/User.cs b/src/Umbraco.Core/Models/Membership/User.cs
index b2100a002e..11b4ec2139 100644
--- a/src/Umbraco.Core/Models/Membership/User.cs
+++ b/src/Umbraco.Core/Models/Membership/User.cs
@@ -72,8 +72,8 @@ namespace Umbraco.Cms.Core.Models.Membership
///
///
///
- public User(GlobalSettings globalSettings, int id, string name, string email, string username,
- string rawPasswordValue, string passwordConfig,
+ public User(GlobalSettings globalSettings, int id, string? name, string? email, string? username,
+ string? rawPasswordValue, string? passwordConfig,
IEnumerable userGroups, int[] startContentIds, int[] startMediaIds)
: this(globalSettings)
{
@@ -111,7 +111,7 @@ namespace Umbraco.Cms.Core.Models.Membership
private DateTime? _emailConfirmedDate;
private DateTime? _invitedDate;
private string _email;
- private string? _rawPasswordValue;
+ private string _rawPasswordValue;
private string? _passwordConfig;
private IEnumerable? _allowedSections;
private HashSet _userGroups;
@@ -158,7 +158,7 @@ namespace Umbraco.Cms.Core.Models.Membership
}
[IgnoreDataMember]
- public string? RawPasswordValue
+ public string RawPasswordValue
{
get => _rawPasswordValue;
set => SetPropertyValueAndDetectChanges(value, ref _rawPasswordValue, nameof(RawPasswordValue));
diff --git a/src/Umbraco.Core/Models/Membership/UserGroup.cs b/src/Umbraco.Core/Models/Membership/UserGroup.cs
index dd91cd6445..4ba77cb087 100644
--- a/src/Umbraco.Core/Models/Membership/UserGroup.cs
+++ b/src/Umbraco.Core/Models/Membership/UserGroup.cs
@@ -48,11 +48,11 @@ namespace Umbraco.Cms.Core.Models.Membership
///
///
///
- public UserGroup(IShortStringHelper shortStringHelper, int userCount, string alias, string name, IEnumerable permissions, string icon)
+ public UserGroup(IShortStringHelper shortStringHelper, int userCount, string? alias, string? name, IEnumerable permissions, string? icon)
: this(shortStringHelper)
{
UserCount = userCount;
- _alias = alias;
+ _alias = alias ?? string.Empty;
_name = name;
_permissions = permissions;
_icon = icon;
diff --git a/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs b/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs
index 127347e528..34f4f83755 100644
--- a/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs
+++ b/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs
@@ -10,21 +10,21 @@ namespace Umbraco.Cms.Core.Models.Packaging
///
public class CompiledPackage
{
- public FileInfo? PackageFile { get; set; }
- public string? Name { get; set; }
+ public FileInfo PackageFile { get; set; } = null!;
+ public string Name { get; set; } = string.Empty;
public InstallWarnings Warnings { get; set; } = new InstallWarnings();
- public IEnumerable? Macros { get; set; } // TODO: make strongly typed
- public IEnumerable? MacroPartialViews { get; set; } // TODO: make strongly typed
- public IEnumerable? Templates { get; set; } // TODO: make strongly typed
- public IEnumerable? Stylesheets { get; set; } // TODO: make strongly typed
- public IEnumerable? Scripts { get; set; } // TODO: make strongly typed
- public IEnumerable? PartialViews { get; set; } // TODO: make strongly typed
- public IEnumerable? DataTypes { get; set; } // TODO: make strongly typed
- public IEnumerable? Languages { get; set; } // TODO: make strongly typed
- public IEnumerable? DictionaryItems { get; set; } // TODO: make strongly typed
- public IEnumerable? DocumentTypes { get; set; } // TODO: make strongly typed
- public IEnumerable? MediaTypes { get; set; } // TODO: make strongly typed
- public IEnumerable? Documents { get; set; }
- public IEnumerable? Media { get; set; }
+ public IEnumerable Macros { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable MacroPartialViews { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable Templates { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable Stylesheets { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable Scripts { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable PartialViews { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable DataTypes { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable Languages { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable DictionaryItems { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable DocumentTypes { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable MediaTypes { get; set; } = null!; // TODO: make strongly typed
+ public IEnumerable Documents { get; set; } = null!;
+ public IEnumerable Media { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Core/Models/Packaging/CompiledPackageContentBase.cs b/src/Umbraco.Core/Models/Packaging/CompiledPackageContentBase.cs
index 476b4a5dac..0fb1c60908 100644
--- a/src/Umbraco.Core/Models/Packaging/CompiledPackageContentBase.cs
+++ b/src/Umbraco.Core/Models/Packaging/CompiledPackageContentBase.cs
@@ -20,6 +20,6 @@ namespace Umbraco.Cms.Core.Models.Packaging
///
/// The serialized version of the content
///
- public XElement? XmlData { get; set; }
+ public XElement XmlData { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Core/Models/Property.cs b/src/Umbraco.Core/Models/Property.cs
index 2975b97b42..1fd52add4b 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;
@@ -85,9 +85,9 @@ namespace Umbraco.Cms.Core.Models
}
public string Culture { get; }
- public string Segment { get; }
+ public string? Segment { get; }
public bool Published { get; }
- public object Value { get; }
+ public object? Value { get; }
}
///
diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs
index 7db1d0d2b3..37dc01ca6e 100644
--- a/src/Umbraco.Core/Models/PropertyType.cs
+++ b/src/Umbraco.Core/Models/PropertyType.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Core.Models
{
private readonly IShortStringHelper _shortStringHelper;
private readonly bool _forceValueStorageType;
- private string? _name;
+ private string _name;
private string _alias;
private string? _description;
private int _dataTypeId;
@@ -48,6 +48,7 @@ namespace Umbraco.Cms.Core.Models
_valueStorageType = dataType.DatabaseType;
_variations = ContentVariation.Nothing;
_alias = string.Empty;
+ _name = string.Empty;
}
///
@@ -110,10 +111,10 @@ namespace Umbraco.Cms.Core.Models
///
[DataMember]
- public string? Name
+ public string Name
{
get => _name;
- set => SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name));
+ set => SetPropertyValueAndDetectChanges(value, ref _name!, nameof(Name));
}
///
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs
index 2f30e16bdb..3ab21d15f6 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedPropertyType.cs
@@ -93,7 +93,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
/// The model CLR type may be a type, or may contain types.
/// For the actual CLR type, see .
///
- Type? ModelClrType { get; }
+ Type ModelClrType { get; }
///
/// Gets the property CLR type.
diff --git a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
index 2673a61876..065681028e 100644
--- a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
@@ -89,10 +89,10 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
/// The type.
/// The model types map.
/// The actual CLR type name.
- public static string? MapToName(Type type, Dictionary map)
+ public static string MapToName(Type type, Dictionary map)
=> MapToName(type, map, false);
- private static string? MapToName(Type type, Dictionary map, bool dictionaryIsInvariant)
+ private static string MapToName(Type type, Dictionary map, bool dictionaryIsInvariant)
{
// it may be that senders forgot to send an invariant dictionary (garbage-in)
if (!dictionaryIsInvariant)
@@ -113,7 +113,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
}
if (type.IsGenericType == false)
- return type.FullName;
+ return type.FullName!;
var def = type.GetGenericTypeDefinition();
if (def == null)
throw new PanicException($"The type {type} has not generic type definition");
diff --git a/src/Umbraco.Core/Models/ServerRegistration.cs b/src/Umbraco.Core/Models/ServerRegistration.cs
index aa46bfbcf9..553460eb5b 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/Tag.cs b/src/Umbraco.Core/Models/Tag.cs
index 3c1e5eb13f..428f9583d0 100644
--- a/src/Umbraco.Core/Models/Tag.cs
+++ b/src/Umbraco.Core/Models/Tag.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Cms.Core.Models
///
/// Initializes a new instance of the class.
///
- public Tag(int id, string group, string text, int? languageId = null)
+ public Tag(int id, string? group, string? text, int? languageId = null)
{
Id = id;
Text = text;
diff --git a/src/Umbraco.Core/Packaging/PackageDefinition.cs b/src/Umbraco.Core/Packaging/PackageDefinition.cs
index ae12a914b3..66a0a9e102 100644
--- a/src/Umbraco.Core/Packaging/PackageDefinition.cs
+++ b/src/Umbraco.Core/Packaging/PackageDefinition.cs
@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Packaging
public bool ContentLoadChildNodes { get; set; }
[DataMember(Name = "contentNodeId")]
- public string ContentNodeId { get; set; } = string.Empty;
+ public string? ContentNodeId { get; set; }
[DataMember(Name = "macros")]
public IList Macros { get; set; } = new List();
diff --git a/src/Umbraco.Core/PropertyEditors/ConfigurationEditor.cs b/src/Umbraco.Core/PropertyEditors/ConfigurationEditor.cs
index 2c071ed98c..639985e7c6 100644
--- a/src/Umbraco.Core/PropertyEditors/ConfigurationEditor.cs
+++ b/src/Umbraco.Core/PropertyEditors/ConfigurationEditor.cs
@@ -61,7 +61,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
///
/// Converts a configuration object into a serialized database value.
///
- public static string? ToDatabase(object configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
+ public static string? ToDatabase(object? configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
=> configuration == null ? null : configurationEditorJsonSerializer.Serialize(configuration);
///
diff --git a/src/Umbraco.Core/PropertyEditors/DataEditor.cs b/src/Umbraco.Core/PropertyEditors/DataEditor.cs
index 5619a1bb87..07d8383334 100644
--- a/src/Umbraco.Core/PropertyEditors/DataEditor.cs
+++ b/src/Umbraco.Core/PropertyEditors/DataEditor.cs
@@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
///
/// Initializes a new instance of the class.
///
- public DataEditor(IDataValueEditorFactory dataValueEditorFactory, EditorType type = EditorType.PropertyValue)
+ public DataEditor(IDataValueEditorFactory? dataValueEditorFactory, EditorType type = EditorType.PropertyValue)
{
// defaults
@@ -60,7 +60,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
[DataMember(Name = "alias", IsRequired = true)]
public string Alias { get; set; }
- protected IDataValueEditorFactory DataValueEditorFactory { get; }
+ protected IDataValueEditorFactory? DataValueEditorFactory { get; }
///
[IgnoreDataMember]
diff --git a/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs
index 14af54ee4a..888c74ff29 100644
--- a/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs
+++ b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs
@@ -24,17 +24,17 @@ namespace Umbraco.Cms.Core.PropertyEditors
[DataContract]
public class DataValueEditor : IDataValueEditor
{
- private readonly ILocalizedTextService _localizedTextService;
- private readonly IShortStringHelper _shortStringHelper;
- private readonly IJsonSerializer _jsonSerializer;
+ private readonly ILocalizedTextService? _localizedTextService;
+ private readonly IShortStringHelper? _shortStringHelper;
+ private readonly IJsonSerializer? _jsonSerializer;
///
/// Initializes a new instance of the class.
///
public DataValueEditor(
- ILocalizedTextService localizedTextService,
- IShortStringHelper shortStringHelper,
- IJsonSerializer jsonSerializer) // for tests, and manifest
+ ILocalizedTextService? localizedTextService,
+ IShortStringHelper? shortStringHelper,
+ IJsonSerializer? jsonSerializer) // for tests, and manifest
{
_localizedTextService = localizedTextService;
_shortStringHelper = shortStringHelper;
diff --git a/src/Umbraco.Core/PropertyEditors/IPropertyIndexValueFactory.cs b/src/Umbraco.Core/PropertyEditors/IPropertyIndexValueFactory.cs
index 20db0a49a1..6ac6b46f50 100644
--- a/src/Umbraco.Core/PropertyEditors/IPropertyIndexValueFactory.cs
+++ b/src/Umbraco.Core/PropertyEditors/IPropertyIndexValueFactory.cs
@@ -19,6 +19,6 @@ namespace Umbraco.Cms.Core.PropertyEditors
/// values. By default, there would be only one object: the property value. But some implementations may return
/// more than one value for a given field.
///
- IEnumerable>> GetIndexValues(IProperty property, string culture, string segment, bool published);
+ IEnumerable>> GetIndexValues(IProperty property, string? culture, string? segment, bool published);
}
}
diff --git a/src/Umbraco.Core/PropertyEditors/MediaPicker3Configuration.cs b/src/Umbraco.Core/PropertyEditors/MediaPicker3Configuration.cs
index 8b843fdf85..50595b7350 100644
--- a/src/Umbraco.Core/PropertyEditors/MediaPicker3Configuration.cs
+++ b/src/Umbraco.Core/PropertyEditors/MediaPicker3Configuration.cs
@@ -46,7 +46,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
public class CropConfiguration
{
[DataMember(Name = "alias")]
- public string? Alias { get; set; }
+ public string Alias { get; set; }
[DataMember(Name = "label")]
public string? Label { get; set; }
diff --git a/src/Umbraco.Core/PublishedCache/IPublishedSnapshot.cs b/src/Umbraco.Core/PublishedCache/IPublishedSnapshot.cs
index 3c55b9d699..9ea08d36d0 100644
--- a/src/Umbraco.Core/PublishedCache/IPublishedSnapshot.cs
+++ b/src/Umbraco.Core/PublishedCache/IPublishedSnapshot.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.PublishedCache
///
/// Gets the .
///
- IPublishedMemberCache? Members { get; }
+ IPublishedMemberCache Members { get; }
///
/// Gets the .
diff --git a/src/Umbraco.Core/Routing/WebPath.cs b/src/Umbraco.Core/Routing/WebPath.cs
index 91313c8278..a4da94ac79 100644
--- a/src/Umbraco.Core/Routing/WebPath.cs
+++ b/src/Umbraco.Core/Routing/WebPath.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core.Routing
{
public const char PathSeparator = '/';
- public static string Combine(params string[] paths)
+ public static string Combine(params string[]? paths)
{
if (paths == null)
{
diff --git a/src/Umbraco.Core/Services/IAuditService.cs b/src/Umbraco.Core/Services/IAuditService.cs
index 63beceef1b..8af4058c12 100644
--- a/src/Umbraco.Core/Services/IAuditService.cs
+++ b/src/Umbraco.Core/Services/IAuditService.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Services
///
public interface IAuditService : IService
{
- void Add(AuditType type, int userId, int objectId, string entityType, string comment, string? parameters = null);
+ void Add(AuditType type, int userId, int objectId, string? entityType, string comment, string? parameters = null);
IEnumerable GetLogs(int objectId);
IEnumerable GetUserLogs(int userId, AuditType type, DateTime? sinceDate = null);
diff --git a/src/Umbraco.Core/Services/IPackagingService.cs b/src/Umbraco.Core/Services/IPackagingService.cs
index f3f3c34eb4..719f8e3396 100644
--- a/src/Umbraco.Core/Services/IPackagingService.cs
+++ b/src/Umbraco.Core/Services/IPackagingService.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Cms.Core.Services
///
InstallationSummary InstallCompiledPackageData(FileInfo packageXmlFile, int userId = Constants.Security.SuperUserId);
- InstallationSummary InstallCompiledPackageData(XDocument packageXml, int userId = Constants.Security.SuperUserId);
+ InstallationSummary InstallCompiledPackageData(XDocument? packageXml, int userId = Constants.Security.SuperUserId);
///
/// Returns the advertised installed packages
diff --git a/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs b/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
index b8fc8d68a5..1c11aa6fa4 100644
--- a/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
+++ b/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
@@ -49,7 +49,7 @@ namespace Umbraco.Cms.Core.Cache
}
else
{
- return EntityTypeCacheKey + id.ToString().ToUpperInvariant();
+ return EntityTypeCacheKey + id?.ToString()?.ToUpperInvariant();
}
}
@@ -162,7 +162,7 @@ namespace Umbraco.Cms.Core.Cache
}
///
- public override TEntity Get(TId id, Func performGet, Func> performGetAll)
+ public override TEntity? Get(TId id, Func performGet, Func> performGetAll)
{
var cacheKey = GetEntityCacheKey(id);
var fromCache = Cache.GetCacheItem(cacheKey);
@@ -184,7 +184,7 @@ namespace Umbraco.Cms.Core.Cache
}
///
- public override TEntity GetCached(TId id)
+ public override TEntity? GetCached(TId id)
{
var cacheKey = GetEntityCacheKey(id);
return Cache.GetCacheItem(cacheKey);
@@ -200,7 +200,7 @@ namespace Umbraco.Cms.Core.Cache
}
///
- public override TEntity[] GetAll(TId[] ids, Func> performGetAll)
+ public override TEntity?[] GetAll(TId[] ids, Func> performGetAll)
{
if (ids.Length > 0)
{
@@ -222,9 +222,12 @@ namespace Umbraco.Cms.Core.Cache
if (_options.GetAllCacheValidateCount)
{
// need to validate the count, get the actual count and return if ok
- var totalCount = _options.PerformCount();
- if (entities.Length == totalCount)
- return entities;
+ if (_options.PerformCount is not null)
+ {
+ var totalCount = _options.PerformCount();
+ if (entities.Length == totalCount)
+ return entities;
+ }
}
else
{
diff --git a/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs b/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs
index 6b2be94d45..94cededccd 100644
--- a/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs
+++ b/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs
@@ -114,27 +114,27 @@ namespace Umbraco.Cms.Core.Cache
}
///
- public override TEntity Get(TId id, Func performGet, Func> performGetAll)
+ public override TEntity? Get(TId id, Func performGet, Func> performGetAll)
{
// get all from the cache, then look for the entity
var all = GetAllCached(performGetAll);
- var entity = all.FirstOrDefault(x => _entityGetId(x).Equals(id));
+ var entity = all.FirstOrDefault(x => _entityGetId(x)?.Equals(id) ?? false);
// see note in InsertEntities - what we get here is the original
// cached entity, not a clone, so we need to manually ensure it is deep-cloned.
- return (TEntity)entity?.DeepClone();
+ return (TEntity?)entity?.DeepClone();
}
///
- public override TEntity GetCached(TId id)
+ public override TEntity? GetCached(TId id)
{
// get all from the cache -- and only the cache, then look for the entity
var all = Cache.GetCacheItem>(GetEntityTypeCacheKey());
- var entity = all?.FirstOrDefault(x => _entityGetId(x).Equals(id));
+ var entity = all?.FirstOrDefault(x => _entityGetId(x)?.Equals(id) ?? false);
// see note in InsertEntities - what we get here is the original
// cached entity, not a clone, so we need to manually ensure it is deep-cloned.
- return (TEntity) entity?.DeepClone();
+ return (TEntity?) entity?.DeepClone();
}
///
@@ -142,7 +142,7 @@ namespace Umbraco.Cms.Core.Cache
{
// get all as one set, then look for the entity
var all = GetAllCached(performGetAll);
- return all.Any(x => _entityGetId(x).Equals(id));
+ return all.Any(x => _entityGetId(x)?.Equals(id) ?? false);
}
///
diff --git a/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs b/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs
index 6124d9fb7a..dfe3466fc0 100644
--- a/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs
+++ b/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs
@@ -46,10 +46,10 @@ namespace Umbraco.Cms.Core.Cache
}
///
- public abstract TEntity Get(TId id, Func performGet, Func> performGetAll);
+ public abstract TEntity? Get(TId id, Func performGet, Func> performGetAll);
///
- public abstract TEntity GetCached(TId id);
+ public abstract TEntity? GetCached(TId id);
///
public abstract bool Exists(TId id, Func performExists, Func> performGetAll);
@@ -64,7 +64,7 @@ namespace Umbraco.Cms.Core.Cache
public abstract void Delete(TEntity entity, Action persistDeleted);
///
- public abstract TEntity[] GetAll(TId[] ids, Func> performGetAll);
+ public abstract TEntity?[] GetAll(TId[] ids, Func> performGetAll);
///
public abstract void ClearAll();
diff --git a/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs b/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs
index f9cc387929..0bec8bc580 100644
--- a/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs
+++ b/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Cms.Core.Configuration
SaveJson(provider, json);
}
- public void SaveConnectionString(string connectionString, string providerName)
+ public void SaveConnectionString(string connectionString, string? providerName)
{
var provider = GetJsonConfigurationProvider();
@@ -36,7 +36,10 @@ namespace Umbraco.Cms.Core.Configuration
var item = GetConnectionItem(connectionString, providerName);
- json.Merge(item, new JsonMergeSettings());
+ if (item is not null)
+ {
+ json?.Merge(item, new JsonMergeSettings());
+ }
SaveJson(provider, json);
}
@@ -48,7 +51,7 @@ namespace Umbraco.Cms.Core.Configuration
var json = GetJson(provider);
- JToken token = json;
+ JToken? token = json;
foreach (var propertyName in key.Split(new[] { ':' }))
{
if (token is null)
@@ -62,7 +65,10 @@ namespace Umbraco.Cms.Core.Configuration
var writer = new JTokenWriter();
writer.WriteValue(value);
- token.Replace(writer.Token);
+ if (writer.Token is not null)
+ {
+ token.Replace(writer.Token);
+ }
SaveJson(provider, json);
@@ -76,7 +82,10 @@ namespace Umbraco.Cms.Core.Configuration
var item = GetDisableRedirectUrlItem(disable);
- json.Merge(item, new JsonMergeSettings());
+ if (item is not null)
+ {
+ json?.Merge(item, new JsonMergeSettings());
+ }
SaveJson(provider, json);
}
@@ -89,12 +98,15 @@ namespace Umbraco.Cms.Core.Configuration
var item = GetGlobalIdItem(id);
- json.Merge(item, new JsonMergeSettings());
+ if (item is not null)
+ {
+ json?.Merge(item, new JsonMergeSettings());
+ }
SaveJson(provider, json);
}
- private object GetGlobalIdItem(string id)
+ private object? GetGlobalIdItem(string id)
{
JTokenWriter writer = new JTokenWriter();
@@ -115,7 +127,7 @@ namespace Umbraco.Cms.Core.Configuration
return writer.Token;
}
- private JToken GetDisableRedirectUrlItem(bool value)
+ private JToken? GetDisableRedirectUrlItem(bool value)
{
JTokenWriter writer = new JTokenWriter();
@@ -136,7 +148,7 @@ namespace Umbraco.Cms.Core.Configuration
return writer.Token;
}
- private JToken GetConnectionItem(string connectionString, string providerName)
+ private JToken? GetConnectionItem(string connectionString, string? providerName)
{
JTokenWriter writer = new JTokenWriter();
@@ -151,9 +163,9 @@ namespace Umbraco.Cms.Core.Configuration
return writer.Token;
}
- private static void RemoveJsonKey(JObject json, string key)
+ private static void RemoveJsonKey(JObject? json, string key)
{
- JToken token = json;
+ JToken? token = json;
foreach (var propertyName in key.Split(new[] { ':' }))
{
token = CaseSelectPropertyValues(token, propertyName);
@@ -162,7 +174,7 @@ namespace Umbraco.Cms.Core.Configuration
token?.Parent?.Remove();
}
- private void SaveJson(JsonConfigurationProvider provider, JObject json)
+ private void SaveJson(JsonConfigurationProvider provider, JObject? json)
{
lock (_locker)
{
@@ -182,7 +194,7 @@ namespace Umbraco.Cms.Core.Configuration
}
}
- private JObject GetJson(JsonConfigurationProvider provider)
+ private JObject? GetJson(JsonConfigurationProvider provider)
{
lock (_locker)
{
@@ -198,11 +210,11 @@ namespace Umbraco.Cms.Core.Configuration
}
}
- return null;
+ return null;
}
}
- private JsonConfigurationProvider GetJsonConfigurationProvider(string requiredKey = null)
+ private JsonConfigurationProvider GetJsonConfigurationProvider(string? requiredKey = null)
{
if (_configuration is IConfigurationRoot configurationRoot)
{
@@ -227,7 +239,7 @@ namespace Umbraco.Cms.Core.Configuration
/// This method is required because keys are case insensative in IConfiguration.
/// JObject[..] do not support case insensative and JObject.Property(...) do not return a new JObject.
///
- private static JToken CaseSelectPropertyValues(JToken token, string name)
+ private static JToken? CaseSelectPropertyValues(JToken? token, string name)
{
if (token is JObject obj)
{
diff --git a/src/Umbraco.Infrastructure/Events/MigrationEventArgs.cs b/src/Umbraco.Infrastructure/Events/MigrationEventArgs.cs
index 1f326abdd6..23bfed0cd9 100644
--- a/src/Umbraco.Infrastructure/Events/MigrationEventArgs.cs
+++ b/src/Umbraco.Infrastructure/Events/MigrationEventArgs.cs
@@ -11,7 +11,7 @@ namespace Umbraco.Cms.Core.Events
: this(migrationTypes, null, configuredVersion, targetVersion, productName, canCancel)
{ }
- internal MigrationEventArgs(IList migrationTypes, IMigrationContext migrationContext, SemVersion configuredVersion, SemVersion targetVersion, string productName, bool canCancel)
+ internal MigrationEventArgs(IList migrationTypes, IMigrationContext? migrationContext, SemVersion configuredVersion, SemVersion targetVersion, string productName, bool canCancel)
: base(migrationTypes, canCancel)
{
MigrationContext = migrationContext;
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Core.Events
///
/// Returns all migrations that were used in the migration runner
///
- public IList MigrationsTypes => EventObject;
+ public IList? MigrationsTypes => EventObject;
///
/// Gets the origin version of the migration, i.e. the one that is currently installed.
@@ -48,16 +48,16 @@ namespace Umbraco.Cms.Core.Events
/// Gets the migration context.
///
/// Is only available after migrations have run, for post-migrations.
- internal IMigrationContext MigrationContext { get; }
+ internal IMigrationContext? MigrationContext { get; }
- public bool Equals(MigrationEventArgs other)
+ public bool Equals(MigrationEventArgs? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
- return base.Equals(other) && ConfiguredSemVersion.Equals(other.ConfiguredSemVersion) && MigrationContext.Equals(other.MigrationContext) && string.Equals(ProductName, other.ProductName) && TargetSemVersion.Equals(other.TargetSemVersion);
+ return base.Equals(other) && ConfiguredSemVersion.Equals(other.ConfiguredSemVersion) && (MigrationContext?.Equals(other.MigrationContext) ?? false) && string.Equals(ProductName, other.ProductName) && TargetSemVersion.Equals(other.TargetSemVersion);
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
@@ -71,7 +71,10 @@ namespace Umbraco.Cms.Core.Events
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ ConfiguredSemVersion.GetHashCode();
- hashCode = (hashCode * 397) ^ MigrationContext.GetHashCode();
+ if (MigrationContext is not null)
+ {
+ hashCode = (hashCode * 397) ^ MigrationContext.GetHashCode();
+ }
hashCode = (hashCode * 397) ^ ProductName.GetHashCode();
hashCode = (hashCode * 397) ^ TargetSemVersion.GetHashCode();
return hashCode;
diff --git a/src/Umbraco.Infrastructure/Examine/BaseValueSetBuilder.cs b/src/Umbraco.Infrastructure/Examine/BaseValueSetBuilder.cs
index 636f50c22d..ceb203c15c 100644
--- a/src/Umbraco.Infrastructure/Examine/BaseValueSetBuilder.cs
+++ b/src/Umbraco.Infrastructure/Examine/BaseValueSetBuilder.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
public abstract IEnumerable GetValueSets(params TContent[] content);
- protected void AddPropertyValue(IProperty property, string culture, string segment, IDictionary> values)
+ protected void AddPropertyValue(IProperty property, string? culture, string? segment, IDictionary>? values)
{
var editor = _propertyEditors[property.PropertyType.PropertyEditorAlias];
if (editor == null) return;
@@ -45,19 +45,19 @@ namespace Umbraco.Cms.Infrastructure.Examine
{
if (strVal.IsNullOrWhiteSpace()) continue;
var key = $"{keyVal.Key}{cultureSuffix}";
- if (values.TryGetValue(key, out var v))
- values[key] = new List
public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValidator
{
- private readonly IPublicAccessService _publicAccessService;
- private readonly IScopeProvider _scopeProvider;
+ private readonly IPublicAccessService? _publicAccessService;
+ private readonly IScopeProvider? _scopeProvider;
private const string PathKey = "path";
private static readonly IEnumerable ValidCategories = new[] { IndexTypes.Content, IndexTypes.Media };
protected override IEnumerable ValidIndexCategories => ValidCategories;
@@ -76,16 +76,16 @@ namespace Umbraco.Cms.Infrastructure.Examine
// used for tests
public ContentValueSetValidator(bool publishedValuesOnly, int? parentId = null,
- IEnumerable includeItemTypes = null, IEnumerable excludeItemTypes = null)
+ IEnumerable? includeItemTypes = null, IEnumerable? excludeItemTypes = null)
: this(publishedValuesOnly, true, null, null, parentId, includeItemTypes, excludeItemTypes)
{
}
public ContentValueSetValidator(bool publishedValuesOnly, bool supportProtectedContent,
- IPublicAccessService publicAccessService,
- IScopeProvider scopeProvider,
+ IPublicAccessService? publicAccessService,
+ IScopeProvider? scopeProvider,
int? parentId = null,
- IEnumerable includeItemTypes = null, IEnumerable excludeItemTypes = null)
+ IEnumerable? includeItemTypes = null, IEnumerable? excludeItemTypes = null)
: base(includeItemTypes, excludeItemTypes, null, null)
{
PublishedValuesOnly = publishedValuesOnly;
@@ -147,9 +147,9 @@ namespace Umbraco.Cms.Infrastructure.Examine
// We need to validate the path of the content based on ParentId, protected content and recycle bin rules.
// We cannot return FAILED here because we need the value set to get into the indexer and then deal with it from there
// because we need to remove anything that doesn't pass by protected content in the cases that umbraco data is moved to an illegal parent.
- if (!ValidatePath(path, valueSet.Category)
- || !ValidateRecycleBin(path, valueSet.Category)
- || !ValidateProtectedContent(path, valueSet.Category))
+ if (!ValidatePath(path!, valueSet.Category)
+ || !ValidateRecycleBin(path!, valueSet.Category)
+ || !ValidateProtectedContent(path!, valueSet.Category))
return ValueSetValidationResult.Filtered;
return isFiltered ? ValueSetValidationResult.Filtered : ValueSetValidationResult.Valid;
diff --git a/src/Umbraco.Infrastructure/Examine/ExamineExtensions.cs b/src/Umbraco.Infrastructure/Examine/ExamineExtensions.cs
index b2b025b5a6..8782d58835 100644
--- a/src/Umbraco.Infrastructure/Examine/ExamineExtensions.cs
+++ b/src/Umbraco.Infrastructure/Examine/ExamineExtensions.cs
@@ -66,7 +66,7 @@ namespace Umbraco.Extensions
if (int.TryParse(result.Id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var contentId) &&
result.Values.TryGetValue(ExamineFieldNames.CategoryFieldName, out var indexType))
{
- IPublishedContent content;
+ IPublishedContent? content;
switch (indexType)
{
case IndexTypes.Content:
diff --git a/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs b/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs
index 0d881888a1..1dff9bb5e1 100644
--- a/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs
+++ b/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs
@@ -194,7 +194,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
.Field("nodeType", id.ToInvariantString())
.Execute(QueryOptions.SkipTake(page * pageSize, pageSize));
total = results.TotalItemCount;
-
+
foreach (ISearchResult item in results)
{
if (int.TryParse(item.Id, NumberStyles.Integer, CultureInfo.InvariantCulture, out int contentId))
@@ -214,9 +214,9 @@ namespace Umbraco.Cms.Infrastructure.Examine
{
private readonly List _actions = new List();
- public static DeferedActions Get(IScopeProvider scopeProvider)
+ public static DeferedActions? Get(IScopeProvider scopeProvider)
{
- IScopeContext scopeContext = scopeProvider.Context;
+ IScopeContext? scopeContext = scopeProvider.Context;
return scopeContext?.Enlist("examineEvents",
() => new DeferedActions(), // creator
@@ -384,7 +384,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
{
private readonly ExamineUmbracoIndexingHandler _examineUmbracoIndexingHandler;
private readonly int _id;
- private readonly IReadOnlyCollection _ids;
+ private readonly IReadOnlyCollection? _ids;
private readonly bool _keepIfUnpublished;
public DeferedDeleteIndex(ExamineUmbracoIndexingHandler examineUmbracoIndexingHandler, int id, bool keepIfUnpublished)
diff --git a/src/Umbraco.Infrastructure/Examine/GenericIndexDiagnostics.cs b/src/Umbraco.Infrastructure/Examine/GenericIndexDiagnostics.cs
index 36d2e60acb..7bcfa2b2da 100644
--- a/src/Umbraco.Infrastructure/Examine/GenericIndexDiagnostics.cs
+++ b/src/Umbraco.Infrastructure/Examine/GenericIndexDiagnostics.cs
@@ -26,7 +26,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
public int FieldCount => -1; //unknown
- public Attempt IsHealthy()
+ public Attempt IsHealthy()
{
if (!_index.IndexExists())
return Attempt.Fail("Does not exist");
@@ -34,7 +34,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
try
{
var result = _index.Searcher.CreateQuery().ManagedQuery("test").SelectFields(_idOnlyFieldSet).Execute(new QueryOptions(0, 1));
- return Attempt.Succeed(); //if we can search we'll assume it's healthy
+ return Attempt.Succeed(); //if we can search we'll assume it's healthy
}
catch (Exception e)
{
diff --git a/src/Umbraco.Infrastructure/Examine/IBackOfficeExamineSearcher.cs b/src/Umbraco.Infrastructure/Examine/IBackOfficeExamineSearcher.cs
index dc6da46150..dc01d7bc94 100644
--- a/src/Umbraco.Infrastructure/Examine/IBackOfficeExamineSearcher.cs
+++ b/src/Umbraco.Infrastructure/Examine/IBackOfficeExamineSearcher.cs
@@ -12,6 +12,6 @@ namespace Umbraco.Cms.Infrastructure.Examine
IEnumerable Search(string query,
UmbracoEntityTypes entityType,
int pageSize,
- long pageIndex, out long totalFound, string searchFrom = null, bool ignoreUserStartNodes = false);
+ long pageIndex, out long totalFound, string? searchFrom = null, bool ignoreUserStartNodes = false);
}
}
diff --git a/src/Umbraco.Infrastructure/Examine/IIndexDiagnostics.cs b/src/Umbraco.Infrastructure/Examine/IIndexDiagnostics.cs
index 716b7731eb..2eb6ca4595 100644
--- a/src/Umbraco.Infrastructure/Examine/IIndexDiagnostics.cs
+++ b/src/Umbraco.Infrastructure/Examine/IIndexDiagnostics.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
/// A successful attempt if it is healthy, else a failed attempt with a message if unhealthy
///
- Attempt IsHealthy();
+ Attempt IsHealthy();
///
/// A key/value collection of diagnostic properties for the index
diff --git a/src/Umbraco.Infrastructure/Examine/MediaValueSetBuilder.cs b/src/Umbraco.Infrastructure/Examine/MediaValueSetBuilder.cs
index 4c745c8503..ff0c1f142c 100644
--- a/src/Umbraco.Infrastructure/Examine/MediaValueSetBuilder.cs
+++ b/src/Umbraco.Infrastructure/Examine/MediaValueSetBuilder.cs
@@ -49,11 +49,11 @@ namespace Umbraco.Cms.Infrastructure.Examine
var urlValue = m.GetUrlSegment(_shortStringHelper, _urlSegmentProviders);
- IEnumerable mediaFiles = m.GetUrls(_contentSettings, _mediaUrlGenerators)
+ IEnumerable mediaFiles = m.GetUrls(_contentSettings, _mediaUrlGenerators)
.Select(x => Path.GetFileName(x))
.Distinct();
- var values = new Dictionary>
+ var values = new Dictionary>
{
{"icon", m.ContentType.Icon?.Yield() ?? Enumerable.Empty()},
{"id", new object[] {m.Id}},
diff --git a/src/Umbraco.Infrastructure/Examine/MemberValueSetBuilder.cs b/src/Umbraco.Infrastructure/Examine/MemberValueSetBuilder.cs
index 9364ac6b94..33481c96a3 100644
--- a/src/Umbraco.Infrastructure/Examine/MemberValueSetBuilder.cs
+++ b/src/Umbraco.Infrastructure/Examine/MemberValueSetBuilder.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
{
foreach (var m in members)
{
- var values = new Dictionary>
+ var values = new Dictionary>
{
{"icon", m.ContentType.Icon?.Yield() ?? Enumerable.Empty()},
{"id", new object[] {m.Id}},
diff --git a/src/Umbraco.Infrastructure/Examine/NoopBackOfficeExamineSearcher.cs b/src/Umbraco.Infrastructure/Examine/NoopBackOfficeExamineSearcher.cs
index 8b676ab331..cb01bae57a 100644
--- a/src/Umbraco.Infrastructure/Examine/NoopBackOfficeExamineSearcher.cs
+++ b/src/Umbraco.Infrastructure/Examine/NoopBackOfficeExamineSearcher.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
public class NoopBackOfficeExamineSearcher : IBackOfficeExamineSearcher
{
public IEnumerable Search(string query, UmbracoEntityTypes entityType, int pageSize, long pageIndex, out long totalFound,
- string searchFrom = null, bool ignoreUserStartNodes = false)
+ string? searchFrom = null, bool ignoreUserStartNodes = false)
{
totalFound = 0;
return Enumerable.Empty();
diff --git a/src/Umbraco.Infrastructure/Examine/ValueSetValidator.cs b/src/Umbraco.Infrastructure/Examine/ValueSetValidator.cs
index 54eaac63df..dbe3a8ddba 100644
--- a/src/Umbraco.Infrastructure/Examine/ValueSetValidator.cs
+++ b/src/Umbraco.Infrastructure/Examine/ValueSetValidator.cs
@@ -11,10 +11,10 @@ namespace Umbraco.Cms.Infrastructure.Examine
public class ValueSetValidator : IValueSetValidator
{
public ValueSetValidator(
- IEnumerable includeItemTypes,
- IEnumerable excludeItemTypes,
- IEnumerable includeFields,
- IEnumerable excludeFields)
+ IEnumerable? includeItemTypes,
+ IEnumerable? excludeItemTypes,
+ IEnumerable? includeFields,
+ IEnumerable? excludeFields)
{
IncludeItemTypes = includeItemTypes;
ExcludeItemTypes = excludeItemTypes;
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
ValidIndexCategories = null;
}
- protected virtual IEnumerable ValidIndexCategories { get; }
+ protected virtual IEnumerable? ValidIndexCategories { get; }
///
/// Optional inclusion list of content types to index
@@ -31,7 +31,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
/// All other types will be ignored if they do not match this list
///
- public IEnumerable IncludeItemTypes { get; }
+ public IEnumerable? IncludeItemTypes { get; }
///
/// Optional exclusion list of content types to ignore
@@ -39,7 +39,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
/// Any content type alias matched in this will not be included in the index
///
- public IEnumerable ExcludeItemTypes { get; }
+ public IEnumerable? ExcludeItemTypes { get; }
///
/// Optional inclusion list of index fields to index
@@ -47,7 +47,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
/// If specified, all other fields in a will be filtered
///
- public IEnumerable IncludeFields { get; }
+ public IEnumerable? IncludeFields { get; }
///
/// Optional exclusion list of index fields
@@ -55,7 +55,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
/// If specified, all fields matching these field names will be filtered from the
///
- public IEnumerable ExcludeFields { get; }
+ public IEnumerable? ExcludeFields { get; }
public virtual ValueSetValidationResult Validate(ValueSet valueSet)
{
diff --git a/src/Umbraco.Infrastructure/Extensions/EmailMessageExtensions.cs b/src/Umbraco.Infrastructure/Extensions/EmailMessageExtensions.cs
index f7bed9d74c..8918b5f951 100644
--- a/src/Umbraco.Infrastructure/Extensions/EmailMessageExtensions.cs
+++ b/src/Umbraco.Infrastructure/Extensions/EmailMessageExtensions.cs
@@ -40,7 +40,7 @@ namespace Umbraco.Cms.Infrastructure.Extensions
builder.TextBody = mailMessage.Body;
}
- foreach (EmailMessageAttachment attachment in mailMessage.Attachments)
+ foreach (EmailMessageAttachment attachment in mailMessage.Attachments!)
{
builder.Attachments.Add(attachment.FileName, attachment.Stream);
}
@@ -55,7 +55,7 @@ namespace Umbraco.Cms.Infrastructure.Extensions
return messageToSend;
}
- private static void AddAddresses(MimeMessage message, string[] addresses, Func addressListGetter, bool throwIfNoneValid = false)
+ private static void AddAddresses(MimeMessage message, string?[]? addresses, Func addressListGetter, bool throwIfNoneValid = false)
{
var foundValid = false;
if (addresses != null)
@@ -77,13 +77,14 @@ namespace Umbraco.Cms.Infrastructure.Extensions
}
public static NotificationEmailModel ToNotificationEmail(this EmailMessage emailMessage,
- string configuredFromAddress)
+ string? configuredFromAddress)
{
var fromEmail = string.IsNullOrEmpty(emailMessage.From) ? configuredFromAddress : emailMessage.From;
- NotificationEmailAddress from = ToNotificationAddress(fromEmail);
+ NotificationEmailAddress? from = ToNotificationAddress(fromEmail);
- return new NotificationEmailModel(from,
+ return new NotificationEmailModel(
+ from,
GetNotificationAddresses(emailMessage.To),
GetNotificationAddresses(emailMessage.Cc),
GetNotificationAddresses(emailMessage.Bcc),
@@ -94,7 +95,7 @@ namespace Umbraco.Cms.Infrastructure.Extensions
emailMessage.IsBodyHtml);
}
- private static NotificationEmailAddress ToNotificationAddress(string address)
+ private static NotificationEmailAddress? ToNotificationAddress(string? address)
{
if (InternetAddress.TryParse(address, out InternetAddress internetAddress))
{
@@ -107,7 +108,7 @@ namespace Umbraco.Cms.Infrastructure.Extensions
return null;
}
- private static IEnumerable GetNotificationAddresses(IEnumerable addresses)
+ private static IEnumerable? GetNotificationAddresses(IEnumerable? addresses)
{
if (addresses is null)
{
@@ -118,7 +119,7 @@ namespace Umbraco.Cms.Infrastructure.Extensions
foreach (var address in addresses)
{
- NotificationEmailAddress notificationAddress = ToNotificationAddress(address);
+ NotificationEmailAddress? notificationAddress = ToNotificationAddress(address);
if (notificationAddress is not null)
{
notificationAddresses.Add(notificationAddress);
diff --git a/src/Umbraco.Infrastructure/Extensions/ObjectJsonExtensions.cs b/src/Umbraco.Infrastructure/Extensions/ObjectJsonExtensions.cs
index 40960cdbb7..609d8165a3 100644
--- a/src/Umbraco.Infrastructure/Extensions/ObjectJsonExtensions.cs
+++ b/src/Umbraco.Infrastructure/Extensions/ObjectJsonExtensions.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Extensions
/// The object to convert.
/// A property namer function.
/// A dictionary containing each properties.
- public static Dictionary ToObjectDictionary(T obj, Func namer = null)
+ public static Dictionary ToObjectDictionary(T obj, Func? namer = null)
{
if (obj == null) return new Dictionary();
diff --git a/src/Umbraco.Infrastructure/HostedServices/BackgroundTaskQueue.cs b/src/Umbraco.Infrastructure/HostedServices/BackgroundTaskQueue.cs
index 10823dd149..ece1827ed0 100644
--- a/src/Umbraco.Infrastructure/HostedServices/BackgroundTaskQueue.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/BackgroundTaskQueue.cs
@@ -31,10 +31,10 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
}
///
- public async Task> DequeueAsync(CancellationToken cancellationToken)
+ public async Task?> DequeueAsync(CancellationToken cancellationToken)
{
await _signal.WaitAsync(cancellationToken);
- _workItems.TryDequeue(out Func workItem);
+ _workItems.TryDequeue(out Func? workItem);
return workItem;
}
diff --git a/src/Umbraco.Infrastructure/HostedServices/ContentVersionCleanup.cs b/src/Umbraco.Infrastructure/HostedServices/ContentVersionCleanup.cs
index 5f3aba5f3f..48c7ddd57d 100644
--- a/src/Umbraco.Infrastructure/HostedServices/ContentVersionCleanup.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/ContentVersionCleanup.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
}
///
- public override Task PerformExecuteAsync(object state)
+ public override Task PerformExecuteAsync(object? state)
{
// Globally disabled by feature flag
if (!_settingsMonitor.CurrentValue.ContentVersionCleanupPolicy.EnableCleanup)
diff --git a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs
index 4b7656d20d..02f484e84a 100644
--- a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs
@@ -81,7 +81,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
});
}
- public override async Task PerformExecuteAsync(object state)
+ public override async Task PerformExecuteAsync(object? state)
{
if (_healthChecksSettings.Notification.Enabled == false)
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/IBackgroundTaskQueue.cs b/src/Umbraco.Infrastructure/HostedServices/IBackgroundTaskQueue.cs
index d5d0c07fda..4e3052dd9e 100644
--- a/src/Umbraco.Infrastructure/HostedServices/IBackgroundTaskQueue.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/IBackgroundTaskQueue.cs
@@ -20,6 +20,6 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
///
/// Dequeue the first item on the queue.
///
- Task> DequeueAsync(CancellationToken cancellationToken);
+ Task?> DequeueAsync(CancellationToken cancellationToken);
}
}
diff --git a/src/Umbraco.Infrastructure/HostedServices/KeepAlive.cs b/src/Umbraco.Infrastructure/HostedServices/KeepAlive.cs
index a27e0d9dee..9f0a82eb78 100644
--- a/src/Umbraco.Infrastructure/HostedServices/KeepAlive.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/KeepAlive.cs
@@ -61,7 +61,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
keepAliveSettings.OnChange(x => _keepAliveSettings = x);
}
- public override async Task PerformExecuteAsync(object state)
+ public override async Task PerformExecuteAsync(object? state)
{
if (_keepAliveSettings.DisableKeepAliveTask)
{
@@ -96,7 +96,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
}
// If the config is an absolute path, just use it
- string keepAlivePingUrl = WebPath.Combine(umbracoAppUrl, _hostingEnvironment.ToAbsolute(_keepAliveSettings.KeepAlivePingUrl));
+ string keepAlivePingUrl = WebPath.Combine(umbracoAppUrl!, _hostingEnvironment.ToAbsolute(_keepAliveSettings.KeepAlivePingUrl));
try
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/LogScrubber.cs b/src/Umbraco.Infrastructure/HostedServices/LogScrubber.cs
index 7c12ae39ec..31dc84d87d 100644
--- a/src/Umbraco.Infrastructure/HostedServices/LogScrubber.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/LogScrubber.cs
@@ -60,7 +60,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
settings.OnChange(x => _settings = x);
}
- public override Task PerformExecuteAsync(object state)
+ public override Task PerformExecuteAsync(object? state)
{
switch (_serverRegistrar.CurrentServerRole)
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/QueuedHostedService.cs b/src/Umbraco.Infrastructure/HostedServices/QueuedHostedService.cs
index c15a37855e..e271c98324 100644
--- a/src/Umbraco.Infrastructure/HostedServices/QueuedHostedService.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/QueuedHostedService.cs
@@ -35,11 +35,14 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
{
while (!stoppingToken.IsCancellationRequested)
{
- Func workItem = await TaskQueue.DequeueAsync(stoppingToken);
+ Func? workItem = await TaskQueue.DequeueAsync(stoppingToken);
try
{
- await workItem(stoppingToken);
+ if (workItem is not null)
+ {
+ await workItem(stoppingToken);
+ }
}
catch (Exception ex)
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs b/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs
index 2063bbc180..ad21c2982b 100644
--- a/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
private TimeSpan _period;
private readonly TimeSpan _delay;
- private Timer _timer;
+ private Timer? _timer;
///
/// Initializes a new instance of the class.
@@ -53,7 +53,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
/// Executes the task.
///
/// The task state.
- public async void ExecuteAsync(object state)
+ public async void ExecuteAsync(object? state)
{
try
{
@@ -74,7 +74,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
}
}
- public abstract Task PerformExecuteAsync(object state);
+ public abstract Task PerformExecuteAsync(object? state);
///
public Task StopAsync(CancellationToken cancellationToken)
diff --git a/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs b/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs
index 7591290bf4..753dc542b7 100644
--- a/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
{
private readonly ILogger _logger;
private readonly ITelemetryService _telemetryService;
- private static HttpClient s_httpClient;
+ private static HttpClient s_httpClient = new();
public ReportSiteTask(
ILogger logger,
@@ -43,9 +43,9 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
/// Runs the background task to send the anonymous ID
/// to telemetry service
///
- public override async Task PerformExecuteAsync(object state)
+ public override async Task PerformExecuteAsync(object? state)
{
- if (_telemetryService.TryGetTelemetryReportData(out TelemetryReportData telemetryReportData) is false)
+ if (_telemetryService.TryGetTelemetryReportData(out TelemetryReportData? telemetryReportData) is false)
{
_logger.LogWarning("No telemetry marker found");
diff --git a/src/Umbraco.Infrastructure/HostedServices/ScheduledPublishing.cs b/src/Umbraco.Infrastructure/HostedServices/ScheduledPublishing.cs
index d59ea4fad3..d806bab5ad 100644
--- a/src/Umbraco.Infrastructure/HostedServices/ScheduledPublishing.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/ScheduledPublishing.cs
@@ -60,7 +60,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
_serverMessenger = serverMessenger;
}
- public override Task PerformExecuteAsync(object state)
+ public override Task PerformExecuteAsync(object? state)
{
if (Suspendable.ScheduledPublishing.CanRun == false)
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/InstructionProcessTask.cs b/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/InstructionProcessTask.cs
index 57354aafdb..54214ba08c 100644
--- a/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/InstructionProcessTask.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/InstructionProcessTask.cs
@@ -36,7 +36,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices.ServerRegistration
_logger = logger;
}
- public override Task PerformExecuteAsync(object state)
+ public override Task PerformExecuteAsync(object? state)
{
if (_runtimeState.Level != RuntimeLevel.Run)
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs b/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs
index 0b631bfaa8..a51f1eb95b 100644
--- a/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs
@@ -59,7 +59,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices.ServerRegistration
_serverRoleAccessor = serverRoleAccessor;
}
- public override Task PerformExecuteAsync(object state)
+ public override Task PerformExecuteAsync(object? state)
{
if (_runtimeState.Level != RuntimeLevel.Run)
{
@@ -83,7 +83,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices.ServerRegistration
try
{
- _serverRegistrationService.TouchServer(serverAddress, _globalSettings.DatabaseServerRegistrar.StaleServerTimeout);
+ _serverRegistrationService.TouchServer(serverAddress!, _globalSettings.DatabaseServerRegistrar.StaleServerTimeout);
}
catch (Exception ex)
{
diff --git a/src/Umbraco.Infrastructure/HostedServices/TempFileCleanup.cs b/src/Umbraco.Infrastructure/HostedServices/TempFileCleanup.cs
index e59cca5fbd..fb70ce39f7 100644
--- a/src/Umbraco.Infrastructure/HostedServices/TempFileCleanup.cs
+++ b/src/Umbraco.Infrastructure/HostedServices/TempFileCleanup.cs
@@ -42,7 +42,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
_tempFolders = _ioHelper.GetTempFolders();
}
- public override Task PerformExecuteAsync(object state)
+ public override Task PerformExecuteAsync(object? state)
{
// Ensure we do not run if not main domain
if (_mainDom.IsMainDom == false)
@@ -68,7 +68,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
_logger.LogDebug("The cleanup folder doesn't exist {Folder}", folder.FullName);
break;
case CleanFolderResultStatus.FailedWithException:
- foreach (CleanFolderResult.Error error in result.Errors)
+ foreach (CleanFolderResult.Error error in result.Errors!)
{
_logger.LogError(error.Exception, "Could not delete temp file {FileName}", error.ErroringFile.FullName);
}
diff --git a/src/Umbraco.Infrastructure/IPublishedContentQuery.cs b/src/Umbraco.Infrastructure/IPublishedContentQuery.cs
index 77ca873638..5b17af02cd 100644
--- a/src/Umbraco.Infrastructure/IPublishedContentQuery.cs
+++ b/src/Umbraco.Infrastructure/IPublishedContentQuery.cs
@@ -56,7 +56,7 @@ namespace Umbraco.Cms.Core
///
/// While enumerating results, the ambient culture is changed to be the searched culture.
///
- IEnumerable Search(string term, int skip, int take, out long totalRecords, string culture = "*", string indexName = Constants.UmbracoIndexes.ExternalIndexName, ISet loadedFields = null);
+ IEnumerable Search(string term, int skip, int take, out long totalRecords, string culture = "*", string indexName = Constants.UmbracoIndexes.ExternalIndexName, ISet? loadedFields = null);
///
/// Searches content.
diff --git a/src/Umbraco.Infrastructure/Install/FilePermissionHelper.cs b/src/Umbraco.Infrastructure/Install/FilePermissionHelper.cs
index 1d228ebf98..0324595133 100644
--- a/src/Umbraco.Infrastructure/Install/FilePermissionHelper.cs
+++ b/src/Umbraco.Infrastructure/Install/FilePermissionHelper.cs
@@ -78,7 +78,7 @@ namespace Umbraco.Cms.Infrastructure.Install
private bool EnsureDirectories(string[] dirs, out IEnumerable errors, bool writeCausesRestart = false)
{
- List temp = null;
+ List? temp = null;
var success = true;
foreach (var dir in dirs)
{
@@ -99,13 +99,13 @@ namespace Umbraco.Cms.Infrastructure.Install
success = false;
}
- errors = success ? Enumerable.Empty() : temp;
+ errors = success ? Enumerable.Empty() : temp ?? Enumerable.Empty();
return success;
}
private bool EnsureFiles(string[] files, out IEnumerable errors)
{
- List temp = null;
+ List? temp = null;
var success = true;
foreach (var file in files)
{
@@ -124,7 +124,7 @@ namespace Umbraco.Cms.Infrastructure.Install
success = false;
}
- errors = success ? Enumerable.Empty() : temp;
+ errors = success ? Enumerable.Empty() : temp ?? Enumerable.Empty();
return success;
}
@@ -133,7 +133,7 @@ namespace Umbraco.Cms.Infrastructure.Install
private bool EnsureCanCreateSubDirectories(IEnumerable dirs, out IEnumerable errors)
{
- List temp = null;
+ List? temp = null;
var success = true;
foreach (var dir in dirs)
{
@@ -152,7 +152,7 @@ namespace Umbraco.Cms.Infrastructure.Install
success = false;
}
- errors = success ? Enumerable.Empty() : temp;
+ errors = success ? Enumerable.Empty() : temp ?? Enumerable.Empty();
return success;
}
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/CompleteInstallStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/CompleteInstallStep.cs
index a819306ae9..0666a3eee5 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/CompleteInstallStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/CompleteInstallStep.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
_installHelper = installHelper;
}
- public override async Task ExecuteAsync(object model)
+ public override async Task ExecuteAsync(object model)
{
//reports the ended install
await _installHelper.SetInstallStatusAsync(true, "");
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs
index a25151bda2..d211253ae2 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs
@@ -29,7 +29,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
_logger = logger;
}
- public override Task ExecuteAsync(DatabaseModel database)
+ public override Task ExecuteAsync(DatabaseModel database)
{
//if the database model is null then we will apply the defaults
if (database == null)
@@ -53,14 +53,14 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
ConfigureConnection(database);
- return Task.FromResult(null);
+ return Task.FromResult(null);
}
private void ConfigureConnection(DatabaseModel database)
{
if (database.ConnectionString.IsNullOrWhiteSpace() == false)
{
- _databaseBuilder.ConfigureDatabaseConnection(database.ConnectionString);
+ _databaseBuilder.ConfigureDatabaseConnection(database.ConnectionString!);
}
else if (database.DatabaseType == DatabaseType.SqlLocalDb)
{
@@ -76,7 +76,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
}
else
{
- var password = database.Password.Replace("'", "''");
+ var password = database.Password?.Replace("'", "''");
password = string.Format("'{0}'", password);
_databaseBuilder.ConfigureDatabaseConnection(database.Server, database.DatabaseName, database.Login, password, database.DatabaseType.ToString());
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs
index 96d2a7c996..5962638d57 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseInstallStep.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
_databaseBuilder = databaseBuilder;
}
- public override Task ExecuteAsync(object model)
+ public override Task ExecuteAsync(object model)
{
if (_runtime.Level == RuntimeLevel.Run)
throw new Exception("Umbraco is already configured!");
@@ -40,14 +40,14 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
if (result.RequiresUpgrade == false)
{
- return Task.FromResult(null);
+ return Task.FromResult(null);
}
// Upgrade is required, so set the flag for the next step
return Task.FromResult(new InstallSetupResult(new Dictionary
{
{ "upgrade", true}
- }));
+ }))!;
}
public override bool RequiresExecution(object model) => true;
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs
index 929b448286..d50624d0c2 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs
@@ -40,7 +40,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
_connectionStrings = connectionStrings;
}
- public override Task ExecuteAsync(object model)
+ public override Task ExecuteAsync(object model)
{
var installSteps = InstallStatusTracker.GetStatus().ToArray();
var previousStep = installSteps.Single(x => x.Name == "DatabaseInstall");
@@ -61,7 +61,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
}
}
- return Task.FromResult((InstallSetupResult)null);
+ return Task.FromResult((InstallSetupResult?)null);
}
public override bool RequiresExecution(object model)
diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs
index 4ef8fa4e28..17ae1de634 100644
--- a/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs
+++ b/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs
@@ -60,7 +60,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
_dbProviderFactoryCreator = dbProviderFactoryCreator ?? throw new ArgumentNullException(nameof(dbProviderFactoryCreator));
}
- public override async Task ExecuteAsync(UserModel user)
+ public override async Task ExecuteAsync(UserModel user)
{
var admin = _userService.GetUserById(Constants.Security.SuperUserId);
if (admin == null)
@@ -68,7 +68,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
throw new InvalidOperationException("Could not find the super user!");
}
admin.Email = user.Email.Trim();
- admin.Name = user.Name.Trim();
+ admin.Name = user.Name?.Trim();
admin.Username = user.Email.Trim();
_userService.Save(admin);
@@ -150,7 +150,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
installState = (installState | InstallState.HasConnectionString) & ~InstallState.Unknown;
}
- var connStringConfigured = databaseSettings.IsConnectionStringConfigured();
+ var connStringConfigured = databaseSettings?.IsConnectionStringConfigured() ?? false;
if (connStringConfigured)
{
installState = (installState | InstallState.ConnectionStringConfigured) & ~InstallState.Unknown;
@@ -158,7 +158,7 @@ namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
var factory = _dbProviderFactoryCreator.CreateFactory(databaseSettings?.ProviderName);
- var canConnect = connStringConfigured && DbConnectionExtensions.IsConnectionAvailable(databaseSettings.ConnectionString, factory);
+ var canConnect = connStringConfigured && DbConnectionExtensions.IsConnectionAvailable(databaseSettings?.ConnectionString, factory);
if (canConnect)
{
installState = (installState | InstallState.CanConnect) & ~InstallState.Unknown;
diff --git a/src/Umbraco.Infrastructure/Install/PackageMigrationRunner.cs b/src/Umbraco.Infrastructure/Install/PackageMigrationRunner.cs
index 54448c68c0..6580bc8596 100644
--- a/src/Umbraco.Infrastructure/Install/PackageMigrationRunner.cs
+++ b/src/Umbraco.Infrastructure/Install/PackageMigrationRunner.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Cms.Infrastructure.Install
_migrationPlanExecutor = migrationPlanExecutor;
_keyValueService = keyValueService;
_eventAggregator = eventAggregator;
- _packageMigrationPlans = packageMigrationPlans.ToDictionary(x => x.Name);
+ _packageMigrationPlans = packageMigrationPlans.ToDictionary(x => x.Name);
}
///
@@ -83,7 +83,7 @@ namespace Umbraco.Cms.Infrastructure.Install
{
foreach (var migrationName in plansToRun)
{
- if (!_packageMigrationPlans.TryGetValue(migrationName, out PackageMigrationPlan plan))
+ if (!_packageMigrationPlans.TryGetValue(migrationName, out PackageMigrationPlan? plan))
{
throw new InvalidOperationException("Cannot find package migration plan " + migrationName);
}
diff --git a/src/Umbraco.Infrastructure/Install/UnattendedInstaller.cs b/src/Umbraco.Infrastructure/Install/UnattendedInstaller.cs
index 94a6646086..5f9b438f2f 100644
--- a/src/Umbraco.Infrastructure/Install/UnattendedInstaller.cs
+++ b/src/Umbraco.Infrastructure/Install/UnattendedInstaller.cs
@@ -94,7 +94,7 @@ namespace Umbraco.Cms.Infrastructure.Install
return Task.CompletedTask;
}
- IUmbracoDatabase database = null;
+ IUmbracoDatabase? database = null;
try
{
using (database = _databaseFactory.CreateDatabase())
diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/ThreadAbortExceptionEnricher.cs b/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/ThreadAbortExceptionEnricher.cs
index d0de79931b..bfe7c4172b 100644
--- a/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/ThreadAbortExceptionEnricher.cs
+++ b/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/ThreadAbortExceptionEnricher.cs
@@ -84,7 +84,7 @@ namespace Umbraco.Cms.Core.Logging.Serilog.Enrichers
var timeoutField = stateType.GetField("_timeout", BindingFlags.Instance | BindingFlags.NonPublic);
if (timeoutField == null) return false;
- return (bool)timeoutField.GetValue(abort.ExceptionState);
+ return (bool?)timeoutField.GetValue(abort.ExceptionState) ?? false;
}
private static bool IsMonitorEnterThreadAbortException(Exception exception)
@@ -92,7 +92,7 @@ namespace Umbraco.Cms.Core.Logging.Serilog.Enrichers
if (!(exception is ThreadAbortException abort)) return false;
var stacktrace = abort.StackTrace;
- return stacktrace.Contains("System.Threading.Monitor.ReliableEnter");
+ return stacktrace?.Contains("System.Threading.Monitor.ReliableEnter") ?? false;
}
diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
index c4e8484307..80cbfc28d3 100644
--- a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
+++ b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs
@@ -111,15 +111,15 @@ namespace Umbraco.Extensions
///
public static LoggerConfiguration UmbracoFile(this LoggerSinkConfiguration configuration,
string path,
- ITextFormatter formatter = null,
+ ITextFormatter? formatter = null,
LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose,
- LoggingLevelSwitch levelSwitch = null,
+ LoggingLevelSwitch? levelSwitch = null,
long? fileSizeLimitBytes = 1073741824,
TimeSpan? flushToDiskInterval = null,
RollingInterval rollingInterval = RollingInterval.Day,
bool rollOnFileSizeLimit = false,
int? retainedFileCountLimit = 31,
- Encoding encoding = null
+ Encoding? encoding = null
)
{
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/ExpressionFilter.cs b/src/Umbraco.Infrastructure/Logging/Viewer/ExpressionFilter.cs
index 7327262ec5..ddf18a12ce 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/ExpressionFilter.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/ExpressionFilter.cs
@@ -9,12 +9,12 @@ namespace Umbraco.Cms.Core.Logging.Viewer
//Log Expression Filters (pass in filter exp string)
internal class ExpressionFilter : ILogFilter
{
- private readonly Func _filter;
+ private readonly Func? _filter;
private const string ExpressionOperators = "()+=*<>%-";
- public ExpressionFilter(string filterExpression)
+ public ExpressionFilter(string? filterExpression)
{
- Func filter;
+ Func? filter;
if (string.IsNullOrEmpty(filterExpression))
{
@@ -48,7 +48,7 @@ namespace Umbraco.Cms.Core.Logging.Viewer
return _filter == null || _filter(e);
}
- private Func PerformMessageLikeFilter(string filterExpression)
+ private Func? PerformMessageLikeFilter(string filterExpression)
{
var filterSearch = $"@Message like '%{FilterLanguage.EscapeLikeExpressionContent(filterExpression)}%'";
if (FilterLanguage.TryCreateFilter(filterSearch, out var eval, out _))
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/ILogLevelLoader.cs b/src/Umbraco.Infrastructure/Logging/Viewer/ILogLevelLoader.cs
index 705e283ed9..1566b96282 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/ILogLevelLoader.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/ILogLevelLoader.cs
@@ -8,11 +8,11 @@ namespace Umbraco.Cms.Core.Logging.Viewer
///
/// Get the Serilog level values of the global minimum and the UmbracoFile one from the config file.
///
- ReadOnlyDictionary GetLogLevelsFromSinks();
+ ReadOnlyDictionary GetLogLevelsFromSinks();
///
/// Get the Serilog minimum-level value from the config file.
///
- LogEventLevel GetGlobalMinLogLevel();
+ LogEventLevel? GetGlobalMinLogLevel();
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs b/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs
index 4fed8ca9ab..1dfa0eda4c 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs
@@ -57,8 +57,8 @@ namespace Umbraco.Cms.Core.Logging.Viewer
int pageNumber = 1,
int pageSize = 100,
Direction orderDirection = Direction.Descending,
- string filterExpression = null,
- string[] logLevels = null);
+ string? filterExpression = null,
+ string[]? logLevels = null);
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/LogLevelLoader.cs b/src/Umbraco.Infrastructure/Logging/Viewer/LogLevelLoader.cs
index b090ddb77c..37c7923cca 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/LogLevelLoader.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/LogLevelLoader.cs
@@ -18,24 +18,24 @@ namespace Umbraco.Cms.Core.Logging.Viewer
///
/// Get the Serilog level values of the global minimum and the UmbracoFile one from the config file.
///
- public ReadOnlyDictionary GetLogLevelsFromSinks()
+ public ReadOnlyDictionary GetLogLevelsFromSinks()
{
- var configuredLogLevels = new Dictionary
+ var configuredLogLevels = new Dictionary
{
{ "Global", GetGlobalMinLogLevel() },
{ "UmbracoFile", _umbracoFileConfig.RestrictedToMinimumLevel }
};
- return new ReadOnlyDictionary(configuredLogLevels);
+ return new ReadOnlyDictionary(configuredLogLevels);
}
///
/// Get the Serilog minimum-level value from the config file.
///
- public LogEventLevel GetGlobalMinLogLevel()
+ public LogEventLevel? GetGlobalMinLogLevel()
{
var logLevel = Enum.GetValues(typeof(LogEventLevel)).Cast().Where(Log.IsEnabled).DefaultIfEmpty(LogEventLevel.Information)?.Min() ?? null;
- return (LogEventLevel)logLevel;
+ return (LogEventLevel?)logLevel;
}
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/LogMessage.cs b/src/Umbraco.Infrastructure/Logging/Viewer/LogMessage.cs
index e55f1605fb..12224c2af3 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/LogMessage.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/LogMessage.cs
@@ -38,6 +38,6 @@ namespace Umbraco.Cms.Core.Logging.Viewer
///
/// An exception associated with the log event, or null.
///
- public string Exception { get; set; }
+ public string? Exception { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/SavedLogSearch.cs b/src/Umbraco.Infrastructure/Logging/Viewer/SavedLogSearch.cs
index b01dad251d..adbd1a6431 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/SavedLogSearch.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/SavedLogSearch.cs
@@ -5,9 +5,9 @@ namespace Umbraco.Cms.Core.Logging.Viewer
public class SavedLogSearch
{
[JsonProperty("name")]
- public string Name { get; set; }
+ public string? Name { get; set; }
[JsonProperty("query")]
- public string Query { get; set; }
+ public string? Query { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogJsonLogViewer.cs b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogJsonLogViewer.cs
index d52d455fbc..ba148a1bda 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogJsonLogViewer.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogJsonLogViewer.cs
@@ -120,7 +120,7 @@ namespace Umbraco.Cms.Core.Logging.Viewer
return logs;
}
- private bool TryRead(LogEventReader reader, out LogEvent evt)
+ private bool TryRead(LogEventReader reader, out LogEvent? evt)
{
try
{
diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs
index eafe4d1787..4f7d1a3c7f 100644
--- a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs
+++ b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs
@@ -59,7 +59,7 @@ namespace Umbraco.Cms.Core.Logging.Viewer
///
/// Get the Serilog minimum-level and UmbracoFile-level values from the config file.
///
- public ReadOnlyDictionary GetLogLevels()
+ public ReadOnlyDictionary GetLogLevels()
{
return _logLevelLoader.GetLogLevelsFromSinks();
}
@@ -96,8 +96,8 @@ namespace Umbraco.Cms.Core.Logging.Viewer
public PagedResult GetLogs(LogTimePeriod logTimePeriod,
int pageNumber = 1, int pageSize = 100,
Direction orderDirection = Direction.Descending,
- string filterExpression = null,
- string[] logLevels = null)
+ string? filterExpression = null,
+ string[]? logLevels = null)
{
var expression = new ExpressionFilter(filterExpression);
var filteredLogs = GetLogs(logTimePeriod, expression, 0, int.MaxValue);
diff --git a/src/Umbraco.Infrastructure/Mail/EmailSender.cs b/src/Umbraco.Infrastructure/Mail/EmailSender.cs
index 22d8bec680..6f94942aed 100644
--- a/src/Umbraco.Infrastructure/Mail/EmailSender.cs
+++ b/src/Umbraco.Infrastructure/Mail/EmailSender.cs
@@ -41,8 +41,8 @@ namespace Umbraco.Cms.Infrastructure.Mail
ILogger logger,
IOptionsMonitor globalSettings,
IEventAggregator eventAggregator,
- INotificationHandler handler1,
- INotificationAsyncHandler handler2)
+ INotificationHandler? handler1,
+ INotificationAsyncHandler? handler2)
{
_logger = logger;
_eventAggregator = eventAggregator;
@@ -84,10 +84,10 @@ namespace Umbraco.Cms.Infrastructure.Mail
if (_globalSettings.IsPickupDirectoryLocationConfigured && !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.From))
{
- // The following code snippet is the recommended way to handle PickupDirectoryLocation.
+ // The following code snippet is the recommended way to handle PickupDirectoryLocation.
// See more https://github.com/jstedfast/MailKit/blob/master/FAQ.md#q-how-can-i-send-email-to-a-specifiedpickupdirectory
do {
- var path = Path.Combine(_globalSettings.Smtp?.PickupDirectoryLocation, Guid.NewGuid () + ".eml");
+ var path = Path.Combine(_globalSettings.Smtp.PickupDirectoryLocation!, Guid.NewGuid () + ".eml");
Stream stream;
try
@@ -112,7 +112,7 @@ namespace Umbraco.Cms.Infrastructure.Mail
FormatOptions options = FormatOptions.Default.Clone();
options.NewLineFormat = NewLineFormat.Dos;
- await message.ToMimeMessage(_globalSettings.Smtp?.From).WriteToAsync(options, filtered);
+ await message.ToMimeMessage(_globalSettings.Smtp.From).WriteToAsync(options, filtered);
filtered.Flush();
return;
@@ -126,7 +126,7 @@ namespace Umbraco.Cms.Infrastructure.Mail
using var client = new SmtpClient();
- await client.ConnectAsync(_globalSettings.Smtp.Host,
+ await client.ConnectAsync(_globalSettings.Smtp!.Host,
_globalSettings.Smtp.Port,
(MailKit.Security.SecureSocketOptions)(int)_globalSettings.Smtp.SecureSocketOptions);
@@ -159,4 +159,4 @@ namespace Umbraco.Cms.Infrastructure.Mail
|| _globalSettings.IsPickupDirectoryLocationConfigured
|| _notificationHandlerRegistered;
}
-}
\ No newline at end of file
+}
diff --git a/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs b/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs
index 3ef5d443e4..aa10cd6943 100644
--- a/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs
+++ b/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs
@@ -102,11 +102,11 @@ namespace Umbraco.Cms.Core.Manifest
// }
// and we need to turn this into a list of IPropertyValidator
// so, rewrite the json structure accordingly
- if (jobject["editor"]["validation"] is JObject validation)
- jobject["editor"]["validation"] = RewriteValidators(validation);
+ if (jobject["editor"]?["validation"] is JObject validation)
+ jobject["editor"]!["validation"] = RewriteValidators(validation);
- if(jobject["editor"]["view"] is JValue view)
- jobject["editor"]["view"] = RewriteVirtualUrl(view);
+ if(jobject["editor"]?["view"] is JValue view)
+ jobject["editor"]!["view"] = RewriteVirtualUrl(view);
var prevalues = jobject["prevalues"] as JObject;
var defaultConfig = jobject["defaultConfig"] as JObject;
@@ -150,7 +150,7 @@ namespace Umbraco.Cms.Core.Manifest
}
}
- private string RewriteVirtualUrl(JValue view)
+ private string? RewriteVirtualUrl(JValue view)
{
return _ioHelper.ResolveRelativeOrVirtualUrl(view.Value as string);
}
@@ -176,7 +176,7 @@ namespace Umbraco.Cms.Core.Manifest
// move the 'view' property
jobject["editor"] = new JObject { ["view"] = jobject["view"] };
- jobject.Property("view").Remove();
+ jobject.Property("view")?.Remove();
}
// in the manifest, default configuration is named 'config', rename
@@ -187,7 +187,7 @@ namespace Umbraco.Cms.Core.Manifest
}
if(jobject["editor"]?["view"] is JValue view) // We need to null check, if view do not exists, then editor do not exists
- jobject["editor"]["view"] = RewriteVirtualUrl(view);
+ jobject["editor"]!["view"] = RewriteVirtualUrl(view);
}
private static JArray RewriteValidators(JObject validation)
diff --git a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs
index cf74bda50a..b156597d3a 100644
--- a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs
+++ b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs
@@ -87,7 +87,7 @@ namespace Umbraco.Cms.Core.Manifest
/// Gets all manifests, merged into a single manifest object.
///
///
- public CompositePackageManifest CombinedManifest
+ public CompositePackageManifest? CombinedManifest
=> _cache.GetCacheItem("Umbraco.Core.Manifest.ManifestParser::Manifests", () =>
{
IEnumerable manifests = GetManifests();
@@ -146,7 +146,7 @@ namespace Umbraco.Cms.Core.Manifest
{
if (manifest.Scripts != null)
{
- if (!scripts.TryGetValue(manifest.BundleOptions, out List scriptsPerBundleOption))
+ if (!scripts.TryGetValue(manifest.BundleOptions, out List? scriptsPerBundleOption))
{
scriptsPerBundleOption = new List();
scripts[manifest.BundleOptions] = scriptsPerBundleOption;
@@ -156,7 +156,7 @@ namespace Umbraco.Cms.Core.Manifest
if (manifest.Stylesheets != null)
{
- if (!stylesheets.TryGetValue(manifest.BundleOptions, out List stylesPerBundleOption))
+ if (!stylesheets.TryGetValue(manifest.BundleOptions, out List? stylesPerBundleOption))
{
stylesPerBundleOption = new List();
stylesheets[manifest.BundleOptions] = stylesPerBundleOption;
@@ -169,7 +169,7 @@ namespace Umbraco.Cms.Core.Manifest
if (manifest.GridEditors != null) gridEditors.AddRange(manifest.GridEditors);
if (manifest.ContentApps != null) contentApps.AddRange(manifest.ContentApps);
if (manifest.Dashboards != null) dashboards.AddRange(manifest.Dashboards);
- if (manifest.Sections != null) sections.AddRange(manifest.Sections.LegacyDistinctBy(x => x.Alias.ToLowerInvariant()));
+ if (manifest.Sections != null) sections.AddRange(manifest.Sections.LegacyDistinctBy(x => x!.Alias.ToLowerInvariant()));
}
return new CompositePackageManifest(
@@ -217,17 +217,17 @@ namespace Umbraco.Cms.Core.Manifest
new DashboardAccessRuleConverter());
// scripts and stylesheets are raw string, must process here
- for (var i = 0; i < manifest.Scripts.Length; i++)
- manifest.Scripts[i] = _ioHelper.ResolveRelativeOrVirtualUrl(manifest.Scripts[i]);
+ for (var i = 0; i < manifest!.Scripts.Length; i++)
+ manifest.Scripts[i] = _ioHelper.ResolveRelativeOrVirtualUrl(manifest.Scripts[i])!;
for (var i = 0; i < manifest.Stylesheets.Length; i++)
- manifest.Stylesheets[i] = _ioHelper.ResolveRelativeOrVirtualUrl(manifest.Stylesheets[i]);
+ manifest.Stylesheets[i] = _ioHelper.ResolveRelativeOrVirtualUrl(manifest.Stylesheets[i])!;
foreach (var contentApp in manifest.ContentApps)
{
contentApp.View = _ioHelper.ResolveRelativeOrVirtualUrl(contentApp.View);
}
foreach (var dashboard in manifest.Dashboards)
{
- dashboard.View = _ioHelper.ResolveRelativeOrVirtualUrl(dashboard.View);
+ dashboard.View = _ioHelper.ResolveRelativeOrVirtualUrl(dashboard.View)!;
}
foreach (var gridEditor in manifest.GridEditors)
{
diff --git a/src/Umbraco.Infrastructure/Manifest/ValueValidatorConverter.cs b/src/Umbraco.Infrastructure/Manifest/ValueValidatorConverter.cs
index 01fc43738d..6d6483a8bb 100644
--- a/src/Umbraco.Infrastructure/Manifest/ValueValidatorConverter.cs
+++ b/src/Umbraco.Infrastructure/Manifest/ValueValidatorConverter.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Cms.Core.Manifest
protected override IValueValidator Create(Type objectType, string path, JObject jObject)
{
- var type = jObject["type"].Value();
+ var type = jObject["type"]?.Value();
if (string.IsNullOrWhiteSpace(type))
throw new InvalidOperationException("Could not get the type of the validator.");
diff --git a/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs b/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs
index 9710c47987..249b01f60f 100644
--- a/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs
+++ b/src/Umbraco.Infrastructure/Mapping/UmbracoMapper.cs
@@ -133,7 +133,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The target type.
/// The source object.
/// The target object.
- public TTarget Map(object source)
+ public TTarget? Map(object source)
=> Map(source, new MapperContext(this));
///
@@ -143,7 +143,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context preparation method.
/// The target object.
- public TTarget Map(object source, Action f)
+ public TTarget? Map(object source, Action f)
{
var context = new MapperContext(this);
f(context);
@@ -157,7 +157,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context.
/// The target object.
- public TTarget Map(object source, MapperContext context)
+ public TTarget? Map(object source, MapperContext context)
=> Map(source, source?.GetType(), context);
///
@@ -167,7 +167,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The target type.
/// The source object.
/// The target object.
- public TTarget Map(TSource source)
+ public TTarget? Map(TSource source)
=> Map(source, new MapperContext(this));
///
@@ -178,7 +178,7 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context preparation method.
/// The target object.
- public TTarget Map(TSource source, Action f)
+ public TTarget? Map(TSource source, Action f)
{
var context = new MapperContext(this);
f(context);
@@ -193,10 +193,10 @@ namespace Umbraco.Cms.Core.Mapping
/// The source object.
/// A mapper context.
/// The target object.
- public TTarget Map(TSource source, MapperContext context)
+ public TTarget? Map(TSource? source, MapperContext context)
=> Map(source, typeof(TSource), context);
- private TTarget Map(object source, Type sourceType, MapperContext context)
+ private TTarget? Map(object? source, Type? sourceType, MapperContext context)
{
if (source == null)
return default;
@@ -340,7 +340,7 @@ namespace Umbraco.Cms.Core.Mapping
throw new InvalidOperationException($"Don't know how to map {typeof(TSource).FullName} to {typeof(TTarget).FullName}.");
}
- private Func GetCtor(Type sourceType, Type targetType)
+ private Func? GetCtor(Type sourceType, Type targetType)
{
if (_ctors.TryGetValue(sourceType, out var sourceCtor) && sourceCtor.TryGetValue(targetType, out var ctor))
return ctor;
diff --git a/src/Umbraco.Infrastructure/Media/ImageSharpDimensionExtractor.cs b/src/Umbraco.Infrastructure/Media/ImageSharpDimensionExtractor.cs
index 227d9a653c..822c639064 100644
--- a/src/Umbraco.Infrastructure/Media/ImageSharpDimensionExtractor.cs
+++ b/src/Umbraco.Infrastructure/Media/ImageSharpDimensionExtractor.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Infrastructure.Media
///
/// The dimension of the image.
///
- public Size? GetDimensions(Stream stream)
+ public Size? GetDimensions(Stream? stream)
{
Size? size = null;
diff --git a/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs b/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
index 2b68e4dde0..cfca16601e 100644
--- a/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
+++ b/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
@@ -36,7 +36,7 @@ namespace Umbraco.Cms.Infrastructure.Media
internal ImageSharpImageUrlGenerator(IEnumerable supportedImageFileTypes) => SupportedImageFileTypes = supportedImageFileTypes;
///
- public string GetImageUrl(ImageUrlGenerationOptions options)
+ public string? GetImageUrl(ImageUrlGenerationOptions options)
{
if (options == null)
{
diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
index f863aa0d78..d84aa51d9b 100644
--- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
+++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
@@ -83,7 +83,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
///
/// Verifies whether a it is possible to connect to a database.
///
- public bool CanConnect(string databaseType, string connectionString, string server, string database, string login, string password, bool integratedAuth)
+ public bool CanConnect(string databaseType, string? connectionString, string server, string database, string login, string password, bool integratedAuth)
{
// we do not test SqlCE or LocalDB connections
if (databaseType.InvariantContains("SqlCe") || databaseType.InvariantContains("SqlLocalDb"))
diff --git a/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorData.cs b/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorData.cs
index 164f554832..e2eece8313 100644
--- a/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorData.cs
+++ b/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorData.cs
@@ -15,6 +15,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
private BlockEditorData()
{
+ _propertyEditorAlias = string.Empty;
BlockValue = new BlockValue();
}
@@ -32,7 +33,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
///
/// Returns the layout for this specific property editor
///
- public JToken Layout => BlockValue.Layout.TryGetValue(_propertyEditorAlias, out var layout) ? layout : null;
+ public JToken? Layout => BlockValue.Layout.TryGetValue(_propertyEditorAlias, out var layout) ? layout : null;
///
/// Returns the reference to the original BlockValue
diff --git a/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorDataConverter.cs b/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorDataConverter.cs
index 838821b563..0389603ac2 100644
--- a/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorDataConverter.cs
+++ b/src/Umbraco.Infrastructure/Models/Blocks/BlockEditorDataConverter.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -23,7 +24,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
return Convert(value);
}
- public bool TryDeserialize(string json, out BlockEditorData blockEditorData)
+ public bool TryDeserialize(string json, [MaybeNullWhen(false)] out BlockEditorData blockEditorData)
{
try
{
@@ -44,16 +45,16 @@ namespace Umbraco.Cms.Core.Models.Blocks
return Convert(value);
}
- private BlockEditorData Convert(BlockValue value)
+ private BlockEditorData Convert(BlockValue? value)
{
- if (value.Layout == null)
+ if (value?.Layout == null)
return BlockEditorData.Empty;
var references = value.Layout.TryGetValue(_propertyEditorAlias, out var layout)
? GetBlockReferences(layout)
: Enumerable.Empty();
- return new BlockEditorData(_propertyEditorAlias, references, value);
+ return new BlockEditorData(_propertyEditorAlias, references!, value);
}
///
@@ -61,7 +62,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
///
///
///
- protected abstract IEnumerable GetBlockReferences(JToken jsonLayout);
+ protected abstract IEnumerable? GetBlockReferences(JToken jsonLayout);
}
}
diff --git a/src/Umbraco.Infrastructure/Models/Blocks/BlockItemData.cs b/src/Umbraco.Infrastructure/Models/Blocks/BlockItemData.cs
index 5771f8c0eb..1cd35e7e79 100644
--- a/src/Umbraco.Infrastructure/Models/Blocks/BlockItemData.cs
+++ b/src/Umbraco.Infrastructure/Models/Blocks/BlockItemData.cs
@@ -17,14 +17,14 @@ namespace Umbraco.Cms.Core.Models.Blocks
/// not serialized, manually set and used during internally
///
[JsonIgnore]
- public string ContentTypeAlias { get; set; }
+ public string? ContentTypeAlias { get; set; }
[JsonProperty("udi")]
[JsonConverter(typeof(UdiJsonConverter))]
- public Udi Udi { get; set; }
+ public Udi? Udi { get; set; }
[JsonIgnore]
- public Guid Key => Udi != null ? ((GuidUdi)Udi).Guid : throw new InvalidOperationException("No Udi assigned");
+ public Guid Key => Udi is not null ? ((GuidUdi)Udi).Guid : throw new InvalidOperationException("No Udi assigned");
///
/// The remaining properties will be serialized to a dictionary
diff --git a/src/Umbraco.Infrastructure/Models/Blocks/BlockListEditorDataConverter.cs b/src/Umbraco.Infrastructure/Models/Blocks/BlockListEditorDataConverter.cs
index be8d1a47ac..3d6c49c2e9 100644
--- a/src/Umbraco.Infrastructure/Models/Blocks/BlockListEditorDataConverter.cs
+++ b/src/Umbraco.Infrastructure/Models/Blocks/BlockListEditorDataConverter.cs
@@ -13,10 +13,10 @@ namespace Umbraco.Cms.Core.Models.Blocks
{
}
- protected override IEnumerable GetBlockReferences(JToken jsonLayout)
+ protected override IEnumerable? GetBlockReferences(JToken jsonLayout)
{
var blockListLayout = jsonLayout.ToObject>();
- return blockListLayout.Select(x => new ContentAndSettingsReference(x.ContentUdi, x.SettingsUdi)).ToList();
+ return blockListLayout?.Select(x => new ContentAndSettingsReference(x.ContentUdi, x.SettingsUdi)).ToList();
}
}
}
diff --git a/src/Umbraco.Infrastructure/Models/Mapping/EntityMapDefinition.cs b/src/Umbraco.Infrastructure/Models/Mapping/EntityMapDefinition.cs
index 2b52a93741..8b49f6ffa2 100644
--- a/src/Umbraco.Infrastructure/Models/Mapping/EntityMapDefinition.cs
+++ b/src/Umbraco.Infrastructure/Models/Mapping/EntityMapDefinition.cs
@@ -42,12 +42,12 @@ namespace Umbraco.Cms.Core.Models.Mapping
if (source is IContentEntitySlim contentSlim)
{
- source.AdditionalData["ContentTypeAlias"] = contentSlim.ContentTypeAlias;
+ source.AdditionalData!["ContentTypeAlias"] = contentSlim.ContentTypeAlias;
}
if (source is IDocumentEntitySlim documentSlim)
{
- source.AdditionalData["IsPublished"] = documentSlim.Published;
+ source.AdditionalData!["IsPublished"] = documentSlim.Published;
}
if (source is IMediaEntitySlim mediaSlim)
@@ -61,7 +61,10 @@ namespace Umbraco.Cms.Core.Models.Mapping
// it works fine for now, but it's something to keep in mind in the future
foreach(var kvp in source.AdditionalData)
{
- target.AdditionalData[kvp.Key] = kvp.Value;
+ if (kvp.Value is not null)
+ {
+ target.AdditionalData[kvp.Key] = kvp.Value;
+ }
}
target.AdditionalData.Add("IsContainer", source.IsContainer);
@@ -243,7 +246,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
}
}
- private static string MapContentTypeIcon(IEntitySlim entity)
+ private static string? MapContentTypeIcon(IEntitySlim entity)
{
switch (entity)
{
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/ApiVersion.cs b/src/Umbraco.Infrastructure/ModelsBuilder/ApiVersion.cs
index efd7257414..fc123d485c 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/ApiVersion.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/ApiVersion.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder
internal ApiVersion(SemVersion executingVersion) => Version = executingVersion ?? throw new ArgumentNullException(nameof(executingVersion));
private static SemVersion CurrentAssemblyVersion
- => SemVersion.Parse(Assembly.GetExecutingAssembly().GetCustomAttribute().InformationalVersion);
+ => SemVersion.Parse(Assembly.GetExecutingAssembly().GetCustomAttribute()!.InformationalVersion);
///
/// Gets the currently executing API version.
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/Building/Builder.cs b/src/Umbraco.Infrastructure/ModelsBuilder/Building/Builder.cs
index 03fc701628..4bfd6ff348 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/Building/Builder.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/Building/Builder.cs
@@ -76,7 +76,9 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
}
// for unit tests only
+#pragma warning disable CS8618
protected Builder()
+#pragma warning restore CS8618
{ }
protected ModelsBuilderSettings Config { get; }
@@ -191,7 +193,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
return true;
}
- public string ModelsNamespaceForTests { get; set; }
+ public string? ModelsNamespaceForTests { get; set; }
public string GetModelsNamespace()
{
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/Building/PropertyModel.cs b/src/Umbraco.Infrastructure/ModelsBuilder/Building/PropertyModel.cs
index 30f5ecd945..6738308735 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/Building/PropertyModel.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/Building/PropertyModel.cs
@@ -12,35 +12,35 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
///
/// Gets the alias of the property.
///
- public string Alias;
+ public string Alias = string.Empty;
///
/// Gets the name of the property.
///
- public string Name;
+ public string Name = string.Empty;
///
/// Gets the description of the property.
///
- public string Description;
+ public string? Description;
///
/// Gets the clr name of the property.
///
/// This is just the local name eg "Price".
- public string ClrName;
+ public string ClrName = string.Empty;
///
/// Gets the Model Clr type of the property values.
///
/// As indicated by the PublishedPropertyType, ie by the IPropertyValueConverter
/// if any, else object. May include some ModelType that will need to be mapped.
- public Type ModelClrType;
+ public Type ModelClrType = null!;
///
/// Gets the CLR type name of the property values.
///
- public string ClrTypeName;
+ public string ClrTypeName = string.Empty;
///
/// Gets the generation errors for the property.
@@ -48,7 +48,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
/// This should be null, unless something prevents the property from being
/// generated, and then the value should explain what. This can be used to generate
/// commented out code eg in mode.
- public List Errors;
+ public List? Errors;
///
/// Adds an error.
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs b/src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs
index 5a1d79d3cd..8bb65eb543 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs
@@ -277,7 +277,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
return string.Format("Get{0}", clrName);
}
- private void WriteProperty(StringBuilder sb, TypeModel type, PropertyModel property, string mixinClrName = null)
+ private void WriteProperty(StringBuilder sb, TypeModel type, PropertyModel property, string? mixinClrName = null)
{
var mixinStatic = mixinClrName != null;
@@ -489,7 +489,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
s = Regex.Replace(s, @"\{(.*)\}\[\*\]", m => ModelsMap[m.Groups[1].Value + "[]"]);
// takes care eg of "System.Int32" vs. "int"
- if (TypesMap.TryGetValue(s, out string typeName))
+ if (TypesMap.TryGetValue(s, out string? typeName))
{
sb.Append(typeName);
return;
@@ -499,7 +499,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
// so if we want Umbraco.Core.Models.IPublishedContent
// and using Umbraco.Core.Models, then we just need IPublishedContent
typeName = s;
- string typeUsing = null;
+ string? typeUsing = null;
var p = typeName.LastIndexOf('.');
if (p > 0)
{
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/Building/TypeModel.cs b/src/Umbraco.Infrastructure/ModelsBuilder/Building/TypeModel.cs
index e5ee0a36b5..8df89be5c6 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/Building/TypeModel.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/Building/TypeModel.cs
@@ -18,23 +18,23 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
///
/// Gets the alias of the model.
///
- public string Alias;
+ public string Alias = string.Empty;
///
/// Gets the name of the content type.
///
- public string Name;
+ public string Name= string.Empty;
///
/// Gets the description of the content type.
///
- public string Description;
+ public string? Description;
///
/// Gets the clr name of the model.
///
/// This is the complete name eg "Foo.Bar.MyContent".
- public string ClrName;
+ public string ClrName = string.Empty;
///
/// Gets the unique identifier of the parent.
@@ -50,7 +50,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building
/// If the content type does not have a base content type, then returns null.
/// The current model inherits from its base model.
///
- public TypeModel BaseType; // the parent type in Umbraco (type inherits its properties)
+ public TypeModel? BaseType; // the parent type in Umbraco (type inherits its properties)
///
/// Gets the list of properties that are defined by this model.
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/ModelsGenerationError.cs b/src/Umbraco.Infrastructure/ModelsBuilder/ModelsGenerationError.cs
index 15e629f4f0..b421042928 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/ModelsGenerationError.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/ModelsGenerationError.cs
@@ -54,7 +54,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder
File.WriteAllText(errFile, sb.ToString());
}
- public string GetLastError()
+ public string? GetLastError()
{
var errFile = GetErrFile();
if (errFile == null)
@@ -73,7 +73,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder
}
}
- private string GetErrFile()
+ private string? GetErrFile()
{
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostingEnvironment);
if (!Directory.Exists(modelsDirectory))
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/PublishedElementExtensions.cs b/src/Umbraco.Infrastructure/ModelsBuilder/PublishedElementExtensions.cs
index f771d34054..85d953da3a 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/PublishedElementExtensions.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/PublishedElementExtensions.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Extensions
///
/// Gets the value of a property.
///
- public static TValue ValueFor(this TModel model, IPublishedValueFallback publishedValueFallback, Expression> property, string? culture = null, string? segment = null, Fallback fallback = default, TValue defaultValue = default)
+ public static TValue? ValueFor(this TModel model, IPublishedValueFallback publishedValueFallback, Expression> property, string? culture = null, string? segment = null, Fallback fallback = default, TValue? defaultValue = default)
where TModel : IPublishedElement
{
var alias = GetAlias(model, property);
@@ -36,7 +36,7 @@ namespace Umbraco.Extensions
throw new ArgumentException("Not a proper lambda expression (body).", nameof(property));
var memberExpression = (MemberExpression) lambdaBody;
- if (memberExpression.Expression.NodeType != ExpressionType.Parameter)
+ if (memberExpression.Expression?.NodeType != ExpressionType.Parameter)
throw new ArgumentException("Not a proper lambda expression (member).", nameof(property));
var member = memberExpression.Member;
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/PublishedModelUtility.cs b/src/Umbraco.Infrastructure/ModelsBuilder/PublishedModelUtility.cs
index fedd255e0f..0bc442772e 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/PublishedModelUtility.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/PublishedModelUtility.cs
@@ -47,7 +47,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder
}
}
- public static IPublishedPropertyType GetModelPropertyType(IPublishedContentType contentType, Expression> selector)
+ public static IPublishedPropertyType? GetModelPropertyType(IPublishedContentType contentType, Expression> selector)
//where TModel : PublishedContentModel // fixme PublishedContentModel _or_ PublishedElementModel
{
// fixme therefore, missing a check on TModel here
diff --git a/src/Umbraco.Infrastructure/ModelsBuilder/TypeExtensions.cs b/src/Umbraco.Infrastructure/ModelsBuilder/TypeExtensions.cs
index e9f427b158..5d3187c707 100644
--- a/src/Umbraco.Infrastructure/ModelsBuilder/TypeExtensions.cs
+++ b/src/Umbraco.Infrastructure/ModelsBuilder/TypeExtensions.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder
/// A generic instance of the generic type with the proper type.
/// Usage... typeof (Something{}).CreateGenericInstance(object1, object2, object3) will return
/// a Something{Type1} if object1.GetType() is Type1.
- public static object CreateGenericInstance(this Type genericType, object typeParmObj, params object[] ctorArgs)
+ public static object? CreateGenericInstance(this Type genericType, object typeParmObj, params object[] ctorArgs)
{
var type = genericType.MakeGenericType(typeParmObj.GetType());
return Activator.CreateInstance(type, ctorArgs);
diff --git a/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs b/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs
index 838d59e14e..04abcfa8a0 100644
--- a/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs
+++ b/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs
@@ -29,7 +29,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
private readonly IShortStringHelper _shortStringHelper;
private readonly PackageMigrationSettings _packageMigrationSettings;
- private bool _executed;
+ private bool _executed;
public ImportPackageBuilderExpression(
IPackagingService packagingService,
@@ -53,9 +53,9 @@ namespace Umbraco.Cms.Infrastructure.Packaging
///
/// The type of the migration which dictates the namespace of the embedded resource
///
- public Type EmbeddedResourceMigrationType { get; set; }
+ public Type? EmbeddedResourceMigrationType { get; set; }
- public XDocument PackageDataManifest { get; set; }
+ public XDocument? PackageDataManifest { get; set; }
public override void Execute()
{
@@ -85,10 +85,10 @@ namespace Umbraco.Cms.Infrastructure.Packaging
{
if (PackageMigrationResource.TryGetEmbeddedPackageDataManifest(
EmbeddedResourceMigrationType,
- out XDocument xml, out ZipArchive zipPackage))
+ out XDocument? xml, out ZipArchive? zipPackage))
{
// first install the package
- installationSummary = _packagingService.InstallCompiledPackageData(xml);
+ installationSummary = _packagingService.InstallCompiledPackageData(xml!);
if (zipPackage is not null)
{
@@ -96,7 +96,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
using (zipPackage)
{
// then we need to save each file to the saved media items
- var mediaWithFiles = xml.XPathSelectElements(
+ var mediaWithFiles = xml!.XPathSelectElements(
"./umbPackage/MediaItems/MediaSet//*[@id][@mediaFilePath]")
.ToDictionary(
x => x.AttributeValue("key"),
@@ -111,8 +111,8 @@ namespace Umbraco.Cms.Infrastructure.Packaging
if (mediaWithFiles.TryGetValue(media.Key, out var mediaFilePath))
{
// this is a media item that has a file, so find that file in the zip
- var entryPath = $"media{mediaFilePath.EnsureStartsWith('/')}";
- ZipArchiveEntry mediaEntry = zipPackage.GetEntry(entryPath);
+ var entryPath = $"media{mediaFilePath!.EnsureStartsWith('/')}";
+ ZipArchiveEntry? mediaEntry = zipPackage.GetEntry(entryPath);
if (mediaEntry == null)
{
throw new InvalidOperationException(
@@ -130,7 +130,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
_shortStringHelper,
_contentTypeBaseServiceProvider,
Constants.Conventions.Media.File,
- Path.GetFileName(mediaFilePath),
+ Path.GetFileName(mediaFilePath)!,
mediaStream);
}
diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs
index 790cefe7e9..c4951c2aaf 100644
--- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs
+++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs
@@ -1118,7 +1118,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
var databaseTypeAttribute = dataTypeElement.Attribute("DatabaseType");
var parentId = -1;
- if (importedFolders.ContainsKey(dataTypeDefinitionName))
+ if (dataTypeDefinitionName is not null && importedFolders.ContainsKey(dataTypeDefinitionName))
parentId = importedFolders[dataTypeDefinitionName];
var definition = _dataTypeService.GetDataType(dataTypeDefinitionId);
diff --git a/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs b/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
index 42c3ff1865..1957e17655 100644
--- a/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
+++ b/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
@@ -877,7 +877,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
public long GetBytes(int i,
long fieldOffset,
- byte[] buffer,
+ byte[]? buffer,
int bufferoffset,
int length)
{
@@ -966,14 +966,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence
///
public long GetChars(int i,
long fieldoffset,
- char[] buffer,
+ char[]? buffer,
int bufferoffset,
int length)
{
object data = GetValue(i);
- string dataAsString = data as string;
- char[] dataAsCharArray = data as char[];
+ string? dataAsString = data as string;
+ char[]? dataAsCharArray = data as char[];
if (dataAsString != null)
{
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
index 6235c1a2b3..a2f053415c 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
@@ -29,12 +29,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations
/// Overrides the default naming of a foreign key reference:
/// FK_thisTableName_refTableName
///
- public string Name { get; set; }
+ public string? Name { get; set; }
///
/// Gets or sets the name of the Column that this foreign key should reference.
///
/// PrimaryKey column is used by default
- public string Column { get; set; }
+ public string? Column { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs
index 2fcc0c85d1..c4c5579028 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs
@@ -36,7 +36,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations
/// Overrides the default naming of a PrimaryKey constraint:
/// PK_tableName
///
- public string Name { get; set; }
+ public string? Name { get; set; }
///
/// Gets or sets the names of the columns for this PrimaryKey.
@@ -45,7 +45,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations
/// Should only be used if the PrimaryKey spans over multiple columns.
/// Usage: [nodeId], [otherColumn]
///
- public string OnColumns { get; set; }
+ public string? OnColumns { get; set; }
///
/// Gets or sets the Identity Seed, which is used for Sql Ce databases.
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbType.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbType.cs
index 00be5c51ab..41570d7b95 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbType.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbType.cs
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations
public static SpecialDbType NCHAR { get; } = new SpecialDbType(SpecialDbTypes.NCHAR);
public static SpecialDbType NVARCHARMAX { get; } = new SpecialDbType(SpecialDbTypes.NVARCHARMAX);
- public override bool Equals(object obj) => obj is SpecialDbType types && Equals(types);
+ public override bool Equals(object? obj) => obj is SpecialDbType types && Equals(types);
public bool Equals(SpecialDbType other) => _dbType == other._dbType;
public override int GetHashCode() => 1038481724 + EqualityComparer.Default.GetHashCode(_dbType);
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs
index dee560a40d..c597b74cde 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs
@@ -32,7 +32,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseModelDefinitions
public virtual string PrimaryKeyColumns { get; set; }//When the primary key spans multiple columns
public virtual bool IsNullable { get; set; }
public virtual bool IsUnique { get; set; }
- public virtual string TableName { get; set; }
+ public virtual string? TableName { get; set; }
public virtual ModificationType ModificationType { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs
index fafd9d44e2..919c5687a6 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs
@@ -14,9 +14,9 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseModelDefinitions
public bool IsUniqueConstraint => ConstraintType.Unique == _constraintType;
public bool IsNonUniqueConstraint => ConstraintType.NonUnique == _constraintType;
- public string SchemaName { get; set; }
- public string ConstraintName { get; set; }
- public string TableName { get; set; }
+ public string? SchemaName { get; set; }
+ public string? ConstraintName { get; set; }
+ public string? TableName { get; set; }
public ICollection Columns = new HashSet();
public bool IsPrimaryKeyClustered { get; set; }
}
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
index 34ad767b04..a2507a17f2 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
@@ -123,18 +123,18 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseModelDefinitions
var referencedPrimaryKey = attribute.Type.FirstAttribute();
string referencedColumn = string.IsNullOrEmpty(attribute.Column)
- ? referencedPrimaryKey.Value
+ ? referencedPrimaryKey!.Value
: attribute.Column;
string foreignKeyName = string.IsNullOrEmpty(attribute.Name)
- ? string.Format("FK_{0}_{1}_{2}", tableName, referencedTable.Value, referencedColumn)
+ ? string.Format("FK_{0}_{1}_{2}", tableName, referencedTable!.Value, referencedColumn)
: attribute.Name;
var definition = new ForeignKeyDefinition
{
Name = foreignKeyName,
ForeignTable = tableName,
- PrimaryTable = referencedTable.Value,
+ PrimaryTable = referencedTable!.Value,
OnDelete = attribute.OnDelete,
OnUpdate = attribute.OnUpdate
};
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs
index 85747ea9e2..e6752159de 100644
--- a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs
@@ -14,11 +14,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.DatabaseModelDefinitions
OnUpdate = Rule.None;
}
- public virtual string Name { get; set; }
- public virtual string ForeignTable { get; set; }
- public virtual string ForeignTableSchema { get; set; }
- public virtual string PrimaryTable { get; set; }
- public virtual string PrimaryTableSchema { get; set; }
+ public virtual string? Name { get; set; }
+ public virtual string? ForeignTable { get; set; }
+ public virtual string? ForeignTableSchema { get; set; }
+ public virtual string? PrimaryTable { get; set; }
+ public virtual string? PrimaryTableSchema { get; set; }
public virtual Rule OnDelete { get; set; }
public virtual Rule OnUpdate { get; set; }
public virtual ICollection ForeignColumns { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs
index abcb6f9700..092a06a57c 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; }
+ public virtual string? SchemaName { get; set; }
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/DbConnectionExtensions.cs b/src/Umbraco.Infrastructure/Persistence/DbConnectionExtensions.cs
index fb5d00abfd..ee6ce188de 100644
--- a/src/Umbraco.Infrastructure/Persistence/DbConnectionExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DbConnectionExtensions.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Extensions
{
public static class DbConnectionExtensions
{
- public static bool IsConnectionAvailable(string connectionString, DbProviderFactory factory)
+ public static bool IsConnectionAvailable(string? connectionString, DbProviderFactory factory)
{
var connection = factory?.CreateConnection();
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
index 00312e2cec..307f91337b 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
@@ -20,10 +20,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("ruleValue")]
[Index(IndexTypes.UniqueNonClustered, ForColumns = "ruleValue,ruleType,accessId", Name = "IX_umbracoAccessRule")]
- public string RuleValue { get; set; }
+ public string? RuleValue { get; set; }
[Column("ruleType")]
- public string RuleType { get; set; }
+ public string? RuleType { get; set; }
[Column("createDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs
index 822f21a593..0bfc517aa6 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs
@@ -28,12 +28,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("performingDetails")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(DetailsLength)]
- public string PerformingDetails { get; set; }
+ public string? PerformingDetails { get; set; }
[Column("performingIp")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(IpLength)]
- public string PerformingIp { get; set; }
+ public string? PerformingIp { get; set; }
[Column("eventDateUtc")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
@@ -45,15 +45,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("affectedDetails")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(DetailsLength)]
- public string AffectedDetails { get; set; }
+ public string? AffectedDetails { get; set; }
[Column("eventType")]
[Length(EventTypeLength)]
- public string EventType { get; set; }
+ public string? EventType { get; set; }
[Column("eventDetails")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(DetailsLength)]
- public string EventDetails { get; set; }
+ public string? EventDetails { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs
index 059a27631d..e0c9b73c78 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs
@@ -19,15 +19,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("source")]
[Length(512)]
- public string Source { get; set; }
+ public string? Source { get; set; }
[Column("context")]
[Length(128)]
- public string Context { get; set; }
+ public string? Context { get; set; }
[Column("action")]
[Length(512)]
- public string Action { get; set; }
+ public string? Action { get; set; }
[Column("createDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
@@ -38,6 +38,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("comment")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Comment { get; set; }
+ public string? Comment { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentTypeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentTypeDto.cs
index ca9f5fc1cc..8d4019de09 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentTypeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentTypeDto.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
internal class ContentTypeDto
{
public const string TableName = Cms.Core.Constants.DatabaseSchema.Tables.ContentType;
- private string _alias;
+ private string? _alias;
[Column("pk")]
[PrimaryKeyColumn(IdentitySeed = 700)]
@@ -22,21 +22,21 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("alias")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Alias { get => _alias; set => _alias = value == null ? null : string.Intern(value); }
+ public string? Alias { get => _alias; set => _alias = value == null ? null : string.Intern(value); }
[Column("icon")]
[Index(IndexTypes.NonClustered)]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Icon { get; set; }
+ public string? Icon { get; set; }
[Column("thumbnail")]
[Constraint(Default = "folder.png")]
- public string Thumbnail { get; set; }
+ public string? Thumbnail { get; set; }
[Column("description")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(1500)]
- public string Description { get; set; }
+ public string? Description { get; set; }
[Column("isContainer")]
[Constraint(Default = "0")]
@@ -56,6 +56,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[ResultColumn]
[Reference(ReferenceType.OneToOne, ColumnName = "NodeId")]
- public NodeDto NodeDto { get; set; }
+ public NodeDto NodeDto { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs
index d8a8d97a97..b94cf3c541 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("config")]
[SpecialDbType(SpecialDbTypes.NTEXT)]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Configuration { get; set; }
+ public string? Configuration { get; set; }
[ResultColumn]
[Reference(ReferenceType.OneToOne, ColumnName = "NodeId")]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs
index 0af1ff83c5..b6eae7f234 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Length(400)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Index(IndexTypes.UniqueNonClustered, ForColumns = "loginProvider,userOrMemberKey", Name = "IX_" + TableName + "_LoginProvider")]
- public string LoginProvider { get; set; }
+ public string LoginProvider { get; set; } = null!;
///
/// Stores the key the provider uses to lookup the login
@@ -40,7 +40,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Length(4000)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Index(IndexTypes.NonClustered, ForColumns = "loginProvider,providerKey", Name = "IX_" + TableName + "_ProviderKey")]
- public string ProviderKey { get; set; }
+ public string ProviderKey { get; set; } = null!;
[Column("createDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
@@ -52,6 +52,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("userData")]
[NullSetting(NullSetting = NullSettings.Null)]
[SpecialDbType(SpecialDbTypes.NTEXT)]
- public string UserData { get; set; }
+ public string? UserData { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/MacroDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/MacroDto.cs
index 6e05fb393a..3f9dae2744 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/MacroDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/MacroDto.cs
@@ -28,11 +28,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("macroAlias")]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_cmsMacroPropertyAlias")]
- public string Alias { get; set; }
+ public string Alias { get; set; } = string.Empty;
[Column("macroName")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Name { get; set; }
+ public string? Name { get; set; }
[Column("macroCacheByPage")]
[Constraint(Default = "1")]
@@ -48,7 +48,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("macroSource")]
[NullSetting(NullSetting = NullSettings.NotNull)]
- public string MacroSource { get; set; }
+ public string MacroSource { get; set; } = null!;
[Column("macroType")]
[NullSetting(NullSetting = NullSettings.NotNull)]
@@ -56,6 +56,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[ResultColumn]
[Reference(ReferenceType.Many, ReferenceMemberName = "Macro")]
- public List MacroPropertyDtos { get; set; }
+ public List? MacroPropertyDtos { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/MacroPropertyDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/MacroPropertyDto.cs
index afc8136383..62e64e77a9 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/MacroPropertyDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/MacroPropertyDto.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
public Guid UniqueId { get; set; }
[Column("editorAlias")]
- public string EditorAlias { get; set; }
+ public string EditorAlias { get; set; } = null!;
[Column("macro")]
[ForeignKey(typeof(MacroDto))]
@@ -32,9 +32,9 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("macroPropertyAlias")]
[Length(50)]
- public string Alias { get; set; }
+ public string Alias { get; set; } = null!;
[Column("macroPropertyName")]
- public string Name { get; set; }
+ public string? Name { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/MediaVersionDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/MediaVersionDto.cs
index 06ec7e64b6..bcea2e7673 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/MediaVersionDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/MediaVersionDto.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("path")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Path { get; set; }
+ public string? Path { get; set; }
[ResultColumn]
[Reference(ReferenceType.OneToOne)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
index be34a473c1..959a6c5f6a 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
@@ -38,12 +38,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("passwordConfig")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(500)]
- public string PasswordConfig { get; set; }
+ public string? PasswordConfig { get; set; }
[Column("securityStampToken")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(255)]
- public string SecurityStampToken { get; set; }
+ public string? SecurityStampToken { get; set; }
[Column("emailConfirmedDate")]
[NullSetting(NullSetting = NullSettings.Null)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
index 4639e4529a..b5b1d42b49 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")]
@@ -54,10 +54,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("text")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Text { get; set; }
+ public string? Text { get; set; }
[Column("nodeObjectType")] // TODO: db rename to 'objectType'
- [NullSetting(NullSetting = NullSettings.Null)]
+ [NullSetting(NullSetting = NullSettings.Null)]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_ObjectType", ForColumns = "nodeObjectType,trashed", IncludeColumns = "uniqueId,parentId,level,path,sortOrder,nodeUser,text,createDate")]
public Guid? NodeObjectType { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs
index 6e45e24d14..bd0c63a412 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs
@@ -41,7 +41,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_Segment")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(SegmentLength)]
- public string Segment { get; set; }
+ public string? Segment { get; set; }
[Column("intValue")]
[NullSetting(NullSetting = NullSettings.Null)]
@@ -62,19 +62,19 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("varcharValue")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(VarcharLength)]
- public string VarcharValue { get; set; }
+ public string? VarcharValue { get; set; }
[Column("textValue")]
[NullSetting(NullSetting = NullSettings.Null)]
[SpecialDbType(SpecialDbTypes.NTEXT)]
- public string TextValue { get; set; }
+ public string? TextValue { get; set; }
[ResultColumn]
[Reference(ReferenceType.OneToOne, ColumnName = "PropertyTypeId")]
- public PropertyTypeDto PropertyTypeDto { get; set; }
+ public PropertyTypeDto? PropertyTypeDto { get; set; }
[Ignore]
- public object Value
+ public object? Value
{
get
{
@@ -119,7 +119,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
return Id == other.Id;
}
- public override bool Equals(object other)
+ public override bool Equals(object? other)
{
return
!ReferenceEquals(null, other) // other is not null
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeDto.cs
index 340134dde2..dd4652f366 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeDto.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[ExplicitColumns]
internal class PropertyTypeDto
{
- private string _alias;
+ private string? _alias;
[Column("id")]
[PrimaryKeyColumn(IdentitySeed = 100)]
@@ -31,11 +31,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Index(IndexTypes.NonClustered, Name = "IX_cmsPropertyTypeAlias")]
[Column("Alias")]
- public string Alias { get => _alias; set => _alias = value == null ? null : string.Intern(value); }
+ public string? Alias { get => _alias; set => _alias = value == null ? null : string.Intern(value); }
[Column("Name")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Name { get; set; }
+ public string? Name { get; set; }
[Column("sortOrder")]
[Constraint(Default = "0")]
@@ -48,21 +48,21 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("mandatoryMessage")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(500)]
- public string MandatoryMessage { get; set; }
+ public string? MandatoryMessage { get; set; }
[Column("validationRegExp")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string ValidationRegExp { get; set; }
+ public string? ValidationRegExp { get; set; }
[Column("validationRegExpMessage")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(500)]
- public string ValidationRegExpMessage { get; set; }
+ public string? ValidationRegExpMessage { get; set; }
[Column("Description")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(2000)]
- public string Description { get; set; }
+ public string? Description { get; set; }
[Column("labelOnTop")]
[Constraint(Default = "0")]
@@ -74,7 +74,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[ResultColumn]
[Reference(ReferenceType.OneToOne, ColumnName = "DataTypeId")]
- public DataTypeDto DataTypeDto { get; set; }
+ public DataTypeDto DataTypeDto { get; set; } = null!;
[Column("UniqueID")]
[NullSetting(NullSetting = NullSettings.NotNull)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeGroupDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeGroupDto.cs
index 42137ed6f1..8b116fab59 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeGroupDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyTypeGroupDto.cs
@@ -32,7 +32,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
public short Type { get; set; }
[Column("text")]
- public string Text { get; set; }
+ public string? Text { get; set; }
[Column("alias")]
public string Alias { get; set; }
@@ -42,6 +42,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[ResultColumn]
[Reference(ReferenceType.Many, ReferenceMemberName = "PropertyTypeGroupId")]
- public List PropertyTypeDtos { get; set; }
+ public List? PropertyTypeDtos { get; set; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs
index a9188a569f..211a52a8a1 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/RedirectUrlDto.cs
@@ -39,16 +39,16 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("url")]
[NullSetting(NullSetting = NullSettings.NotNull)]
- public string Url { get; set; }
+ public string Url { get; set; } = null!;
[Column("culture")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Culture { get; set; }
+ public string Culture { get; set; } = null!;
[Column("urlHash")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_umbracoRedirectUrl", ForColumns = "urlHash, contentKey, culture, createDateUtc")]
[Length(40)]
- public string UrlHash { get; set; }
+ public string UrlHash { get; set; } = null!;
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
index 902facec84..89ef0039ab 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
@@ -16,12 +16,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("address")]
[Length(500)]
- public string ServerAddress { get; set; }
+ public string? ServerAddress { get; set; }
[Column("computerName")]
[Length(255)]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_computerName")] // server identity is unique
- public string ServerIdentity { get; set; }
+ public string? ServerIdentity { get; set; }
[Column("registeredDate")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/TagDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/TagDto.cs
index 6f729c39cf..9c437dd6a1 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/TagDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/TagDto.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("group")]
[Length(100)]
- public string Group { get; set; }
+ public string? Group { get; set; }
[Column("languageId")]
[ForeignKey(typeof(LanguageDto))]
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("tag")]
[Length(200)]
[Index(IndexTypes.UniqueNonClustered, ForColumns = "group,tag,languageId", Name = "IX_cmsTags")]
- public string Text { get; set; }
+ public string? Text { get; set; }
//[Column("key")]
//[Length(301)] // de-normalized "{group}/{tag}"
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
index 9a51672689..3c313794e0 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
@@ -34,16 +34,16 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
public bool NoConsole { get; set; }
[Column("userName")]
- public string UserName { get; set; }
+ public string? UserName { get; set; }
[Column("userLogin")]
[Length(125)]
[Index(IndexTypes.NonClustered)]
- public string Login { get; set; }
+ public string? Login { get; set; }
[Column("userPassword")]
[Length(500)]
- 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)
@@ -51,20 +51,20 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("passwordConfig")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(500)]
- public string PasswordConfig { get; set; }
+ public string? PasswordConfig { get; set; }
[Column("userEmail")]
- public string Email { get; set; }
+ public string? Email { get; set; }
[Column("userLanguage")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(10)]
- public string UserLanguage { get; set; }
+ public string? UserLanguage { get; set; }
[Column("securityStampToken")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(255)]
- public string SecurityStampToken { get; set; }
+ public string? SecurityStampToken { get; set; }
[Column("failedLoginAttempts")]
[NullSetting(NullSetting = NullSettings.Null)]
@@ -106,7 +106,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("avatar")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(500)]
- public string Avatar { get; set; }
+ public string? Avatar { get; set; }
///
/// A Json blob stored for recording tour data for a user
@@ -114,7 +114,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("tourData")]
[NullSetting(NullSetting = NullSettings.Null)]
[SpecialDbType(SpecialDbTypes.NTEXT)]
- public string TourData { get; set; }
+ public string? TourData { get; set; }
[ResultColumn]
[Reference(ReferenceType.Many, ReferenceMemberName = "UserId")]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
index d30d1beca2..afbda3cc9a 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
@@ -23,17 +23,17 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("userGroupAlias")]
[Length(200)]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_umbracoUserGroup_userGroupAlias")]
- public string Alias { get; set; }
+ public string? Alias { get; set; }
[Column("userGroupName")]
[Length(200)]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_umbracoUserGroup_userGroupName")]
- public string Name { get; set; }
+ public string? Name { get; set; }
[Column("userGroupDefaultPermissions")]
[Length(50)]
[NullSetting(NullSetting = NullSettings.Null)]
- public string DefaultPermissions { get; set; }
+ public string? DefaultPermissions { get; set; }
[Column("createDate")]
[NullSetting(NullSetting = NullSettings.NotNull)]
@@ -47,7 +47,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("icon")]
[NullSetting(NullSetting = NullSettings.Null)]
- public string Icon { get; set; }
+ public string? Icon { get; set; }
[Column("startContentId")]
[NullSetting(NullSetting = NullSettings.Null)]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserStartNodeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserStartNodeDto.cs
index fd2456c943..44e6379007 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserStartNodeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserStartNodeDto.cs
@@ -34,14 +34,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
Media = 2
}
- public bool Equals(UserStartNodeDto other)
+ public bool Equals(UserStartNodeDto? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Id == other.Id;
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
index a451ac0879..fb3e866272 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
@@ -130,7 +130,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
content.PasswordConfiguration = dto.PasswordConfig;
content.Key = nodeDto.UniqueId;
content.VersionId = contentVersionDto.Id;
-
+
// TODO: missing names?
content.Path = nodeDto.Path;
@@ -297,7 +297,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
// try to get a path from the string being stored for media
// TODO: only considering umbracoFile
- string path = null;
+ string? path = null;
if (entity.Properties.TryGetValue(Cms.Core.Constants.Conventions.Media.File, out var property)
&& mediaUrlGenerators.TryGetMediaPath(property.PropertyType.PropertyEditorAlias, property.GetValue(), out var mediaPath))
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/ContentTypeFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ContentTypeFactory.cs
index bf1234ffb2..a3a1deb62d 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/ContentTypeFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/ContentTypeFactory.cs
@@ -108,7 +108,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
{
entity.Id = dto.NodeDto.NodeId;
entity.Key = dto.NodeDto.UniqueId;
- entity.Alias = dto.Alias;
+ entity.Alias = dto.Alias ?? string.Empty;
entity.Name = dto.NodeDto.Text;
entity.Icon = dto.Icon;
entity.Thumbnail = dto.Thumbnail;
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/DictionaryItemFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/DictionaryItemFactory.cs
index 9cfdc019a8..31dc7ef2ec 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/DictionaryItemFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/DictionaryItemFactory.cs
@@ -46,20 +46,24 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
private static List BuildLanguageTextDtos(IDictionaryItem entity)
{
var list = new List();
- foreach (var translation in entity.Translations)
+ if (entity.Translations is not null)
{
- var text = new LanguageTextDto
- {
- LanguageId = translation.LanguageId,
- UniqueId = translation.Key,
- Value = translation.Value
- };
+ foreach (var translation in entity.Translations)
+ {
+ var text = new LanguageTextDto
+ {
+ LanguageId = translation.LanguageId,
+ UniqueId = translation.Key,
+ Value = translation.Value!,
+ };
- if (translation.HasIdentity)
- text.PrimaryKey = translation.Id;
+ if (translation.HasIdentity)
+ text.PrimaryKey = translation.Id;
- list.Add(text);
+ list.Add(text);
+ }
}
+
return list;
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs
index 8df6d654b0..f0f3249318 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyFactory.cs
@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
return properties;
}
- private static PropertyDataDto BuildDto(int versionId, IProperty property, int? languageId, string segment, object value)
+ private static PropertyDataDto BuildDto(int versionId, IProperty property, int? languageId, string? segment, object? value)
{
var dto = new PropertyDataDto { VersionId = versionId, PropertyTypeId = property.PropertyTypeId };
@@ -103,12 +103,12 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
///
public static IEnumerable BuildDtos(ContentVariation contentVariation, int currentVersionId, int publishedVersionId, IEnumerable properties,
ILanguageRepository languageRepository, out bool edited,
- out HashSet editedCultures)
+ out HashSet? editedCultures)
{
var propertyDataDtos = new List();
edited = false;
editedCultures = null; // don't allocate unless necessary
- string defaultCulture = null; //don't allocate unless necessary
+ string? defaultCulture = null; //don't allocate unless necessary
var entityVariesByCulture = contentVariation.VariesByCulture();
@@ -132,11 +132,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
// deal with published value
if ((propertyValue.PublishedValue != null || isSegmentValue) && publishedVersionId > 0)
- propertyDataDtos.Add(BuildDto(publishedVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.PublishedValue));
+ propertyDataDtos.Add(BuildDto(publishedVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue?.Segment, propertyValue?.PublishedValue));
// deal with edit value
- if (propertyValue.EditedValue != null || isSegmentValue)
- propertyDataDtos.Add(BuildDto(currentVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.EditedValue));
+ if (propertyValue?.EditedValue != null || isSegmentValue)
+ propertyDataDtos.Add(BuildDto(currentVersionId, property, languageRepository.GetIdByIsoCode(propertyValue?.Culture), propertyValue?.Segment, propertyValue?.EditedValue));
// property.Values will contain ALL of it's values, both variant and invariant which will be populated if the
// administrator has previously changed the property type to be variant vs invariant.
@@ -150,15 +150,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
continue;
// use explicit equals here, else object comparison fails at comparing eg strings
- var sameValues = propertyValue.PublishedValue == null ? propertyValue.EditedValue == null : propertyValue.PublishedValue.Equals(propertyValue.EditedValue);
+ var sameValues = propertyValue?.PublishedValue == null ? propertyValue?.EditedValue == null : propertyValue.PublishedValue.Equals(propertyValue.EditedValue);
edited |= !sameValues;
if (entityVariesByCulture && !sameValues)
{
- if (isCultureValue)
+ if (isCultureValue && propertyValue?.Culture is not null)
{
- editedCultures.Add(propertyValue.Culture); // report culture as edited
+ editedCultures?.Add(propertyValue.Culture); // report culture as edited
}
else if (isInvariantValue)
{
@@ -166,7 +166,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
if (defaultCulture == null)
defaultCulture = languageRepository.GetDefaultIsoCode();
- editedCultures.Add(defaultCulture);
+ editedCultures?.Add(defaultCulture);
}
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs
index 2e73ff037c..0b61c8c7b1 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
int contentTypeId,
DateTime createDate,
DateTime updateDate,
- Func propertyTypeCtor)
+ Func propertyTypeCtor)
{
// groupDtos contains all the groups, those that are defined on the current
// content type, and those that are inherited from composition content types
@@ -44,7 +44,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
group.PropertyTypes = new PropertyTypeCollection(isPublishing);
//Because we are likely to have a group with no PropertyTypes we need to ensure that these are excluded
- var typeDtos = groupDto.PropertyTypeDtos.Where(x => x.Id > 0);
+ var typeDtos = groupDto.PropertyTypeDtos?.Where(x => x.Id > 0) ?? Enumerable.Empty();
foreach (var typeDto in typeDtos)
{
var tempGroupDto = groupDto;
@@ -56,13 +56,13 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
{
propertyType.DisableChangeTracking();
- propertyType.Alias = typeDto.Alias;
+ propertyType.Alias = typeDto.Alias ?? string.Empty;
propertyType.DataTypeId = typeDto.DataTypeId;
propertyType.DataTypeKey = typeDto.DataTypeDto.NodeDto.UniqueId;
propertyType.Description = typeDto.Description;
propertyType.Id = typeDto.Id;
propertyType.Key = typeDto.UniqueId;
- propertyType.Name = typeDto.Name;
+ propertyType.Name = typeDto.Name ?? string.Empty;
propertyType.Mandatory = typeDto.Mandatory;
propertyType.MandatoryMessage = typeDto.MandatoryMessage;
propertyType.SortOrder = typeDto.SortOrder;
@@ -118,7 +118,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
if (propertyGroup.HasIdentity)
dto.Id = propertyGroup.Id;
- dto.PropertyTypeDtos = propertyGroup.PropertyTypes.Select(propertyType => BuildPropertyTypeDto(propertyGroup.Id, propertyType, contentTypeId)).ToList();
+ dto.PropertyTypeDtos = propertyGroup.PropertyTypes?.Select(propertyType => BuildPropertyTypeDto(propertyGroup.Id, propertyType, contentTypeId)).ToList();
return dto;
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/RelationTypeFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/RelationTypeFactory.cs
index 51f5261199..0e304f1fcb 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/RelationTypeFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/RelationTypeFactory.cs
@@ -35,7 +35,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
Alias = entity.Alias,
ChildObjectType = entity.ChildObjectType,
Dual = entity.IsBidirectional,
- Name = entity.Name,
+ Name = entity.Name ?? string.Empty,
ParentObjectType = entity.ParentObjectType,
UniqueId = entity.Key
};
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs
index 0ce7fe53cb..b50d013198 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/TemplateFactory.cs
@@ -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);
+ template.MasterTemplateId = new Lazy(() => dto.NodeDto.ParentId.Value);
// 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,
Path = entity.Path,
Text = entity.Name,
Trashed = false,
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs
index 87124a2d0d..e4f98c708c 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs
@@ -74,24 +74,30 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
TourData = entity.TourData
};
- foreach (var startNodeId in entity.StartContentIds)
+ if (entity.StartContentIds is not null)
{
- dto.UserStartNodeDtos.Add(new UserStartNodeDto
+ foreach (var startNodeId in entity.StartContentIds)
{
- StartNode = startNodeId,
- StartNodeType = (int)UserStartNodeDto.StartNodeTypeValue.Content,
- UserId = entity.Id
- });
+ dto.UserStartNodeDtos.Add(new UserStartNodeDto
+ {
+ StartNode = startNodeId,
+ StartNodeType = (int)UserStartNodeDto.StartNodeTypeValue.Content,
+ UserId = entity.Id
+ });
+ }
}
- foreach (var startNodeId in entity.StartMediaIds)
+ if (entity.StartMediaIds is not null)
{
- dto.UserStartNodeDtos.Add(new UserStartNodeDto
+ foreach (var startNodeId in entity.StartMediaIds)
{
- StartNode = startNodeId,
- StartNodeType = (int)UserStartNodeDto.StartNodeTypeValue.Media,
- UserId = entity.Id
- });
+ dto.UserStartNodeDtos.Add(new UserStartNodeDto
+ {
+ StartNode = startNodeId,
+ StartNodeType = (int)UserStartNodeDto.StartNodeTypeValue.Media,
+ UserId = entity.Id
+ });
+ }
}
if (entity.HasIdentity)
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/UserGroupFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/UserGroupFactory.cs
index d4c8673a6c..9672e0e3a9 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/UserGroupFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/UserGroupFactory.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
var userGroup = new UserGroup(shortStringHelper, dto.UserCount, dto.Alias, dto.Name,
dto.DefaultPermissions.IsNullOrWhiteSpace()
? Enumerable.Empty()
- : dto.DefaultPermissions.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture)).ToList(),
+ : dto.DefaultPermissions!.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture)).ToList(),
dto.Icon);
try
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicy.cs
index 3a4c7a4c5f..82e4f20c50 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicy.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicy.cs
@@ -101,7 +101,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
///
/// An instance of a callback delegate that will be invoked whenever a retry condition is encountered.
///
- public event EventHandler Retrying;
+ public event EventHandler? Retrying;
///
/// Gets the retry strategy.
@@ -130,13 +130,13 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
/// The type of result expected from the executable action.
/// A delegate representing the executable action which returns the result of type R.
/// The result from the action.
- public virtual TResult ExecuteAction(Func func)
+ public virtual TResult? ExecuteAction(Func func)
{
//Guard.ArgumentNotNull(func, "func");
int retryCount = 0;
TimeSpan delay = TimeSpan.Zero;
- Exception lastError;
+ Exception? lastError;
var shouldRetry = this.RetryStrategy.GetShouldRetry();
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryStrategy.cs
index 1d48c336d3..3f120261d7 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryStrategy.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryStrategy.cs
@@ -85,7 +85,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
/// The name of the retry strategy.
/// a value indicating whether or not the very first retry attempt will be made immediately
/// whereas the subsequent retries will remain subject to retry interval.
- protected RetryStrategy(string name, bool firstFastRetry)
+ protected RetryStrategy(string? name, bool firstFastRetry)
{
this.Name = name;
this.FastFirstRetry = firstFastRetry;
@@ -100,7 +100,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
///
/// Gets the name of the retry strategy.
///
- public string Name { get; private set; }
+ public string? Name { get; private set; }
///
/// Returns the corresponding ShouldRetry delegate.
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs
index 33dd9ab137..91dcaf9feb 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs
@@ -57,7 +57,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
/// Indicates whether or not the very first retry attempt will be made immediately
/// whereas the subsequent retries will remain subject to retry interval.
///
- public ExponentialBackoff(string name, int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff, bool firstFastRetry)
+ public ExponentialBackoff(string? name, int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff, bool firstFastRetry)
: base(name, firstFastRetry)
{
//Guard.ArgumentNotNegativeValue(retryCount, "retryCount");
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/FixedInterval.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/FixedInterval.cs
index 0878973cc5..546b10b55a 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/FixedInterval.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/FixedInterval.cs
@@ -55,7 +55,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
/// The number of retry attempts.
/// The time interval between retries.
/// a value indicating whether or not the very first retry attempt will be made immediately whereas the subsequent retries will remain subject to retry interval.
- public FixedInterval(string name, int retryCount, TimeSpan retryInterval, bool firstFastRetry)
+ public FixedInterval(string? name, int retryCount, TimeSpan retryInterval, bool firstFastRetry)
: base(name, firstFastRetry)
{
//Guard.ArgumentNotNegativeValue(retryCount, "retryCount");
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/Incremental.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/Incremental.cs
index 5cf34f783b..1848436ae1 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/Incremental.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/Incremental.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
/// The number of retry attempts.
/// The initial interval that will apply for the first retry.
/// The incremental time value that will be used for calculating the progressive delay between retries.
- public Incremental(string name, int retryCount, TimeSpan initialInterval, TimeSpan increment)
+ public Incremental(string? name, int retryCount, TimeSpan initialInterval, TimeSpan increment)
: this(name, retryCount, initialInterval, increment, DefaultFirstFastRetry)
{
}
@@ -50,7 +50,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
/// The initial interval that will apply for the first retry.
/// The incremental time value that will be used for calculating the progressive delay between retries.
/// a value indicating whether or not the very first retry attempt will be made immediately whereas the subsequent retries will remain subject to retry interval.
- public Incremental(string name, int retryCount, TimeSpan initialInterval, TimeSpan increment, bool firstFastRetry)
+ public Incremental(string? name, int retryCount, TimeSpan initialInterval, TimeSpan increment, bool firstFastRetry)
: base(name, firstFastRetry)
{
//Guard.ArgumentNotNegativeValue(retryCount, "retryCount");
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs
index 8cd01e706c..fc7bb72b6b 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
{
public bool IsTransient(Exception ex)
{
- SqlException sqlException;
+ SqlException? sqlException;
if (ex != null && (sqlException = ex as SqlException) != null)
{
diff --git a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
index faf6442333..2711ce4714 100644
--- a/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
@@ -79,7 +79,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
{
if (ex != null)
{
- SqlException sqlException;
+ SqlException? sqlException;
if ((sqlException = ex as SqlException) != null)
{
// Enumerate through all errors found in the exception.
diff --git a/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs b/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs
index 6a38dc3c06..2de1bcef16 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/Mappers/BaseMapper.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
index 239d114184..bc0deb56f1 100644
--- a/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Mappers
private readonly object _definedLock = new object();
private readonly MapperConfigurationStore _maps;
- private ISqlSyntaxProvider _sqlSyntax;
+ private ISqlSyntaxProvider? _sqlSyntax;
private bool _defined;
protected BaseMapper(Lazy sqlContext, MapperConfigurationStore maps)
diff --git a/src/Umbraco.Infrastructure/Persistence/Mappers/IMapperCollection.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/IMapperCollection.cs
index 110d65392c..db2f104ed7 100644
--- a/src/Umbraco.Infrastructure/Persistence/Mappers/IMapperCollection.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Mappers/IMapperCollection.cs
@@ -1,11 +1,12 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using Umbraco.Cms.Core.Composing;
namespace Umbraco.Cms.Infrastructure.Persistence.Mappers
{
public interface IMapperCollection : IBuilderCollection
{
- bool TryGetMapper(Type type, out BaseMapper mapper);
+ bool TryGetMapper(Type type, [MaybeNullWhen(false)] out BaseMapper mapper);
BaseMapper this[Type type] { get; }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Mappers/MapperCollection.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/MapperCollection.cs
index feaacd714b..aab89f8cd9 100644
--- a/src/Umbraco.Infrastructure/Persistence/Mappers/MapperCollection.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Mappers/MapperCollection.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Umbraco.Cms.Core.Composing;
using Umbraco.Extensions;
@@ -44,6 +45,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Mappers
}
}
- public bool TryGetMapper(Type type, out BaseMapper mapper) => _index.Value.TryGetValue(type, out mapper);
+ public bool TryGetMapper(Type type,[MaybeNullWhen(false)] out BaseMapper mapper) => _index.Value.TryGetValue(type, out mapper);
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Mappers/NullableDateMapper.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/NullableDateMapper.cs
index c647c4b93e..86f5401e52 100644
--- a/src/Umbraco.Infrastructure/Persistence/Mappers/NullableDateMapper.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Mappers/NullableDateMapper.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Mappers
///
public class NullableDateMapper : DefaultMapper
{
- public override Func GetToDbConverter(Type destType, MemberInfo sourceMemberInfo)
+ public override Func? GetToDbConverter(Type destType, MemberInfo sourceMemberInfo)
{
// ensures that NPoco does not try to insert an invalid date
// from a nullable DateTime property
diff --git a/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs b/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
index 05f15f7372..72b3f2cf5f 100644
--- a/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
@@ -25,7 +25,7 @@ namespace Umbraco.Extensions
/// A predicate to transform and append to the Sql statement.
/// An optional alias for the table.
/// The Sql statement.
- public static Sql Where(this Sql sql, Expression> predicate, string alias = null)
+ public static Sql Where(this Sql sql, Expression> predicate, string? alias = null)
{
var (s, a) = sql.SqlContext.VisitDto(predicate, alias);
return sql.Where(s, a);
@@ -41,7 +41,7 @@ namespace Umbraco.Extensions
/// An optional alias for Dto 1 table.
/// An optional alias for Dto 2 table.
/// The Sql statement.
- public static Sql Where(this Sql sql, Expression> predicate, string alias1 = null, string alias2 = null)
+ public static Sql Where(this Sql sql, Expression> predicate, string? alias1 = null, string? alias2 = null)
{
var (s, a) = sql.SqlContext.VisitDto(predicate, alias1, alias2);
return sql.Where(s, a);
@@ -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