[Aaru] Reformat and cleanup.

This commit is contained in:
2023-10-03 22:38:23 +01:00
parent 1252feea0c
commit 8815beffd8
33 changed files with 3008 additions and 2971 deletions

View File

@@ -56,6 +56,7 @@ dotnet_style_qualification_for_property
dotnet_style_require_accessibility_modifiers = never:suggestion
# ReSharper properties
resharper_align_first_arg_by_paren = false
resharper_align_linq_query = true
resharper_align_multiline_argument = true
resharper_align_multiline_array_and_object_initializer = false
@@ -82,7 +83,7 @@ resharper_braces_for_ifelse
resharper_braces_for_while = required_for_multiline
resharper_builtin_type_apply_to_native_integer = true
resharper_constructor_or_destructor_body = expression_body
resharper_csharp_align_first_arg_by_paren = true
resharper_csharp_align_first_arg_by_paren = false
resharper_csharp_empty_block_style = together_same_line
resharper_csharp_place_comments_at_first_column = true
resharper_csharp_prefer_qualified_reference = false
@@ -95,7 +96,7 @@ resharper_for_built_in_types
resharper_function_declaration_return_type_style = on_single_line
resharper_function_definition_return_type_style = on_single_line
resharper_html_pi_attribute_style = first_attribute_on_single_line
resharper_indent_anonymous_method_block = true
resharper_indent_anonymous_method_block = false
resharper_indent_preprocessor_if = outdent
resharper_indent_preprocessor_other = outdent
resharper_indent_preprocessor_region = outdent

View File

