From 14f6918f173222ba0b6b6d26bccf4e692feb2c18 Mon Sep 17 00:00:00 2001 From: Mika Herrmann Date: Mon, 29 Jan 2024 13:30:41 +0100 Subject: [PATCH 01/12] Make fields in data calsses required/nullable --- .../Files/DTOs/FileMetadataDTO.cs | 30 +++++++++---------- .../GetFileContent/GetFileContentQuery.cs | 2 +- .../GetFileContent/GetFileContentResponse.cs | 2 +- .../GetFileMetadata/GetFileMetadataQuery.cs | 2 +- .../Infrastructure/Persistence/BlobOptions.cs | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Modules/Files/src/Files.Application/Files/DTOs/FileMetadataDTO.cs b/Modules/Files/src/Files.Application/Files/DTOs/FileMetadataDTO.cs index f4c4784ddf..8d5f36bf37 100644 --- a/Modules/Files/src/Files.Application/Files/DTOs/FileMetadataDTO.cs +++ b/Modules/Files/src/Files.Application/Files/DTOs/FileMetadataDTO.cs @@ -8,29 +8,29 @@ namespace Backbone.Modules.Files.Application.Files.DTOs; public class FileMetadataDTO : IHaveCustomMapping { - public FileId Id { get; set; } + public required FileId Id { get; set; } - public DateTime CreatedAt { get; set; } - public IdentityAddress CreatedBy { get; set; } - public DeviceId CreatedByDevice { get; set; } + public required DateTime CreatedAt { get; set; } + public required IdentityAddress CreatedBy { get; set; } + public required DeviceId CreatedByDevice { get; set; } - public DateTime ModifiedAt { get; set; } - public IdentityAddress ModifiedBy { get; set; } - public DeviceId ModifiedByDevice { get; set; } + public required DateTime ModifiedAt { get; set; } + public required IdentityAddress ModifiedBy { get; set; } + public required DeviceId ModifiedByDevice { get; set; } public DateTime? DeletedAt { get; set; } - public IdentityAddress DeletedBy { get; set; } - public DeviceId DeletedByDevice { get; set; } + public IdentityAddress? DeletedBy { get; set; } + public DeviceId? DeletedByDevice { get; set; } - public IdentityAddress Owner { get; set; } - public byte[] OwnerSignature { get; set; } + public required IdentityAddress Owner { get; set; } + public required byte[] OwnerSignature { get; set; } - public long CipherSize { get; set; } - public byte[] CipherHash { get; set; } + public required long CipherSize { get; set; } + public required byte[] CipherHash { get; set; } - public DateTime ExpiresAt { get; set; } + public required DateTime ExpiresAt { get; set; } - public byte[] EncryptedProperties { get; set; } + public required byte[] EncryptedProperties { get; set; } public void CreateMappings(Profile configuration) { diff --git a/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentQuery.cs b/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentQuery.cs index b03a268cc4..a1261bfbec 100644 --- a/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentQuery.cs +++ b/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentQuery.cs @@ -5,5 +5,5 @@ namespace Backbone.Modules.Files.Application.Files.Queries.GetFileContent; public class GetFileContentQuery : IRequest { - public FileId Id { get; set; } + public required FileId Id { get; set; } } diff --git a/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentResponse.cs b/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentResponse.cs index cad268999e..648b6c2f61 100644 --- a/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentResponse.cs +++ b/Modules/Files/src/Files.Application/Files/Queries/GetFileContent/GetFileContentResponse.cs @@ -2,5 +2,5 @@ public class GetFileContentResponse { - public byte[] FileContent { get; set; } + public required byte[] FileContent { get; set; } } diff --git a/Modules/Files/src/Files.Application/Files/Queries/GetFileMetadata/GetFileMetadataQuery.cs b/Modules/Files/src/Files.Application/Files/Queries/GetFileMetadata/GetFileMetadataQuery.cs index 137a62d0f6..3621b0cc2e 100644 --- a/Modules/Files/src/Files.Application/Files/Queries/GetFileMetadata/GetFileMetadataQuery.cs +++ b/Modules/Files/src/Files.Application/Files/Queries/GetFileMetadata/GetFileMetadataQuery.cs @@ -6,5 +6,5 @@ namespace Backbone.Modules.Files.Application.Files.Queries.GetFileMetadata; public class GetFileMetadataQuery : IRequest { - public FileId Id { get; set; } + public required FileId Id { get; set; } } diff --git a/Modules/Files/src/Files.Application/Infrastructure/Persistence/BlobOptions.cs b/Modules/Files/src/Files.Application/Infrastructure/Persistence/BlobOptions.cs index 48b6842940..ff8a3e34b2 100644 --- a/Modules/Files/src/Files.Application/Infrastructure/Persistence/BlobOptions.cs +++ b/Modules/Files/src/Files.Application/Infrastructure/Persistence/BlobOptions.cs @@ -2,5 +2,5 @@ public class BlobOptions { - public string RootFolder { get; set; } + public required string RootFolder { get; set; } } From 208bbf272a88794c4c15c4409443f301dcf85b86 Mon Sep 17 00:00:00 2001 From: Mika Herrmann Date: Mon, 29 Jan 2024 13:36:10 +0100 Subject: [PATCH 02/12] Make FilesRepository Find method nullable --- .../Infrastructure/Persistence/Repository/IFilesRepository.cs | 2 +- .../Persistence/Database/Repository/FilesRepository.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Files/src/Files.Application/Infrastructure/Persistence/Repository/IFilesRepository.cs b/Modules/Files/src/Files.Application/Infrastructure/Persistence/Repository/IFilesRepository.cs index 7507e0fc1a..093480cdf8 100644 --- a/Modules/Files/src/Files.Application/Infrastructure/Persistence/Repository/IFilesRepository.cs +++ b/Modules/Files/src/Files.Application/Infrastructure/Persistence/Repository/IFilesRepository.cs @@ -7,7 +7,7 @@ namespace Backbone.Modules.Files.Application.Infrastructure.Persistence.Repository; public interface IFilesRepository { - Task Find(FileId id, CancellationToken cancellationToken, bool track = false, bool fillContent = true); + Task Find(FileId id, CancellationToken cancellationToken, bool track = false, bool fillContent = true); Task> FindFilesByCreator(IEnumerable fileIds, IdentityAddress creatorAddress, PaginationFilter paginationFilter, CancellationToken cancellationToken); Task Add(File file, CancellationToken cancellationToken); } diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/Repository/FilesRepository.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/Repository/FilesRepository.cs index abb6ab6a9d..cb721aa6e3 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/Repository/FilesRepository.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/Repository/FilesRepository.cs @@ -38,7 +38,7 @@ public async Task Add(File file, CancellationToken cancellationToken) } - public async Task Find(FileId fileId, CancellationToken cancellationToken, bool track = false, bool fillContent = true) + public async Task Find(FileId fileId, CancellationToken cancellationToken, bool track = false, bool fillContent = true) { var file = await (track ? _files : _readOnlyFiles) .WithId(fileId) From 56ca6ae34d25ad21b597d0e63ae5c85f64cf1ee8 Mon Sep 17 00:00:00 2001 From: Mika Herrmann Date: Mon, 29 Jan 2024 13:37:41 +0100 Subject: [PATCH 03/12] Remove redundant null checks --- .../Persistence/Database/IServiceCollectionExtensions.cs | 6 +++--- .../ValueConverters/FileIdEntityFrameworkValueConverter.cs | 2 +- .../Persistence/IServiceCollectionExtensions.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index e20fb08f5c..ca094296d5 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -15,7 +15,7 @@ public static class IServiceCollectionExtensions public static void AddDatabase(this IServiceCollection services, Action setupOptions) { var options = new DbOptions(); - setupOptions?.Invoke(options); + setupOptions.Invoke(options); services.AddDatabase(options); } @@ -56,8 +56,8 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio public class DbOptions { - public string Provider { get; set; } - public string DbConnectionString { get; set; } + public string Provider { get; set; } = string.Empty; + public string DbConnectionString { get; set; } = string.Empty; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs index 4545be81d6..da522a6e8e 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs @@ -9,7 +9,7 @@ public FileIdEntityFrameworkValueConverter() : this(null) { } public FileIdEntityFrameworkValueConverter(ConverterMappingHints mappingHints) : base( - id => id == null ? null : id.StringValue, + id => id.StringValue, value => FileId.Parse(value), mappingHints ) diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs b/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs index d47f5dbb6d..0d3847a883 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs @@ -11,7 +11,7 @@ public static class IServiceCollectionExtensions public static void AddPersistence(this IServiceCollection services, Action setupOptions) { var options = new PersistenceOptions(); - setupOptions?.Invoke(options); + setupOptions.Invoke(options); services.AddPersistence(options); } From 18fdd4d502972d14d0735507fec926a5e08fee12 Mon Sep 17 00:00:00 2001 From: Mika Herrmann Date: Mon, 29 Jan 2024 13:39:12 +0100 Subject: [PATCH 04/12] Assert Container is non-null --- .../Persistence/IServiceCollectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs b/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs index 0d3847a883..8a7c4da2e4 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs @@ -20,7 +20,7 @@ public static void AddPersistence(this IServiceCollection services, PersistenceO { services.AddDatabase(options.DbOptions); services.Configure(blobOptions => - blobOptions.RootFolder = options.BlobStorageOptions.Container); + blobOptions.RootFolder = options.BlobStorageOptions.Container!); services.AddBlobStorage(options.BlobStorageOptions); services.AddTransient(); From 00502b41bb8cf564d4dbd4e6384537e4300b536c Mon Sep 17 00:00:00 2001 From: Mika Herrmann Date: Mon, 29 Jan 2024 13:39:51 +0100 Subject: [PATCH 05/12] Use default ConverterMappingHints --- .../ValueConverters/FileIdEntityFrameworkValueConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs index da522a6e8e..16ad39e10e 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/ValueConverters/FileIdEntityFrameworkValueConverter.cs @@ -5,7 +5,7 @@ namespace Backbone.Modules.Files.Infrastructure.Persistence.Database.ValueConver public class FileIdEntityFrameworkValueConverter : ValueConverter { - public FileIdEntityFrameworkValueConverter() : this(null) { } + public FileIdEntityFrameworkValueConverter() : this(new ConverterMappingHints()) { } public FileIdEntityFrameworkValueConverter(ConverterMappingHints mappingHints) : base( From 8e9d4a7b14946f903f4e10cd067048952a5d5827 Mon Sep 17 00:00:00 2001 From: Mika Herrmann Date: Mon, 29 Jan 2024 13:41:31 +0100 Subject: [PATCH 06/12] Add default initializers --- .../Persistence/Database/FilesDbContext.cs | 2 +- .../Infrastructure/SanityCheck/SanityCheck.cs | 2 ++ Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/FilesDbContext.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/FilesDbContext.cs index d45bd1875c..c7488e12b2 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/FilesDbContext.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/FilesDbContext.cs @@ -15,7 +15,7 @@ public FilesDbContext(DbContextOptions options) : base(options) public FilesDbContext(DbContextOptions options, IServiceProvider serviceProvider) : base(options, serviceProvider) { } - public DbSet FileMetadata { get; set; } + public DbSet FileMetadata { get; set; } = null!; protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { diff --git a/Modules/Files/src/Files.Jobs.SanityCheck/Infrastructure/SanityCheck/SanityCheck.cs b/Modules/Files/src/Files.Jobs.SanityCheck/Infrastructure/SanityCheck/SanityCheck.cs index 643a164e46..4a9b15b88d 100644 --- a/Modules/Files/src/Files.Jobs.SanityCheck/Infrastructure/SanityCheck/SanityCheck.cs +++ b/Modules/Files/src/Files.Jobs.SanityCheck/Infrastructure/SanityCheck/SanityCheck.cs @@ -15,6 +15,8 @@ public SanityCheck(IDataSource dataSource, IReporter reporter) { _dataSource = dataSource; _reporter = reporter; + _databaseIds = []; + _blobIds = []; } public async Task Run(CancellationToken cancellationToken) diff --git a/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs b/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs index fab043f432..f67b81b66f 100644 --- a/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs +++ b/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs @@ -14,6 +14,8 @@ public Worker(IHostApplicationLifetime host, IServiceScopeFactory serviceScopeFa { _host = host; _serviceScopeFactory = serviceScopeFactory; + _dataSource = null!; + _reporter = null!; } public async Task StartAsync(CancellationToken cancellationToken) @@ -33,7 +35,7 @@ public Task StopAsync(CancellationToken cancellationToken) return Task.CompletedTask; } - public async Task RunSanityCheck(CancellationToken cancellationToken) + private async Task RunSanityCheck(CancellationToken cancellationToken) { var sanityCheck = new Infrastructure.SanityCheck.SanityCheck(_dataSource, _reporter); From e334d821868c3531b929447566b5115aa070798d Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 9 Feb 2024 11:53:46 +0100 Subject: [PATCH 07/12] chore: use null! instead of string.Empty --- .../Persistence/Database/IServiceCollectionExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index ca094296d5..928bc4e440 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -56,8 +56,8 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio public class DbOptions { - public string Provider { get; set; } = string.Empty; - public string DbConnectionString { get; set; } = string.Empty; + public string Provider { get; set; } = null!; + public string DbConnectionString { get; set; } = null!; public RetryOptions RetryOptions { get; set; } = new(); } From 8e43a8d4bf7848aa01af3e87b7c731c44b9f4b0a Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 9 Feb 2024 11:58:40 +0100 Subject: [PATCH 08/12] chore: make properties in BlobStorageOptions not nullable --- .../BlobStorageServiceCollectionExtensions.cs | 14 ++++---------- .../Persistence/IServiceCollectionExtensions.cs | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs b/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs index f2921a0c4c..cef3cc516b 100644 --- a/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs +++ b/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs @@ -29,7 +29,7 @@ public static void AddBlobStorage(this IServiceCollection services, BlobStorageO services.AddGoogleCloudStorage(googleCloudStorageOptions => { googleCloudStorageOptions.GcpAuthJson = options.ConnectionInfo; - googleCloudStorageOptions.BucketName = options.Container!; + googleCloudStorageOptions.BucketName = options.Container; }); else if (options.CloudProvider.IsNullOrEmpty()) throw new NotSupportedException("No cloud provider was specified."); @@ -41,15 +41,9 @@ public static void AddBlobStorage(this IServiceCollection services, BlobStorageO public class BlobStorageOptions { - /** - * This property will never be null as it makes no sense, but is marked as nullable due to how AddBlobStorage method uses BlobStorageOptions. - */ - public string? CloudProvider { get; set; } + public string CloudProvider { get; set; } = null!; - /** - * This property will never be null as it makes no sense, but is marked as nullable due to how AddBlobStorage method uses BlobStorageOptions. - */ - public string? Container { get; set; } + public string Container { get; set; } = null!; - public string? ConnectionInfo { get; set; } + public string? ConnectionInfo { get; set; } = null!; } diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs b/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs index 8a7c4da2e4..0d3847a883 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/IServiceCollectionExtensions.cs @@ -20,7 +20,7 @@ public static void AddPersistence(this IServiceCollection services, PersistenceO { services.AddDatabase(options.DbOptions); services.Configure(blobOptions => - blobOptions.RootFolder = options.BlobStorageOptions.Container!); + blobOptions.RootFolder = options.BlobStorageOptions.Container); services.AddBlobStorage(options.BlobStorageOptions); services.AddTransient(); From ec9902cd0f02414d6a4db31b6bd7fc95c65a26dd Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 9 Feb 2024 11:59:04 +0100 Subject: [PATCH 09/12] chore: minor cleanup --- Backbone.sln.DotSettings | 1 + Modules/Files/src/Files.Domain/Entities/File.cs | 17 ++++++++++++++--- .../FileEntityTypeConfiguration.cs | 2 +- .../test/Files.Application.Tests/TestData.cs | 8 ++++---- .../Infrastructure/DataSource/FakeDataSource.cs | 4 ++-- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Backbone.sln.DotSettings b/Backbone.sln.DotSettings index 678e39afaf..2b6eef206f 100644 --- a/Backbone.sln.DotSettings +++ b/Backbone.sln.DotSettings @@ -36,6 +36,7 @@ True True True + True True True True diff --git a/Modules/Files/src/Files.Domain/Entities/File.cs b/Modules/Files/src/Files.Domain/Entities/File.cs index e10bd9f454..9f69b8d208 100644 --- a/Modules/Files/src/Files.Domain/Entities/File.cs +++ b/Modules/Files/src/Files.Domain/Entities/File.cs @@ -6,9 +6,20 @@ namespace Backbone.Modules.Files.Domain.Entities; public class File { -#pragma warning disable CS8618 - private File() { } -#pragma warning restore CS8618 + private File() + { + // This constructor is for EF Core only; initializing the properties with null is therefore not a problem + Id = null!; + CreatedBy = null!; + CreatedByDevice = null!; + ModifiedBy = null!; + ModifiedByDevice = null!; + Owner = null!; + OwnerSignature = null!; + CipherHash = null!; + Content = null!; + EncryptedProperties = null!; + } public File(IdentityAddress createdBy, DeviceId createdByDevice, IdentityAddress owner, byte[] ownerSignature, byte[] cipherHash, byte[] content, long cipherSize, DateTime expiresAt, byte[] encryptedProperties) { diff --git a/Modules/Files/src/Files.Infrastructure/Persistence/Database/EntityTypeConfigurations/FileEntityTypeConfiguration.cs b/Modules/Files/src/Files.Infrastructure/Persistence/Database/EntityTypeConfigurations/FileEntityTypeConfiguration.cs index c8e30521a8..b406bc11ca 100644 --- a/Modules/Files/src/Files.Infrastructure/Persistence/Database/EntityTypeConfigurations/FileEntityTypeConfiguration.cs +++ b/Modules/Files/src/Files.Infrastructure/Persistence/Database/EntityTypeConfigurations/FileEntityTypeConfiguration.cs @@ -4,7 +4,7 @@ namespace Backbone.Modules.Files.Infrastructure.Persistence.Database.EntityTypeConfigurations; -public class FileEntityTypeConfiguration : IEntityTypeConfiguration +public class FileEntityTypeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { diff --git a/Modules/Files/test/Files.Application.Tests/TestData.cs b/Modules/Files/test/Files.Application.Tests/TestData.cs index 662d5415e2..98c2422125 100644 --- a/Modules/Files/test/Files.Application.Tests/TestData.cs +++ b/Modules/Files/test/Files.Application.Tests/TestData.cs @@ -31,9 +31,9 @@ public static class Devices public static class Payloads { - public static readonly byte[] EMPTY = Array.Empty(); - public static readonly byte[] PAYLOAD_1 = { 1, 1, 1 }; - public static readonly byte[] PAYLOAD_2 = { 2, 2, 2 }; - public static readonly byte[] PAYLOAD_3 = { 3, 3, 3 }; + public static readonly byte[] EMPTY = []; + public static readonly byte[] PAYLOAD_1 = [1, 1, 1]; + public static readonly byte[] PAYLOAD_2 = [2, 2, 2]; + public static readonly byte[] PAYLOAD_3 = [3, 3, 3]; } } diff --git a/Modules/Files/test/Files.Jobs.SanityCheck.Tests/Infrastructure/DataSource/FakeDataSource.cs b/Modules/Files/test/Files.Jobs.SanityCheck.Tests/Infrastructure/DataSource/FakeDataSource.cs index 49907c2013..625a7e12a7 100644 --- a/Modules/Files/test/Files.Jobs.SanityCheck.Tests/Infrastructure/DataSource/FakeDataSource.cs +++ b/Modules/Files/test/Files.Jobs.SanityCheck.Tests/Infrastructure/DataSource/FakeDataSource.cs @@ -5,8 +5,8 @@ namespace Backbone.Modules.Files.Jobs.SanityCheck.Tests.Infrastructure.DataSourc public class FakeDataSource : IDataSource { - public List DatabaseIds { get; } = new(); - public List BlobIds { get; } = new(); + public List DatabaseIds { get; } = []; + public List BlobIds { get; } = []; public Task> GetBlobIdsAsync(CancellationToken cancellationToken) { From 9a722436d820d0893f7ee8dead1a5b1f5f42ac48 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 9 Feb 2024 12:58:25 +0100 Subject: [PATCH 10/12] chore: add explaining comment to usage of null! --- Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs b/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs index f67b81b66f..6c82448355 100644 --- a/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs +++ b/Modules/Files/src/Files.Jobs.SanityCheck/Worker.cs @@ -14,6 +14,8 @@ public Worker(IHostApplicationLifetime host, IServiceScopeFactory serviceScopeFa { _host = host; _serviceScopeFactory = serviceScopeFactory; + + // the following fields are initialized in StartAsync, which is always called before any other method _dataSource = null!; _reporter = null!; } From 3e0dd33a00ccdc766c2f23ffd0c6cc9154bc263f Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 9 Feb 2024 12:59:45 +0100 Subject: [PATCH 11/12] chore: initialize ConnectionInfo with null! --- .../BlobStorage/BlobStorageServiceCollectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs b/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs index cef3cc516b..7ef97b7b47 100644 --- a/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs +++ b/BuildingBlocks/src/BuildingBlocks.Infrastructure/Persistence/BlobStorage/BlobStorageServiceCollectionExtensions.cs @@ -45,5 +45,5 @@ public class BlobStorageOptions public string Container { get; set; } = null!; - public string? ConnectionInfo { get; set; } = null!; + public string? ConnectionInfo { get; set; } = null; } From 2989eddb6eac65c4dc1e085af3a2fe220b8e478e Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 9 Feb 2024 13:03:57 +0100 Subject: [PATCH 12/12] chore: remove unnecessary stuff from .csproj files --- .../src/Files.Infrastructure/Files.Infrastructure.csproj | 6 ------ .../Files.Jobs.SanityCheck/Files.Jobs.SanityCheck.csproj | 1 - 2 files changed, 7 deletions(-) diff --git a/Modules/Files/src/Files.Infrastructure/Files.Infrastructure.csproj b/Modules/Files/src/Files.Infrastructure/Files.Infrastructure.csproj index b535e7f37d..3d377fd7c1 100644 --- a/Modules/Files/src/Files.Infrastructure/Files.Infrastructure.csproj +++ b/Modules/Files/src/Files.Infrastructure/Files.Infrastructure.csproj @@ -4,12 +4,6 @@ enable - - - - - - diff --git a/Modules/Files/src/Files.Jobs.SanityCheck/Files.Jobs.SanityCheck.csproj b/Modules/Files/src/Files.Jobs.SanityCheck/Files.Jobs.SanityCheck.csproj index a338edbbc7..24463953d1 100644 --- a/Modules/Files/src/Files.Jobs.SanityCheck/Files.Jobs.SanityCheck.csproj +++ b/Modules/Files/src/Files.Jobs.SanityCheck/Files.Jobs.SanityCheck.csproj @@ -1,7 +1,6 @@  - dotnet-Files.Jobs.SanityCheck-9f22e8e4-eb64-498c-9599-b971e0419647 Linux ..\..\..\.. enable