Fix some warnings.

This commit is contained in:
2025-05-10 13:38:59 +01:00
parent c8ee8bb151
commit e4113d2092
21 changed files with 80 additions and 90 deletions

View File

@@ -1,7 +1,6 @@
@page "/{documentCategory}/{documentName}.md"
@page "/{documentName}.md"
@inject NavigationManager NavigationManager
@inject IWebHostEnvironment HostEnvironment
@inject IConfiguration Configuration

View File

@@ -6,7 +6,7 @@
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
<PageTitle>@_pageTitle</PageTitle>
<PageTitle>@PageTitle</PageTitle>
<style>
.list-group-item {
background-color: #212529; color: white; border-color: #373b3e;
@@ -30,7 +30,7 @@
}
<div class="stats-section">
<h1 style="color: #e18fdc; align-content: center; padding: 2rem">@_pageTitle</h1>
<h1 style="color: #e18fdc; align-content: center; padding: 2rem">@PageTitle</h1>
</div>
<div class="stats-section">

View File

@@ -19,7 +19,7 @@ public partial class View
{
bool _initialized;
bool _notFound;
string _pageTitle { get; set; } = "Aaru Device Report";
string PageTitle { get; set; } = "Aaru Device Report";
[CascadingParameter]
HttpContext HttpContext { get; set; } = default!;
[Parameter]
@@ -132,7 +132,7 @@ public partial class View
return;
}
_pageTitle = $"Aaru Device Report for {report.Manufacturer} {report.Model} {report.Revision}";
PageTitle = $"Aaru Device Report for {report.Manufacturer} {report.Model} {report.Revision}";
if(report.USB != null)
{
@@ -195,7 +195,7 @@ public partial class View
if(tuples != null)
{
Dictionary<string, string> decodedTuples = new();
Dictionary<string, string> decodedTuples = [];
foreach(Tuple tuple in tuples)
{
@@ -319,7 +319,7 @@ public partial class View
out string? maximumAtaRevision,
out string? transport,
out List<string>? transportVersions,
out List<string>? generalConfiguration,
out List<string> generalConfiguration,
out List<string>? specificConfiguration,
out List<string> deviceCapabilities,
out List<string> pioTransferModes,
@@ -405,10 +405,9 @@ public partial class View
DeviceInquiry = new Dictionary<string, string>
{
{
"Vendor:",
VendorString.Prettify(vendorId) != vendorId
? $"{vendorId} ({VendorString.Prettify(vendorId)})"
: vendorId
"Vendor:", VendorString.Prettify(vendorId) != vendorId
? $"{vendorId} ({VendorString.Prettify(vendorId)})"
: vendorId
},
{
"Product:", StringHandlers.CToString(inq.ProductIdentification)

View File

@@ -39,7 +39,7 @@ public partial class Commands
}
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_commandsChart, _commandsLabels, GetCommandsChartDataset);
await Common.HandleRedrawAsync(_commandsChart, _commandsLabels, GetCommandsChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -47,8 +47,8 @@ public partial class Commands
{
Label = $"Top {_commandsLabels.Length} used commands",
Data = _commandsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -4,23 +4,17 @@ namespace Aaru.Server.Components.Pages.Statistics;
public static class Common
{
internal static readonly List<string> _backgroundColors =
internal static readonly List<string> BackgroundColors =
[
ChartColor.FromHtmlColorCode("#006412"), ChartColor.FromHtmlColorCode("#0000D3"),
ChartColor.FromHtmlColorCode("#FF6403"), ChartColor.FromHtmlColorCode("#562C05"),
ChartColor.FromHtmlColorCode("#DD0907"), ChartColor.FromHtmlColorCode("#F20884"),
ChartColor.FromHtmlColorCode("#4700A5"), ChartColor.FromHtmlColorCode("#90713A"),
ChartColor.FromHtmlColorCode("#1FB714"), ChartColor.FromHtmlColorCode("#02ABEA"),
ChartColor.FromHtmlColorCode("#FBF305")
ChartColor.FromHtmlColorCode("#006412"), ChartColor.FromHtmlColorCode("#0000D3"), ChartColor.FromHtmlColorCode("#FF6403"), ChartColor.FromHtmlColorCode("#562C05"), ChartColor.FromHtmlColorCode("#DD0907"), ChartColor.FromHtmlColorCode("#F20884"), ChartColor.FromHtmlColorCode("#4700A5"), ChartColor.FromHtmlColorCode("#90713A"), ChartColor.FromHtmlColorCode("#1FB714"), ChartColor.FromHtmlColorCode("#02ABEA"), ChartColor.FromHtmlColorCode("#FBF305")
];
internal static readonly List<string> _borderColors = [ChartColor.FromHtmlColorCode("#8b0000")];
internal static readonly List<string> BorderColors = [ChartColor.FromHtmlColorCode("#8b0000")];
internal static async Task HandleRedraw<TDataSet, TItem, TOptions, TModel>(
BaseChart<TDataSet, TItem, TOptions, TModel> chart, string[] labels, Func<TDataSet> getDataSet)
internal static async Task HandleRedrawAsync<TDataSet, TItem, TOptions, TModel>(BaseChart<TDataSet, TItem, TOptions, TModel> chart, string[] labels, Func<TDataSet> getDataSet)
where TDataSet : ChartDataset<TItem> where TOptions : ChartOptions where TModel : ChartModel
{
await chart.Clear();
await chart.AddLabelsDatasetsAndUpdate(labels, getDataSet());
await chart.AddLabelsDatasetsAndUpdate(labels, getDataSet()).ConfigureAwait(false);
}
}

View File

@@ -95,11 +95,11 @@ public partial class Devices
_devicesByManufacturerCounts[9] = data.Sum(static o => o.Count) - _devicesByManufacturerCounts.Take(9).Sum();
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_devicesByBusChart, _devicesByBusLabels, GetDevicesByBusChartDataset);
await Common.HandleRedrawAsync(_devicesByBusChart, _devicesByBusLabels, GetDevicesByBusChartDataset);
await Common.HandleRedraw(_devicesByManufacturerChart,
_devicesByManufacturerLabels,
GetDevicesByManufacturerChartDataset);
await Common.HandleRedrawAsync(_devicesByManufacturerChart,
_devicesByManufacturerLabels,
GetDevicesByManufacturerChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
// Upstream: https://github.com/Megabit/Blazorise/issues/5491
@@ -110,8 +110,8 @@ public partial class Devices
{
Label = $"Top {_devicesByBusLabels.Length} devices by bus",
Data = _devicesByBusCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
@@ -119,8 +119,8 @@ public partial class Devices
{
Label = $"Top {_devicesByManufacturerLabels.Length} devices by manufacturers",
Data = _devicesByManufacturerCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -49,7 +49,7 @@ public partial class Filesystems
}
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_filesystemsChart, _filesystemsLabels, GetFilesystemsChartDataset);
await Common.HandleRedrawAsync(_filesystemsChart, _filesystemsLabels, GetFilesystemsChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -57,8 +57,8 @@ public partial class Filesystems
{
Label = $"Top {_filesystemsLabels.Length} filesystems found",
Data = _filesystemsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -49,7 +49,7 @@ public partial class Filters
}
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_filtersChart, _filtersLabels, GetFiltersChartDataset);
await Common.HandleRedrawAsync(_filtersChart, _filtersLabels, GetFiltersChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -58,8 +58,8 @@ public partial class Filters
{
Label = $"Top {_filtersLabels.Length} filters found",
Data = _filtersCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -50,7 +50,7 @@ public partial class Formats
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_formatsChart, _formatsLabels, GetFormatsChartDataset);
await Common.HandleRedrawAsync(_formatsChart, _formatsLabels, GetFormatsChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -59,8 +59,8 @@ public partial class Formats
{
Label = $"Top {_formatsLabels.Length} media image formats found",
Data = _formatsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -147,12 +147,12 @@ public partial class OperatingSystems
#pragma warning disable CS8604 // Possible null reference argument.
await Task.WhenAll(Common.HandleRedraw(_operatingSystemsChart,
_operatingSystemsLabels,
GetOperatingSystemsChartDataset),
Common.HandleRedraw(_linuxChart, _linuxLabels, GetLinuxChartDataset),
Common.HandleRedraw(_macosChart, _macosLabels, GetMacosChartDataset),
Common.HandleRedraw(_windowsChart, _windowsLabels, GetWindowsChartDataset));
await Task.WhenAll(Common.HandleRedrawAsync(_operatingSystemsChart,
_operatingSystemsLabels,
GetOperatingSystemsChartDataset),
Common.HandleRedrawAsync(_linuxChart, _linuxLabels, GetLinuxChartDataset),
Common.HandleRedrawAsync(_macosChart, _macosLabels, GetMacosChartDataset),
Common.HandleRedrawAsync(_windowsChart, _windowsLabels, GetWindowsChartDataset));
#pragma warning restore CS8604 // Possible null reference argument.
// Upstream: https://github.com/Megabit/Blazorise/issues/5491
@@ -163,8 +163,8 @@ public partial class OperatingSystems
{
Label = "Operating systems",
Data = _operatingSystemsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
@@ -172,8 +172,8 @@ public partial class OperatingSystems
{
Label = $"Top {_linuxLabels.Length} Linux versions",
Data = _linuxCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
@@ -181,8 +181,8 @@ public partial class OperatingSystems
{
Label = $"Top {_macosLabels.Length} macOS versions",
Data = _macosCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
@@ -190,11 +190,10 @@ public partial class OperatingSystems
{
Label = $"Top {_windowsLabels.Length} Windows versions",
Data = _windowsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
static string GetPlatformName(string name, string version) =>
DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), name), version);
static string GetPlatformName(string name, string version) => DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), name), version);
}

View File

@@ -49,7 +49,7 @@ public partial class Partitions
}
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_partitionsChart, _partitionsLabels, GetPartitionsChartDataset);
await Common.HandleRedrawAsync(_partitionsChart, _partitionsLabels, GetPartitionsChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -57,8 +57,8 @@ public partial class Partitions
{
Label = $"Top {_partitionsLabels.Length} partitioning schemes found",
Data = _partitionsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -65,7 +65,7 @@ public partial class RealMedias
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_realMediaChart, _realMediaLabels, GetRealMediaChartDataset);
await Common.HandleRedrawAsync(_realMediaChart, _realMediaLabels, GetRealMediaChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -73,8 +73,8 @@ public partial class RealMedias
{
Label = $"Top {_realMediaLabels.Length} media types found in devices",
Data = _realMediaCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -55,7 +55,7 @@ public partial class Versions
}
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_versionsChart, _versionsLabels, GetVersionsChartDataset);
await Common.HandleRedrawAsync(_versionsChart, _versionsLabels, GetVersionsChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -63,8 +63,8 @@ public partial class Versions
{
Label = $"Top {_versionsLabels.Length} Aaru versions",
Data = _versionsCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -64,7 +64,7 @@ public partial class VirtualMedias
}
#pragma warning disable CS8604 // Possible null reference argument.
await Common.HandleRedraw(_virtualMediaChart, _virtualMediaLabels, GetVirtualMediaChartDataset);
await Common.HandleRedrawAsync(_virtualMediaChart, _virtualMediaLabels, GetVirtualMediaChartDataset);
#pragma warning restore CS8604 // Possible null reference argument.
}
@@ -72,8 +72,8 @@ public partial class VirtualMedias
{
Label = $"Top {_virtualMediaLabels.Length} media types found in images",
Data = _virtualMediaCounts,
BackgroundColor = Common._backgroundColors,
BorderColor = Common._borderColors,
BackgroundColor = Common.BackgroundColors,
BorderColor = Common.BorderColors,
BorderWidth = 1
};
}

View File

@@ -99,7 +99,7 @@ public static class Ata
streaming = null;
smartCommandTransport = null;
nvCache = null;
readCapabilitiesDictionary = new Dictionary<string, string>();
readCapabilitiesDictionary = [];
readCapabilitiesList = [];
Identify.IdentifyDevice? ataIdentifyNullable = Identify.Decode(ataReport.Identify);
@@ -110,19 +110,19 @@ public static class Ata
if(!string.IsNullOrEmpty(ataIdentify.Model))
{
deviceIdentification ??= new Dictionary<string, string>();
deviceIdentification ??= [];
deviceIdentification["Model"] = ataIdentify.Model;
}
if(!string.IsNullOrEmpty(ataIdentify.FirmwareRevision))
{
deviceIdentification ??= new Dictionary<string, string>();
deviceIdentification ??= [];
deviceIdentification["Firmware revision"] = ataIdentify.FirmwareRevision;
}
if(!string.IsNullOrEmpty(ataIdentify.AdditionalPID))
{
deviceIdentification ??= new Dictionary<string, string>();
deviceIdentification ??= [];
deviceIdentification["Additional product ID"] = ataIdentify.AdditionalPID;
}

View File

@@ -47,7 +47,7 @@ public static class ScsiEvpd
public static void Report(IEnumerable<ScsiPage> pages, string vendor,
out Dictionary<string, List<string>> evpdPages)
{
evpdPages = new Dictionary<string, List<string>>();
evpdPages = [];
vendor = vendor.ToLowerInvariant();
foreach(ScsiPage evpd in pages)

View File

@@ -53,7 +53,7 @@ public static class ScsiModeSense
{
modeSenseCapabilities = null;
blockDescriptors = null;
modePages = new Dictionary<string, List<string>>();
modePages = [];
if(modeSense.MediumType.HasValue)
{

View File

@@ -43,11 +43,11 @@ public static class SscTestedMedia
out Dictionary<string, (Dictionary<string, string> Table, List<string> List)>
mediaInformation)
{
mediaInformation = new Dictionary<string, (Dictionary<string, string>, List<string>)>();
mediaInformation = [];
foreach(TestedSequentialMedia media in testedMedia)
{
Dictionary<string, string> table = new();
Dictionary<string, string> table = [];
List<string> list = [];
string header;
@@ -63,9 +63,9 @@ public static class SscTestedMedia
header = "Information for unknown medium type";
if(!string.IsNullOrWhiteSpace(media.Manufacturer))
table.Add("Medium manufacturer", $"{media.Manufacturer}");
table.Add("Medium manufacturer", media.Manufacturer);
if(!string.IsNullOrWhiteSpace(media.Model)) table.Add("Medium model", $"{media.Model}");
if(!string.IsNullOrWhiteSpace(media.Model)) table.Add("Medium model", media.Model);
if(media.Density.HasValue) list.Add($"Medium has density code {media.Density:X2}h");

View File

@@ -38,13 +38,13 @@ public static class TestedMedia
/// <param name="mediaInformation">List to put values on</param>
/// <param name="testedMedias">List of tested media</param>
public static void Report(List<CommonTypes.Metadata.TestedMedia> testedMedias,
out Dictionary<string, (Dictionary<string, string>, List<string>)> mediaInformation)
out Dictionary<string, (Dictionary<string, string> Table, List<string> List)> mediaInformation)
{
mediaInformation = new Dictionary<string, (Dictionary<string, string>, List<string>)>();
mediaInformation = [];
foreach(CommonTypes.Metadata.TestedMedia testedMedia in testedMedias)
{
Dictionary<string, string> table = new();
Dictionary<string, string> table = [];
List<string> list = [];
string header;
@@ -64,9 +64,9 @@ public static class TestedMedia
: "Drive does not recognize this medium.");
if(!string.IsNullOrWhiteSpace(testedMedia.Manufacturer))
table.Add("Medium manufacturer", $"{testedMedia.Manufacturer}");
table.Add("Medium manufacturer", testedMedia.Manufacturer);
if(!string.IsNullOrWhiteSpace(testedMedia.Model)) table.Add("Medium model", $"{testedMedia.Model}");
if(!string.IsNullOrWhiteSpace(testedMedia.Model)) table.Add("Medium model", testedMedia.Model);
if(testedMedia.Density != null) table.Add("Density code", $"{testedMedia.Density:X2}h");
@@ -191,8 +191,7 @@ public static class TestedMedia
: $"Medium rotates at {testedMedia.NominalRotationRate} rpm");
}
if(testedMedia.BlockSize != null &&
testedMedia.PhysicalBlockSize != null &&
if(testedMedia is { BlockSize: not null, PhysicalBlockSize: not null } &&
testedMedia.BlockSize.Value != testedMedia.PhysicalBlockSize.Value &&
(testedMedia.LogicalAlignment & 0x8000) == 0x0000 &&
(testedMedia.LogicalAlignment & 0x4000) == 0x4000)

View File

@@ -76,7 +76,7 @@ builder.Services.AddScoped<IdentityUserAccessor>();
builder.Services.AddScoped<IdentityRedirectManager>();
builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();
builder.Services.AddAuthentication(options =>
builder.Services.AddAuthentication(static options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
@@ -164,7 +164,7 @@ using(IServiceScope scope = app.Services.CreateScope())
{
Console.WriteLine("\e[31;1mCould not open database...\e[0m");
#if DEBUG
Console.WriteLine("\e[31;1mException: {0}\e[0m", ex.Message);
Console.WriteLine("\e[31;1mException: {0}\e[0m", ex);
#endif
return;
}

View File

@@ -7,7 +7,7 @@ public static class Seeder
{
public static async Task SeedAsync(DbContext ctx, IServiceProvider serviceProvider)
{
var email = "claunia@claunia.com";
const string email = "claunia@claunia.com";
var randChars = new char[16];
UserManager<IdentityUser> userManager = serviceProvider.GetRequiredService<UserManager<IdentityUser>>();
var rnd = new Random();