From e92a6a28ecf5cb4ee724d7f43e96beb5d6f24354 Mon Sep 17 00:00:00 2001 From: Omar Boukli-Hacene Date: Thu, 8 Feb 2024 22:10:17 +0200 Subject: [PATCH] refactor: Fix false positive null reference --- src/Aktabook.Bus/Program.cs | 4 ++-- .../ConfigurationManagerExtensions.cs | 4 ++-- .../RequesterServiceDbContextSqlServerDestructiveFixture.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Aktabook.Bus/Program.cs b/src/Aktabook.Bus/Program.cs index 2f04902..70a8be9 100644 --- a/src/Aktabook.Bus/Program.cs +++ b/src/Aktabook.Bus/Program.cs @@ -78,7 +78,7 @@ TelemetryOptions telemetryOptions = context .Configuration .GetRequiredSection(nameof(TelemetryOptions)) - .Get(); + .Get()!; services.AddSingleton(new ActivitySource(telemetryOptions.ServiceName)); services.AddOpenTelemetry() @@ -100,7 +100,7 @@ OpenLibraryClientOptions openLibraryClientOptions = context .Configuration .GetRequiredSection(nameof(OpenLibraryClientOptions)) - .Get(); + .Get()!; services.AddOpenLibraryClient(openLibraryClientOptions); services.AddScoped(); diff --git a/src/Aktabook.Infrastructure.Configuration/ConfigurationManagerExtensions.cs b/src/Aktabook.Infrastructure.Configuration/ConfigurationManagerExtensions.cs index 803b7d7..df6b0dc 100644 --- a/src/Aktabook.Infrastructure.Configuration/ConfigurationManagerExtensions.cs +++ b/src/Aktabook.Infrastructure.Configuration/ConfigurationManagerExtensions.cs @@ -16,13 +16,13 @@ public static SqlConnectionStringBuilder GetSqlConnectionStringBuilderFrom( { return configuration .GetRequiredSection(section) - .Get(options => options.ErrorOnUnknownConfiguration = true); + .Get(options => options.ErrorOnUnknownConfiguration = true)!; } public static string GetRabbitMqBusConnectionString(this IConfiguration configuration, string section) { return configuration .GetRequiredSection(section) - .Get().ConnectionUri.ToString(); + .Get()!.ConnectionUri.ToString(); } } diff --git a/test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs b/test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs index 46d8286..c6903d2 100644 --- a/test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs +++ b/test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs @@ -44,7 +44,7 @@ public RequesterServiceDbContext CreateDbContext() _connectionString = new ConfigurationFactory() .Configuration .GetRequiredSection(DbContextConstants.RequesterServiceDbContextSqlServerSection) - .Get(options => options.ErrorOnUnknownConfiguration = true) + .Get(options => options.ErrorOnUnknownConfiguration = true)! .ConnectionString; }