From 9984e6d0a780fad73d924b0c40713c80dd14f373 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 25 Aug 2023 13:35:40 +0800 Subject: [PATCH] Eliminate nullable warnings. --- .../Server.Mongo/MyProjectNameHostModule.cs | 2 +- .../Server/MyProjectNameHostModule.cs | 2 +- .../MyProjectNameModule.cs | 2 +- .../MyProjectNameModule.cs | 2 +- .../MyProjectNameAuthServerModule.cs | 5 ++--- .../MyProjectNameBlazorModule.cs | 5 ++--- .../OpenIddict/OpenIddictDataSeedContributor.cs | 9 ++++----- .../MyProjectNameHttpApiHostModule.cs | 7 +++---- .../MyProjectNameHttpApiHostModule.cs | 2 +- .../Models/Test/TestModel.cs | 2 +- .../MyProjectNameWebModule.cs | 5 ++--- .../MyProjectNameAuthServerModule.cs | 2 +- .../OpenIddict/OpenIddictDataSeedContributor.cs | 2 +- .../MyProjectNameHttpApiHostModule.cs | 4 ++-- .../MyProjectNameWebHostMenuContributor.cs | 2 +- .../MyProjectNameWebHostModule.cs | 2 +- 16 files changed, 25 insertions(+), 30 deletions(-) diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/MyProjectNameHostModule.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/MyProjectNameHostModule.cs index fb5de452d2..ca98281863 100644 --- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/MyProjectNameHostModule.cs +++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server.Mongo/MyProjectNameHostModule.cs @@ -197,7 +197,7 @@ public class MyProjectNameHostModule : AbpModule private void ConfigureSwagger(IServiceCollection services, IConfiguration configuration) { services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/MyProjectNameHostModule.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/MyProjectNameHostModule.cs index 2925af8d67..000fbd1e38 100644 --- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/MyProjectNameHostModule.cs +++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Blazor.WebAssembly/Server/MyProjectNameHostModule.cs @@ -200,7 +200,7 @@ public class MyProjectNameHostModule : AbpModule private void ConfigureSwagger(IServiceCollection services, IConfiguration configuration) { services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/MyProjectNameModule.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/MyProjectNameModule.cs index aa072a238e..400e865d1d 100644 --- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/MyProjectNameModule.cs +++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host.Mongo/MyProjectNameModule.cs @@ -241,7 +241,7 @@ public class MyProjectNameModule : AbpModule private void ConfigureSwagger(IServiceCollection services, IConfiguration configuration) { services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} diff --git a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/MyProjectNameModule.cs b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/MyProjectNameModule.cs index bbc6b36262..792e93fe86 100644 --- a/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/MyProjectNameModule.cs +++ b/templates/app-nolayers/aspnet-core/MyCompanyName.MyProjectName.Host/MyProjectNameModule.cs @@ -244,7 +244,7 @@ public class MyProjectNameModule : AbpModule private void ConfigureSwagger(IServiceCollection services, IConfiguration configuration) { services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs index c8f1c89424..b044af0d06 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs @@ -133,14 +133,13 @@ public class MyProjectNameAuthServerModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } context.Services.AddSingleton(sp => { - var connection = ConnectionMultiplexer - .Connect(configuration["Redis:Configuration"]); + var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); }); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs index fa55b7d44f..1d8bcfd636 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs @@ -265,7 +265,7 @@ public class MyProjectNameBlazorModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } } @@ -276,8 +276,7 @@ public class MyProjectNameBlazorModule : AbpModule { context.Services.AddSingleton(sp => { - var connection = ConnectionMultiplexer - .Connect(configuration["Redis:Configuration"]); + var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); }); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs index 775c72aaca..ccf35ec026 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs @@ -83,7 +83,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep var webClientId = configurationSection["MyProjectName_Web:ClientId"]; if (!webClientId.IsNullOrWhiteSpace()) { - var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); + var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"]!.EnsureEndsWith('/'); /* MyProjectName_Web client is only needed if you created a tiered * solution. Otherwise, you can delete this client. */ @@ -152,8 +152,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"]; if (!blazorServerTieredClientId.IsNullOrWhiteSpace()) { - var blazorServerTieredRootUrl = - configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/'); + var blazorServerTieredRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"]!.EnsureEndsWith('/'); await CreateApplicationAsync( name: blazorServerTieredClientId!, @@ -218,7 +217,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep } var client = await _openIddictApplicationRepository.FindByClientIdAsync(name); - + var application = new AbpApplicationDescriptor { ClientId = name, Type = type, @@ -412,4 +411,4 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep { return existingClient.Permissions == JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/'))); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index c848b1f774..91302e428a 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -110,7 +110,7 @@ public class MyProjectNameHttpApiHostModule : AbpModule private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} @@ -131,7 +131,7 @@ public class MyProjectNameHttpApiHostModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } } @@ -142,8 +142,7 @@ public class MyProjectNameHttpApiHostModule : AbpModule { context.Services.AddSingleton(sp => { - var connection = ConnectionMultiplexer - .Connect(configuration["Redis:Configuration"]); + var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); }); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs index dd79fb773c..fe71a42e9a 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs @@ -137,7 +137,7 @@ public class MyProjectNameHttpApiHostModule : AbpModule private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs index 8700b992ef..f07f7ba521 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs @@ -4,7 +4,7 @@ namespace MyCompanyName.MyProjectName.Models.Test; public class TestModel { - public string Name { get; set; } + public string? Name { get; set; } public DateTime BirthDate { get; set; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 8e8ac6c694..1fd1133c0a 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -229,7 +229,7 @@ public class MyProjectNameWebModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } } @@ -240,8 +240,7 @@ public class MyProjectNameWebModule : AbpModule { context.Services.AddSingleton(sp => { - var connection = ConnectionMultiplexer - .Connect(configuration["Redis:Configuration"]); + var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); }); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs index 5fef3d79a8..9819154b9b 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs @@ -165,7 +165,7 @@ public class MyProjectNameAuthServerModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs index 6423cf037b..6d18e53622 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.AuthServer/OpenIddict/OpenIddictDataSeedContributor.cs @@ -81,7 +81,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep var webClientId = configurationSection["MyProjectName_Web:ClientId"]; if (!webClientId.IsNullOrWhiteSpace()) { - var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); + var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"]!.EnsureEndsWith('/'); /* MyProjectName_Web client is only needed if you created a tiered * solution. Otherwise, you can delete this client. */ diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index bc1ec583b6..c73725aaa0 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -81,7 +81,7 @@ public class MyProjectNameHttpApiHostModule : AbpModule } context.Services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], + configuration["AuthServer:Authority"]!, new Dictionary { {"MyProjectName", "MyProjectName API"} @@ -133,7 +133,7 @@ public class MyProjectNameHttpApiHostModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs index 7c47c56d2d..9cef51e86d 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs @@ -37,7 +37,7 @@ public class MyProjectNameWebHostMenuContributor : IMenuContributor context.Menu.Items.Add(new ApplicationMenuItem( "Account.Manage", l["MyAccount"], - $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", + $"{_configuration["AuthServer:Authority"]!.EnsureEndsWith('/')}Account/Manage", icon: "fa fa-cog", order: int.MaxValue - 1001, null, diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs index a76d628ecb..6a1255fa9d 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs @@ -219,7 +219,7 @@ public class MyProjectNameWebHostModule : AbpModule var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); if (!hostingEnvironment.IsDevelopment()) { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } }