Skip to content

Commit 7fdc7e6

Browse files
NeWbY100claude
andcommitted
style: prefer var when type is obvious and use expression bodies
- Sweep explicit-type local declarations to var where the right-hand side already shows the type (casts, factory calls, LINQ results). - Make MainWindow.SaveWindowState's bounds explicit Rect (the ternary hides the type at the declaration site). - Convert one-liner relay-command and helper methods to expression bodies for consistency. - Tighten ExtractCommand's argv loop using the null-coalescing assignment operator. Bumps ReScene.Lib submodule for the matching style pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1d8a8a6 commit 7fdc7e6

7 files changed

Lines changed: 19 additions & 43 deletions

File tree

ReScene.Cli/Commands/ExtractCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public static int Run(string[] args)
2929
{
3030
outDir = args[++i];
3131
}
32-
else if (srrPath is null)
32+
else
3333
{
34-
srrPath = args[i];
34+
srrPath ??= args[i];
3535
}
3636
}
3737

@@ -50,12 +50,12 @@ public static int Run(string[] args)
5050
try
5151
{
5252
Directory.CreateDirectory(outDir);
53-
SRRFile srr = SRRFile.Load(srrPath);
53+
var srr = SRRFile.Load(srrPath);
5454

5555
using FileStream input = File.OpenRead(srrPath);
5656
byte[] buffer = new byte[CopyBufferSize];
5757

58-
foreach (var stored in srr.StoredFiles)
58+
foreach (SrrStoredFileBlock stored in srr.StoredFiles)
5959
{
6060
string outPath = ResolveSafeOutputPath(outDir, stored.FileName);
6161
Directory.CreateDirectory(Path.GetDirectoryName(outPath)!);

ReScene.Cli/Commands/InspectCommand.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static int Run(string[] args)
3434

3535
try
3636
{
37-
SRRFile srr = SRRFile.Load(path);
37+
var srr = SRRFile.Load(path);
3838

3939
List<(long Offset, string Type, long Size, string Name)> rows = [];
4040

@@ -68,7 +68,7 @@ public static int Run(string[] args)
6868
Console.WriteLine($"{"Offset",-12} {"Type",-20} {"Size",10} Name");
6969
Console.WriteLine(new string('-', 60));
7070

71-
foreach (var row in rows)
71+
foreach ((long Offset, string Type, long Size, string Name) row in rows)
7272
{
7373
PrintRow(row.Offset, row.Type, row.Size, row.Name);
7474
}
@@ -82,8 +82,5 @@ public static int Run(string[] args)
8282
}
8383
}
8484

85-
private static void PrintRow(long offset, string type, long size, string name)
86-
{
87-
Console.WriteLine($"0x{offset:X8} {type,-20} {size,10:N0} {name}");
88-
}
85+
private static void PrintRow(long offset, string type, long size, string name) => Console.WriteLine($"0x{offset:X8} {type,-20} {size,10:N0} {name}");
8986
}

ReScene.NET/Services/PropertyExportService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Task ExportSelectedAsync(string outputPath, TreeNodeViewModel node, IEnum
3838
/// <inheritdoc />
3939
public Task ExportTreeAsync(string outputPath, IEnumerable<TreeNodeViewModel> roots, CancellationToken ct = default)
4040
{
41-
List<PropertyExportNode> list = roots.Select(r => ToExport(r, includeChildren: true)).ToList();
41+
var list = roots.Select(r => ToExport(r, includeChildren: true)).ToList();
4242
string json = JsonSerializer.Serialize(list, _options);
4343
return File.WriteAllTextAsync(outputPath, json, ct);
4444
}

ReScene.NET/ViewModels/InspectorViewModel.cs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -632,16 +632,10 @@ private async Task RenameStoredFileAsync()
632632
}
633633

634634
[RelayCommand(CanExecute = nameof(CanMoveStoredFileUp))]
635-
private async Task MoveStoredFileUpAsync()
636-
{
637-
await MoveStoredFileByOffsetAsync(-1);
638-
}
635+
private async Task MoveStoredFileUpAsync() => await MoveStoredFileByOffsetAsync(-1);
639636

640637
[RelayCommand(CanExecute = nameof(CanMoveStoredFileDown))]
641-
private async Task MoveStoredFileDownAsync()
642-
{
643-
await MoveStoredFileByOffsetAsync(+1);
644-
}
638+
private async Task MoveStoredFileDownAsync() => await MoveStoredFileByOffsetAsync(+1);
645639

646640
private bool CanVerifyIntegrity() => IsSrrFileLoaded();
647641

@@ -682,16 +676,10 @@ private async Task VerifyIntegrityAsync()
682676
}
683677

684678
[RelayCommand]
685-
private void DismissVerifyResult()
686-
{
687-
IsVerifyResultVisible = false;
688-
}
679+
private void DismissVerifyResult() => IsVerifyResultVisible = false;
689680

690681
[RelayCommand]
691-
private void ShowHexSearch()
692-
{
693-
IsHexSearchVisible = true;
694-
}
682+
private void ShowHexSearch() => IsHexSearchVisible = true;
695683

696684
[RelayCommand]
697685
private void HideHexSearch()
@@ -701,16 +689,10 @@ private void HideHexSearch()
701689
}
702690

703691
[RelayCommand(CanExecute = nameof(CanRunHexSearch))]
704-
private void FindNext()
705-
{
706-
RunHexSearch(forward: true);
707-
}
692+
private void FindNext() => RunHexSearch(forward: true);
708693

709694
[RelayCommand(CanExecute = nameof(CanRunHexSearch))]
710-
private void FindPrevious()
711-
{
712-
RunHexSearch(forward: false);
713-
}
695+
private void FindPrevious() => RunHexSearch(forward: false);
714696

715697
private void BuildTree()
716698
{
@@ -1061,7 +1043,7 @@ private void RunHexSearch(bool forward)
10611043
return;
10621044
}
10631045

1064-
HexSearchPattern? pattern = HexSearchPattern.TryParse(HexSearchText, HexSearchAsHex);
1046+
var pattern = HexSearchPattern.TryParse(HexSearchText, HexSearchAsHex);
10651047

10661048
if (pattern is null)
10671049
{
@@ -1101,7 +1083,7 @@ private void RunLiveHexSearch()
11011083
return;
11021084
}
11031085

1104-
HexSearchPattern? pattern = HexSearchPattern.TryParse(HexSearchText, HexSearchAsHex);
1086+
var pattern = HexSearchPattern.TryParse(HexSearchText, HexSearchAsHex);
11051087

11061088
if (pattern is null)
11071089
{

ReScene.NET/ViewModels/ViewModelBase.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ public abstract class ViewModelBase : ObservableObject
88
/// <summary>
99
/// Appends a timestamped log entry to the specified collection.
1010
/// </summary>
11-
protected static void AppendLogEntry(ObservableCollection<string> entries, string message)
12-
{
13-
entries.Add($"{DateTime.Now:HH:mm:ss} {message}");
14-
}
11+
protected static void AppendLogEntry(ObservableCollection<string> entries, string message) => entries.Add($"{DateTime.Now:HH:mm:ss} {message}");
1512
}

ReScene.NET/Views/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void RestoreWindowState()
164164
private void SaveWindowState()
165165
{
166166
// Use RestoreBounds for position/size when maximized
167-
var bounds = WindowState == System.Windows.WindowState.Maximized
167+
Rect bounds = WindowState == System.Windows.WindowState.Maximized
168168
? RestoreBounds
169169
: new Rect(Left, Top, Width, Height);
170170

0 commit comments

Comments
 (0)