diff --git a/ChatRPG/API/HttpMessageHandlerFactory.cs b/ChatRPG/API/HttpMessageHandlerFactory.cs index 9fa9ce8..4d874d5 100644 --- a/ChatRPG/API/HttpMessageHandlerFactory.cs +++ b/ChatRPG/API/HttpMessageHandlerFactory.cs @@ -28,7 +28,7 @@ public HttpMessageHandler CreateHandler(string name) private static HttpResponseMessage GenerateMockResponse(HttpRequestMessage request) { Console.Write("Please enter mocked API response: "); - string input = Console.ReadLine(); + string? input = Console.ReadLine(); StringContent responseContent = new StringContent($$""" { "id": "chatcmpl-000", diff --git a/ChatRPG/API/OpenAiLlmClient.cs b/ChatRPG/API/OpenAiLlmClient.cs index bb48e4d..1324eef 100644 --- a/ChatRPG/API/OpenAiLlmClient.cs +++ b/ChatRPG/API/OpenAiLlmClient.cs @@ -13,7 +13,7 @@ public class OpenAiLlmClient : IOpenAiLlmClient public OpenAiLlmClient(IConfiguration configuration, IHttpClientFactory httpClientFactory) { - _openAiApi = new OpenAIAPI(configuration.GetSection("ApiKeys").GetValue("OpenAI") ?? string.Empty); + _openAiApi = new OpenAIAPI(configuration.GetSection("ApiKeys")?.GetValue("OpenAI")); _openAiApi.Chat.DefaultChatRequestArgs.Model = Model; _openAiApi.Chat.DefaultChatRequestArgs.Temperature = Temperature; _openAiApi.HttpClientFactory = httpClientFactory; diff --git a/ChatRPG/Areas/Identity/RevalidatingIdentityAuthenticationStateProvider.cs b/ChatRPG/Areas/Identity/RevalidatingIdentityAuthenticationStateProvider.cs index b869596..10e59d2 100644 --- a/ChatRPG/Areas/Identity/RevalidatingIdentityAuthenticationStateProvider.cs +++ b/ChatRPG/Areas/Identity/RevalidatingIdentityAuthenticationStateProvider.cs @@ -31,7 +31,7 @@ protected override async Task ValidateAuthenticationStateAsync( IServiceScope scope = _scopeFactory.CreateScope(); try { - UserManager userManager = scope.ServiceProvider.GetRequiredService>(); + UserManager userManager = scope.ServiceProvider.GetRequiredService>(); return await ValidateSecurityStampAsync(userManager, authenticationState.User); } finally @@ -47,7 +47,7 @@ protected override async Task ValidateAuthenticationStateAsync( } } - private async Task ValidateSecurityStampAsync(UserManager userManager, ClaimsPrincipal principal) + private async Task ValidateSecurityStampAsync(UserManager userManager, ClaimsPrincipal principal) { TUser? user = await userManager.GetUserAsync(principal); if (user == null) diff --git a/ChatRPG/Data/Models/Character.cs b/ChatRPG/Data/Models/Character.cs index d438b15..c899c66 100644 --- a/ChatRPG/Data/Models/Character.cs +++ b/ChatRPG/Data/Models/Character.cs @@ -34,7 +34,7 @@ public Character(Campaign campaign, CharacterType type, string name, string desc public string Description { get; private set; } = null!; public int MaxHealth { get; private set; } public int CurrentHealth { get; private set; } - public ICollection CharacterAbilities { get; } = new List(); + public ICollection CharacterAbilities { get; } = new List(); /// /// Adjust the current health of this character. @@ -54,9 +54,9 @@ public void AdjustHealth(int value) /// /// The ability to add. /// The created entity. - public CharacterAbility AddAbility(Ability ability) + public CharacterAbility? AddAbility(Ability ability) { - CharacterAbility charAbility = CharacterAbilities.FirstOrDefault(a => a!.Ability == ability, null); + CharacterAbility? charAbility = CharacterAbilities.FirstOrDefault(a => a!.Ability == ability, null); if (charAbility is not null) { return charAbility; diff --git a/ChatRPG/Pages/Shared/_Layout.cshtml b/ChatRPG/Pages/Shared/_Layout.cshtml index 46212bd..1118ede 100644 --- a/ChatRPG/Pages/Shared/_Layout.cshtml +++ b/ChatRPG/Pages/Shared/_Layout.cshtml @@ -58,7 +58,7 @@
© 2023 - ChatRPG @{ - string foundPrivacy = Url.Page("/Privacy", new { area = "" }); + string? foundPrivacy = Url.Page("/Privacy", new { area = "" }); } @if (foundPrivacy != null) { diff --git a/ChatRPG/Program.cs b/ChatRPG/Program.cs index 3d84b83..d92bc65 100644 --- a/ChatRPG/Program.cs +++ b/ChatRPG/Program.cs @@ -51,7 +51,7 @@ ApplicationDbContext dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.Database.Migrate(); - UserManager userManager = scope.ServiceProvider.GetRequiredService>(); + UserManager userManager = scope.ServiceProvider.GetRequiredService>(); const string username = "test"; User? user = await userManager.FindByNameAsync(username); if (user == null)