@@ -720,7 +720,8 @@ sealed class DeviceReportCommand : Command
{
tryPlextor |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_Plextor_commands} [red]{UI.This_is_dangerous}[/][/]",
Confirm(
$"[italic]{UI.Do_you_want_to_try_Plextor_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
}
@@ -728,7 +729,8 @@ sealed class DeviceReportCommand : Command
{
tryNec |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_NEC_commands} [red]{UI.This_is_dangerous}[/][/]",
Confirm(
$"[italic]{UI.Do_you_want_to_try_NEC_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
}
@@ -736,7 +738,8 @@ sealed class DeviceReportCommand : Command
{
tryPioneer |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_Pioneer_commands} [red]{UI.This_is_dangerous}[/][/]",
Confirm(
$"[italic]{UI.Do_you_want_to_try_Pioneer_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
}
@@ -744,13 +747,15 @@ sealed class DeviceReportCommand : Command
{
tryHldtst |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_HLDTST_commands} [red]{UI.This_is_dangerous}[/][/]",
Confirm(
$"[italic]{UI.Do_you_want_to_try_HLDTST_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
}
tryMediaTekF106 =
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_MediaTek_commands} [red]{UI.This_is_dangerous}[/][/]",
Confirm(
$"[italic]{UI.Do_you_want_to_try_MediaTek_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
}
@@ -923,7 +928,8 @@ sealed class DeviceReportCommand : Command
{
task.Description =
string.
Format(Localization.Core.Trying_READ_LONG_with_size_0,
Format(
Localization.Core.Trying_READ_LONG_with_size_0,
i);
task.Value = i;
@@ -1565,7 +1571,8 @@ sealed class DeviceReportCommand : Command
task.Description =
string.
Format(Localization.Core.Trying_READ_LONG_with_size_0,
Format(
Localization.Core.Trying_READ_LONG_with_size_0,
i);
sense = mediaTest.SupportsReadLong16 == true

View File

@@ -355,7 +355,8 @@ sealed class DeviceInfoCommand : Command
dev.IsCompactFlash, dev.IsPcmcia, blocks);
AaruConsole.
WriteLine(removable ? Localization.Core.Media_identified_as_0 : Localization.Core.Device_identified_as_0,
WriteLine(
removable ? Localization.Core.Media_identified_as_0 : Localization.Core.Device_identified_as_0,
mediaType);
Statistics.AddMedia(mediaType, true);

View File

@@ -311,7 +311,9 @@ sealed class ChecksumCommand : Command
{
AaruConsole.
ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
Format(
UI.
Error_0_while_reading_1_sectors_from_sector_2,
errno, SECTORS_TO_READ,
doneSectors));
@@ -336,7 +338,9 @@ sealed class ChecksumCommand : Command
{
AaruConsole.
ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
Format(
UI.
Error_0_while_reading_1_sectors_from_sector_2,
errno, sectors - doneSectors,
doneSectors));
@@ -491,7 +495,9 @@ sealed class ChecksumCommand : Command
{
AaruConsole.
ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
Format(
UI.
Error_0_while_reading_1_sectors_from_sector_2,
errno, SECTORS_TO_READ,
doneSectors +
currentFile.FirstBlock));
@@ -515,7 +521,9 @@ sealed class ChecksumCommand : Command
{
AaruConsole.
ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
Format(
UI.
Error_0_while_reading_1_sectors_from_sector_2,
errno, sectors - doneSectors,
doneSectors +
currentFile.FirstBlock));
@@ -711,7 +719,8 @@ sealed class ChecksumCommand : Command
{
AaruConsole.
ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
Format(
UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, SECTORS_TO_READ,
doneSectors));
@@ -733,7 +742,8 @@ sealed class ChecksumCommand : Command
{
AaruConsole.
ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
Format(
UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, sectors - doneSectors,
doneSectors));

View File

@@ -737,8 +737,10 @@ sealed class ConvertImageCommand : Command
return;
if(force)
{
AaruConsole.ErrorWriteLine(UI.Error_0_writing_media_tag,
outputFormat.ErrorMessage);
}
else
{
AaruConsole.ErrorWriteLine(UI.Error_0_writing_media_tag_not_continuing,
@@ -951,8 +953,10 @@ sealed class ConvertImageCommand : Command
SectorTagType.DvdTitleKeyDecrypted,
out titleKey) ==
ErrorNumber.NoError)
{
sector = CSS.DecryptSector(sector, titleKey, cmi,
sectorsToDo);
}
else
{
if(generatedTitleKeys == null)
@@ -1296,7 +1300,8 @@ sealed class ConvertImageCommand : Command
else
{
AaruConsole.
ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_not_continuing,
ErrorWriteLine(
UI.Error_0_reading_tag_for_sector_1_not_continuing,
errno, doneSectors + track.StartSector);
return;
@@ -1349,7 +1354,8 @@ sealed class ConvertImageCommand : Command
else
{
AaruConsole.
ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_not_continuing,
ErrorWriteLine(
UI.Error_0_reading_tag_for_sector_1_not_continuing,
errno, doneSectors + track.StartSector);
return;
@@ -1405,10 +1411,8 @@ sealed class ConvertImageCommand : Command
if(trackFlags.Count > 0)
{
foreach((byte track, byte flags) in trackFlags)
{
outputOptical.WriteSectorTag(new[] { flags }, track, SectorTagType.CdTrackFlags);
}
}
if(mcn != null)
outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);
@@ -1710,7 +1714,8 @@ sealed class ConvertImageCommand : Command
out byte[] dataBuffer);
outputFlux.WriteFluxCapture(indexResolution, dataResolution,
indexBuffer, dataBuffer, head, track, subTrackIndex,
indexBuffer, dataBuffer, head, track,
subTrackIndex,
captureIndex);
}
}

View File

@@ -220,15 +220,9 @@ sealed class CreateSidecarCommand : Command
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
sidecarClass.InitProgressEvent += () =>
{
_progressTask1 = ctx.AddTask("Progress");
};
sidecarClass.InitProgressEvent += () => { _progressTask1 = ctx.AddTask("Progress"); };
sidecarClass.InitProgressEvent2 += () =>
{
_progressTask2 = ctx.AddTask("Progress");
};
sidecarClass.InitProgressEvent2 += () => { _progressTask2 = ctx.AddTask("Progress"); };
sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
{
@@ -283,7 +277,9 @@ sealed class CreateSidecarCommand : Command
var jsonFs =
new
FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
FileStream(
Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(),
Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
FileMode.Create);
JsonSerializer.Serialize(jsonFs, new MetadataJson
@@ -325,10 +321,7 @@ sealed class CreateSidecarCommand : Command
{
sidecarClass.InitProgressEvent += () => { _progressTask1 = ctx.AddTask("Progress"); };
sidecarClass.InitProgressEvent2 += () =>
{
_progressTask2 = ctx.AddTask("Progress");
};
sidecarClass.InitProgressEvent2 += () => { _progressTask2 = ctx.AddTask("Progress"); };
sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
{
@@ -360,10 +353,7 @@ sealed class CreateSidecarCommand : Command
_progressTask2 = null;
};
sidecarClass.UpdateStatusEvent += text =>
{
AaruConsole.WriteLine(Markup.Escape(text));
};
sidecarClass.UpdateStatusEvent += text => { AaruConsole.WriteLine(Markup.Escape(text)); };
System.Console.CancelKeyPress += (_, e) =>
{
@@ -381,7 +371,9 @@ sealed class CreateSidecarCommand : Command
var jsonFs =
new
FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
FileStream(
Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(),
Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
FileMode.Create);
JsonSerializer.Serialize(jsonFs, new MetadataJson

View File

@@ -195,12 +195,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.SCSI_INQUIRY_command_response}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(Inquiry.Prettify(inquiry));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -219,12 +221,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_DEVICE_command_response}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(Identify.Prettify(identify));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -244,12 +248,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_PACKET_DEVICE_command_response}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(Identify.Prettify(identify));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -265,12 +271,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.CD_ATIP}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(ATIP.Prettify(atip));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -286,12 +294,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.CD_full_TOC}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(FullTOC.Prettify(fullToc));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -307,12 +317,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{"CD PMA:"}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(PMA.Prettify(pma));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -328,12 +340,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.CD_session_information}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(Session.Prettify(sessionInfo));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -349,12 +363,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.CD_TEXT}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(CDTextOnLeadIn.Prettify(cdText));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;
@@ -371,12 +387,14 @@ sealed class DecodeCommand : Command
AaruConsole.WriteLine($"[bold]{UI.CD_TOC}[/]");
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
AaruConsole.WriteLine(TOC.Prettify(toc));
AaruConsole.
WriteLine("================================================================================");
WriteLine(
"================================================================================");
}
break;

View File

@@ -173,8 +173,10 @@ sealed class MediaScanCommand : Command
scanner.PulseProgress += text =>
{
if(_progressTask1 is null)
{
ctx.AddTask(Markup.Escape(text)).
IsIndeterminate();
}
else
{
_progressTask1.Description = Markup.Escape(text);

View File

@@ -133,7 +133,8 @@ class MainClass
ctx.Database.EnsureCreated();
ctx.Database.
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
ExecuteSqlRaw(
"CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
foreach(string migration in ctx.Database.GetPendingMigrations())
{