From 6dba1b6d8b1b6c1eb8a974f7d6c97ed63679f1f5 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 20 Apr 2023 09:44:24 +0900 Subject: [PATCH] Nullable on LanguageService --- BTCPayServer/Services/LanguageService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Services/LanguageService.cs b/BTCPayServer/Services/LanguageService.cs index 2d9a8631a..48f56c91e 100644 --- a/BTCPayServer/Services/LanguageService.cs +++ b/BTCPayServer/Services/LanguageService.cs @@ -1,3 +1,4 @@ +#nullable enable using System; using System.Collections.Generic; using System.Globalization; @@ -45,7 +46,7 @@ namespace BTCPayServer.Services using var stream = new StreamReader(file); var json = stream.ReadToEnd(); - result.Add(JObject.Parse(json).ToObject()); + result.Add(JObject.Parse(json).ToObject()!); } catch (Exception e) { @@ -73,7 +74,7 @@ namespace BTCPayServer.Services return items; } - public Language FindLanguageInAcceptLanguageHeader(string acceptLanguageHeader) + public Language? FindLanguageInAcceptLanguageHeader(string? acceptLanguageHeader) { if (acceptLanguageHeader is null) return null; @@ -130,7 +131,7 @@ namespace BTCPayServer.Services * Look for a supported language that matches the given locale (can be in different notations like "nl" or "nl-NL"). * Example: "nl" is not supported, but we do have "nl-NL" */ - public Language FindLanguage(string locale) + public Language? FindLanguage(string locale) { var supportedLangs = GetLanguages(); var split = locale.Split('-', StringSplitOptions.RemoveEmptyEntries); @@ -150,7 +151,7 @@ namespace BTCPayServer.Services return countryMatches.FirstOrDefault() ?? langMatches.FirstOrDefault(); } - public Language AutoDetectLanguageUsingHeader(IHeaderDictionary headerDictionary, string defaultLang) + public Language? AutoDetectLanguageUsingHeader(IHeaderDictionary headerDictionary, string? defaultLang) { if (headerDictionary?.TryGetValue("Accept-Language", out var acceptLanguage) is true && !string.IsNullOrEmpty(acceptLanguage))