Fix Rider inspections

This commit is contained in:
chylex 2021-11-28 14:44:40 +01:00
parent 4cfe19d369
commit 2ec9c7cbc3
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548
7 changed files with 14 additions and 15 deletions

View File

@ -1,6 +1,5 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
@ -21,8 +20,11 @@ namespace DHT.Desktop.Dialogs {
AvaloniaXamlLoader.Load(this);
}
[SuppressMessage("ReSharper", "UnusedParameter.Local")]
private void Loaded(object? sender, EventArgs e) {
public void OnClosing(object? sender, CancelEventArgs e) {
e.Cancel = !isFinished;
}
public void Loaded(object? sender, EventArgs e) {
if (DataContext is ProgressDialogModel model) {
Task.Run(model.StartTask).ContinueWith(OnFinished, TaskScheduler.FromCurrentSynchronizationContext());
}
@ -32,10 +34,5 @@ namespace DHT.Desktop.Dialogs {
isFinished = true;
Close();
}
[SuppressMessage("ReSharper", "UnusedParameter.Local")]
private void OnClosing(object? sender, CancelEventArgs e) {
e.Cancel = !isFinished;
}
}
}

View File

@ -59,7 +59,7 @@ namespace DHT.Desktop.Main.Pages {
fileDialog.Directory = Path.GetDirectoryName(Db.Path);
fileDialog.AllowMultiple = true;
string[] paths = await fileDialog.ShowAsync(window);
string[]? paths = await fileDialog.ShowAsync(window);
if (paths == null || paths.Length == 0) {
return;
}

View File

@ -97,7 +97,8 @@ namespace DHT.Desktop.Main.Pages {
int counter = 0;
while (File.Exists(fullPath)) {
fullPath = Path.Combine(rootPath, filenameBase + "-" + (++counter) + ".html");
++counter;
fullPath = Path.Combine(rootPath, filenameBase + "-" + counter + ".html");
}
Directory.CreateDirectory(rootPath);
@ -119,7 +120,7 @@ namespace DHT.Desktop.Main.Pages {
}
}.ShowAsync(window);
string path = await dialog;
string? path = await dialog;
if (!string.IsNullOrEmpty(path)) {
await File.WriteAllTextAsync(path, await GenerateViewerContents());
}

View File

@ -29,7 +29,7 @@ namespace DHT.Desktop.Main {
var dialog = DatabaseGui.NewOpenOrCreateDatabaseFileDialog();
dialog.Directory = Path.GetDirectoryName(dbFilePath);
string path = await dialog.ShowAsync(window);
string? path = await dialog.ShowAsync(window);
if (!string.IsNullOrWhiteSpace(path)) {
await OpenOrCreateDatabaseFromPath(path);
}

View File

@ -15,6 +15,7 @@ namespace DHT.Server.Database.Sqlite {
if (filter.StartDate != null) {
conditions.Add("timestamp >= " + new DateTimeOffset(filter.StartDate.Value).ToUnixTimeMilliseconds());
}
if (filter.EndDate != null) {
conditions.Add("timestamp <= " + new DateTimeOffset(filter.EndDate.Value).ToUnixTimeMilliseconds());
}

View File

@ -22,8 +22,8 @@ namespace DHT.Server.Endpoints {
throw new HttpException(HttpStatusCode.BadRequest, "Expected root element to be an array.");
}
MessageFilter addedMessageIdFilter = new();
Message[] messages = new Message[root.GetArrayLength()];
var addedMessageIdFilter = new MessageFilter();
var messages = new Message[root.GetArrayLength()];
int i = 0;
foreach (JsonElement ele in root.EnumerateArray()) {

View File

@ -18,7 +18,7 @@ namespace DHT.Server.Endpoints {
throw new HttpException(HttpStatusCode.BadRequest, "Expected root element to be an array.");
}
User[] users = new User[root.GetArrayLength()];
var users = new User[root.GetArrayLength()];
int i = 0;
foreach (JsonElement user in root.EnumerateArray()) {