diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-12-02 22:36:15 +0100 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-12-02 22:36:15 +0100 |
commit | 779ced6da10e35df9273b95928ed182cddecee27 (patch) | |
tree | 90765a9e7bf6e2255503a0a4e0a4fb5d5c9fdec6 /MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs | |
parent | Update upstreams (diff) | |
download | MatrixUtils-779ced6da10e35df9273b95928ed182cddecee27.tar.xz |
Reformat
Diffstat (limited to 'MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs')
-rw-r--r-- | MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs b/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs index 4f265ee..c7a311d 100644 --- a/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs +++ b/MatrixRoomUtils.Desktop/MRUDesktopConfiguration.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Diagnostics.CodeAnalysis; using ArcaneLibs.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; @@ -9,6 +10,7 @@ namespace MatrixRoomUtils.Desktop; public class MRUDesktopConfiguration { private static ILogger<MRUDesktopConfiguration> _logger; + [RequiresUnreferencedCode("Uses reflection binding")] public MRUDesktopConfiguration(ILogger<MRUDesktopConfiguration> logger, IConfiguration config, HostBuilderContext host) { _logger = logger; logger.LogInformation("Loading configuration for environment: {}...", host.HostingEnvironment.EnvironmentName); @@ -24,7 +26,7 @@ public class MRUDesktopConfiguration { private static string ExpandPath(string path, bool retry = true) { _logger.LogInformation("Expanding path `{}`", path); - if (path.StartsWith("~")) { + if (path.StartsWith('~')) { path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), path[1..]); } @@ -34,8 +36,8 @@ public class MRUDesktopConfiguration { _logger.LogInformation("Expanded path to `{}`", path); var tries = 0; - while(retry && path.ContainsAnyOf("~$".Split())) { - if(tries++ > 100) + while (retry && path.ContainsAnyOf("~$".Split())) { + if (tries++ > 100) throw new Exception($"Path `{path}` contains unrecognised environment variables"); path = ExpandPath(path, false); } |