diff --git a/MatrixRoomUtils.Desktop/FileStorageProvider.cs b/MatrixRoomUtils.Desktop/FileStorageProvider.cs
index 7f73cf3..0429d1a 100644
--- a/MatrixRoomUtils.Desktop/FileStorageProvider.cs
+++ b/MatrixRoomUtils.Desktop/FileStorageProvider.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using ArcaneLibs.Extensions;
using LibMatrix.Extensions;
@@ -19,13 +20,14 @@ public class FileStorageProvider : IStorageProvider {
new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test");
Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}");
TargetPath = targetPath;
- if(!Directory.Exists(targetPath)) {
+ if (!Directory.Exists(targetPath)) {
Directory.CreateDirectory(targetPath);
}
}
public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson());
+ [RequiresUnreferencedCode("This API uses reflection to deserialize JSON")]
public async Task<T?> LoadObjectAsync<T>(string key) => JsonSerializer.Deserialize<T>(await File.ReadAllTextAsync(Path.Join(TargetPath, key)));
public Task<bool> ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key)));
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);
}
diff --git a/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs b/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs
index bc01774..8a44518 100644
--- a/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs
+++ b/MatrixRoomUtils.Desktop/MRUStorageWrapper.cs
@@ -7,7 +7,7 @@ namespace MatrixRoomUtils.Desktop;
public class MRUStorageWrapper(TieredStorageService storageService, HomeserverProviderService homeserverProviderService) {
public async Task<List<LoginResponse>?> GetAllTokens() {
- if(!await storageService.DataStorageProvider.ObjectExistsAsync("mru.tokens")) {
+ if (!await storageService.DataStorageProvider.ObjectExistsAsync("mru.tokens")) {
return null;
}
return await storageService.DataStorageProvider.LoadObjectAsync<List<LoginResponse>>("mru.tokens") ??
@@ -15,7 +15,7 @@ public class MRUStorageWrapper(TieredStorageService storageService, HomeserverPr
}
public async Task<LoginResponse?> GetCurrentToken() {
- if(!await storageService.DataStorageProvider.ObjectExistsAsync("token")) {
+ if (!await storageService.DataStorageProvider.ObjectExistsAsync("token")) {
return null;
}
var currentToken = await storageService.DataStorageProvider.LoadObjectAsync<LoginResponse>("token");
@@ -41,7 +41,7 @@ public class MRUStorageWrapper(TieredStorageService storageService, HomeserverPr
tokens.Add(loginResponse);
await storageService.DataStorageProvider.SaveObjectAsync("mru.tokens", tokens);
- if(await GetCurrentToken() is null)
+ if (await GetCurrentToken() is null)
await SetCurrentToken(loginResponse);
}
diff --git a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
index 0bed93d..9db59c5 100644
--- a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
+++ b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
@@ -28,7 +28,7 @@ public partial class MainWindow : Window {
// for (int i = 0; i < 100; i++) {
- // roomList.Children.Add(new RoomListEntry());
+ // roomList.Children.Add(new RoomListEntry());
// }
}
@@ -45,6 +45,6 @@ public partial class MainWindow : Window {
// public Command
// protected void LoadedCommand() {
- // _logger.LogInformation("async command");
+ // _logger.LogInformation("async command");
// }
}
diff --git a/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj b/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj
index 012f74b..6d9fc0e 100644
--- a/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj
+++ b/MatrixRoomUtils.Desktop/MatrixRoomUtils.Desktop.csproj
@@ -46,17 +46,4 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
- <ItemGroup>
- <Folder Include="Classes\" />
- </ItemGroup>
- <ItemGroup>
- <Compile Update="Components\NavigationStack.axaml.cs">
- <DependentUpon>NavigationStack.axaml</DependentUpon>
- <SubType>Code</SubType>
- </Compile>
- <Compile Update="Components\RoomListEntry.axaml.cs">
- <DependentUpon>RoomListEntry.axaml</DependentUpon>
- <SubType>Code</SubType>
- </Compile>
- </ItemGroup>
</Project>
diff --git a/MatrixRoomUtils.Desktop/Program.cs b/MatrixRoomUtils.Desktop/Program.cs
index 6e299eb..aa1d9d3 100644
--- a/MatrixRoomUtils.Desktop/Program.cs
+++ b/MatrixRoomUtils.Desktop/Program.cs
@@ -1,4 +1,4 @@
-using Avalonia;
+using Avalonia;
using Microsoft.Extensions.Hosting;
using Tmds.DBus.Protocol;
|