diff --git a/.github/workflows/czishrink_codeql.yml b/.github/workflows/czishrink_codeql.yml
index dc123ac..d1dc728 100644
--- a/.github/workflows/czishrink_codeql.yml
+++ b/.github/workflows/czishrink_codeql.yml
@@ -40,7 +40,15 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 7.0.x
+ dotnet-version: 8.0.x
+
+ - name: Cache nugets
+ uses: actions/cache@v3
+ with:
+ path: ${{ github.workspace }}/.nuget/packages
+ key: ${{ runner.os }}-czishrink-nuget-${{ hashFiles('czishrink/**/packages.lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-czishrink-nuget-
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -49,7 +57,7 @@ jobs:
queries: security-and-quality
- name: Restore dependencies
- run: dotnet restore
+ run: dotnet restore --locked-mode
- name: Build
run: dotnet build --no-restore -c Release
diff --git a/.github/workflows/czishrink_dotnet.yml b/.github/workflows/czishrink_dotnet.yml
index 05c5103..476b920 100644
--- a/.github/workflows/czishrink_dotnet.yml
+++ b/.github/workflows/czishrink_dotnet.yml
@@ -50,7 +50,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 7.0.x
+ dotnet-version: 8.0.x
- name: Get Version from Directory.Build.props
id: getversion
@@ -117,12 +117,11 @@ jobs:
if: ${{ always() }}
- name: Publish
- if: ${{ (github.event_name == 'push') && (matrix.build == 'Release') }}
+ if: matrix.build == 'Release'
run: >
dotnet publish netczicompress.Desktop/netczicompress.Desktop.csproj
-c ${{ matrix.build }}
-a x64
- --no-restore
--self-contained
-p:PublishSingleFile=true
-p:PublishReadyToRun=true
diff --git a/czishrink/.vscode/launch.json b/czishrink/.vscode/launch.json
index 42947bb..9842bcd 100644
--- a/czishrink/.vscode/launch.json
+++ b/czishrink/.vscode/launch.json
@@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/netczicompress.Desktop/bin/x64/Debug/net7.0/CziShrink",
+ "program": "${workspaceFolder}/netczicompress.Desktop/bin/x64/Debug/net8.0/CziShrink",
"args": [],
"cwd": "${workspaceFolder}/netczicompress.Desktop",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
diff --git a/czishrink/Directory.Build.props b/czishrink/Directory.Build.props
index f73469a..e042e1e 100644
--- a/czishrink/Directory.Build.props
+++ b/czishrink/Directory.Build.props
@@ -1,6 +1,6 @@
- net7.0
+ net8.0
latest
enable
True
@@ -17,6 +17,6 @@
false
- 1.0.3
+ 1.1.0
\ No newline at end of file
diff --git a/czishrink/global.json b/czishrink/global.json
index a0f1fbf..1d0fe83 100644
--- a/czishrink/global.json
+++ b/czishrink/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "7.0.0",
+ "version": "8.0.0",
"allowPrerelease": false,
"rollForward": "latestFeature"
}
diff --git a/czishrink/netczicompress.Desktop/packages.lock.json b/czishrink/netczicompress.Desktop/packages.lock.json
index f3a862f..00c4265 100644
--- a/czishrink/netczicompress.Desktop/packages.lock.json
+++ b/czishrink/netczicompress.Desktop/packages.lock.json
@@ -1,7 +1,7 @@
{
"version": 2,
"dependencies": {
- "net7.0": {
+ "net8.0": {
"Avalonia.Desktop": {
"type": "Direct",
"requested": "[11.0.5, )",
diff --git a/czishrink/netczicompress/Models/CompositeObserver.cs b/czishrink/netczicompress/Models/CompositeObserver.cs
index 1078ab5..6540ccb 100644
--- a/czishrink/netczicompress/Models/CompositeObserver.cs
+++ b/czishrink/netczicompress/Models/CompositeObserver.cs
@@ -20,15 +20,9 @@ public static IObserver Create(params IObserver[] observers)
/// A composite .
///
/// The observed type.
- public sealed class CompositeObserverImpl : IObserver
+ public sealed class CompositeObserverImpl(params IObserver[] observers)
+ : IObserver
{
- private readonly IObserver[] observers;
-
- public CompositeObserverImpl(params IObserver[] observers)
- {
- this.observers = observers;
- }
-
public void OnCompleted()
{
this.ForEachObserver(o => o.OnCompleted());
@@ -46,7 +40,7 @@ public void OnNext(T value)
private void ForEachObserver(Action> action)
{
- foreach (var item in this.observers)
+ foreach (var item in observers)
{
action(item);
}
diff --git a/czishrink/netczicompress/Models/CompressionLevel.cs b/czishrink/netczicompress/Models/CompressionLevel.cs
index 4bf99cb..f5f3948 100644
--- a/czishrink/netczicompress/Models/CompressionLevel.cs
+++ b/czishrink/netczicompress/Models/CompressionLevel.cs
@@ -39,7 +39,7 @@ static CompressionLevel()
public static int DefaultValue { get; } = 1;
[Range(0, 22)]
- public int Value
+ public required int Value
{
get => this.internalValue;
init =>
diff --git a/czishrink/netczicompress/Models/CsvLoggingStrategy.cs b/czishrink/netczicompress/Models/CsvLoggingStrategy.cs
index feae883..739861b 100644
--- a/czishrink/netczicompress/Models/CsvLoggingStrategy.cs
+++ b/czishrink/netczicompress/Models/CsvLoggingStrategy.cs
@@ -12,14 +12,9 @@ namespace netczicompress.Models;
///
/// A logging strategy that writes data to a CSV log file.
///
-public class CsvLoggingStrategy : ILoggingStrategy
+public class CsvLoggingStrategy(IFileLauncher fileLauncher) : ILoggingStrategy
{
- private readonly IFileLauncher fileLauncher;
-
- public CsvLoggingStrategy(IFileLauncher fileLauncher)
- {
- this.fileLauncher = fileLauncher;
- }
+ private readonly IFileLauncher fileLauncher = fileLauncher;
///
/// Gets the scheduler to use for logging.
diff --git a/czishrink/netczicompress/Models/FileLauncher.cs b/czishrink/netczicompress/Models/FileLauncher.cs
index b9e497c..80bd5b4 100644
--- a/czishrink/netczicompress/Models/FileLauncher.cs
+++ b/czishrink/netczicompress/Models/FileLauncher.cs
@@ -11,7 +11,7 @@ namespace netczicompress.Models;
/// Launches a file with its associated app,
/// or displays a file in its folder with the operating system's file manager.
///
-public class FileLauncher : IFileLauncher
+public class FileLauncher(IFileSystem fs, Func getEnvironmentVariable) : IFileLauncher
{
// Cf. https://github.com/dotnet/runtime/blob/52806bc157decf345005249c9ea7969c8b9e7e1b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs#L14C9-L41C6
private const string Windows = "WINDOWS";
@@ -23,23 +23,14 @@ public class FileLauncher : IFileLauncher
private const string Unsupported = "UNSUPPORTED";
private static readonly string[] SupportedPlatforms =
- {
+ [
Windows,
Osx,
Linux,
FreeBsd,
NetBsd,
Solaris,
- };
-
- private readonly IFileSystem fs;
- private readonly Func getEnvironmentVariable;
-
- public FileLauncher(IFileSystem fs, Func getEnvironmentVariable)
- {
- this.fs = fs;
- this.getEnvironmentVariable = getEnvironmentVariable;
- }
+ ];
protected string CurrentPlatform { get; init; } = GetPlatform();
@@ -100,10 +91,10 @@ private static ProcessStartInfo GetLaunchStartInfo(string? path)
private ProcessStartInfo GetRevealStartInfoWindows(string path)
{
var fileName = "explorer";
- var sysRoot = this.getEnvironmentVariable("SYSTEMROOT");
+ var sysRoot = getEnvironmentVariable("SYSTEMROOT");
if (sysRoot != null)
{
- fileName = this.fs.Path.Combine(sysRoot, fileName);
+ fileName = fs.Path.Combine(sysRoot, fileName);
}
return new ProcessStartInfo
@@ -126,7 +117,7 @@ private ProcessStartInfo GetRevealStartInfoDBus(string path)
private ProcessStartInfo GetOpenParentFolderStartInfo(string path)
{
- return GetLaunchStartInfo(this.fs.Path.GetDirectoryName(path));
+ return GetLaunchStartInfo(fs.Path.GetDirectoryName(path));
}
private ProcessStartInfo GetRevealStartInfo(string path)
diff --git a/czishrink/netczicompress/Models/MultiThreadedFolderCompressor.cs b/czishrink/netczicompress/Models/MultiThreadedFolderCompressor.cs
index 37ede24..1646ff7 100644
--- a/czishrink/netczicompress/Models/MultiThreadedFolderCompressor.cs
+++ b/czishrink/netczicompress/Models/MultiThreadedFolderCompressor.cs
@@ -18,22 +18,12 @@ namespace netczicompress.Models;
///
/// A multi-threaded that uses s to do the actual work.
///
-public class MultiThreadedFolderCompressor : IFolderCompressor
-{
- private readonly CreateProcessor createProcessor;
- private readonly FileProcessingFailedHandler fileProcessingFailedHandler;
- private readonly int maxTriesToCreateTemporaryFile;
-
- public MultiThreadedFolderCompressor(
+public class MultiThreadedFolderCompressor(
CreateProcessor createProcessor,
FileProcessingFailedHandler fileProcessingFailedHandler,
int maxTriesToCreateTemporaryFiles = 100)
- {
- this.createProcessor = createProcessor;
- this.fileProcessingFailedHandler = fileProcessingFailedHandler ?? throw new ArgumentNullException(nameof(fileProcessingFailedHandler));
- this.maxTriesToCreateTemporaryFile = maxTriesToCreateTemporaryFiles;
- }
-
+ : IFolderCompressor
+{
// Public only for testing. MockFileSystem does not support CaseInsensitive
public MatchCasing MatchExtensionCasing { get; init; } = MatchCasing.CaseInsensitive;
@@ -83,7 +73,7 @@ async IAsyncEnumerable CoreAsync([EnumeratorCancellation] Can
if (activeTasks.Count < maxNumberOfThreads)
{
- var processor = this.createProcessor(mode, processingOptions);
+ var processor = createProcessor(mode, processingOptions);
processors.Add(processor);
activeTasks.Add(Run(processor));
}
@@ -218,7 +208,7 @@ private CompressorMessage.FileFinished ProcessFile(
EnsureParentDirectoryExists(outFile);
}
- temporaryFile = new TemporaryFile(outFile, this.maxTriesToCreateTemporaryFile);
+ temporaryFile = new TemporaryFile(outFile, maxTriesToCreateTemporaryFiles);
if (temporaryFile.TemporaryFileCreationFailed)
{
var tempOutFile = temporaryFile.Info;
@@ -247,7 +237,7 @@ private CompressorMessage.FileFinished ProcessFile(
// We only cover those exceptions, that have been reported when processing the file, i.e. processedByProcessor is false.
var tempOutFile = temporaryFile.Info;
return MakeTheReturnValue(
- this.fileProcessingFailedHandler.FileProcessingFailed(
+ fileProcessingFailedHandler.FileProcessingFailed(
inFile,
outFile,
tempOutFile,
diff --git a/czishrink/netczicompress/Models/ObservableMixin.CompleteOnError.cs b/czishrink/netczicompress/Models/ObservableMixin.CompleteOnError.cs
index f37a52a..b06a076 100644
--- a/czishrink/netczicompress/Models/ObservableMixin.CompleteOnError.cs
+++ b/czishrink/netczicompress/Models/ObservableMixin.CompleteOnError.cs
@@ -26,18 +26,11 @@ public static IObservable CompleteOnError(this IObservable obs)
return new CompleteOnErrorDecorator(obs);
}
- public class CompleteOnErrorDecorator : IObservable
+ public class CompleteOnErrorDecorator(IObservable core) : IObservable
{
- private readonly IObservable core;
-
- public CompleteOnErrorDecorator(IObservable core)
- {
- this.core = core;
- }
-
public IDisposable Subscribe(IObserver observer)
{
- return this.core.Subscribe(
+ return core.Subscribe(
onNext: observer.OnNext,
onCompleted: observer.OnCompleted,
onError: ex => observer.OnCompleted());
diff --git a/czishrink/netczicompress/Models/PInvokeFileProcessor.cs b/czishrink/netczicompress/Models/PInvokeFileProcessor.cs
index 8a71f1c..09ad27e 100644
--- a/czishrink/netczicompress/Models/PInvokeFileProcessor.cs
+++ b/czishrink/netczicompress/Models/PInvokeFileProcessor.cs
@@ -118,10 +118,7 @@ public void Dispose()
private void CheckDisposed()
{
- if (this.IsDisposed)
- {
- throw new ObjectDisposedException(this.ToString());
- }
+ ObjectDisposedException.ThrowIf(this.IsDisposed, this);
}
internal static partial class NativeMethods
@@ -199,7 +196,7 @@ public static string GetLibFullName(int suggestedBufferLength = 64)
[LibraryImport(LibName, StringMarshalling = LibStringEncoding)]
[return: MarshalAs(UnmanagedType.U1)]
- public static partial bool GetLibVersionString(byte[] buffer, ref ulong bufferLength);
+ public static partial bool GetLibVersionString([Out] byte[] buffer, ref ulong bufferLength);
[LibraryImport(LibName, StringMarshalling = LibStringEncoding)]
public static partial void GetLibVersion(out int major, out int minor, out int patch);
@@ -215,7 +212,7 @@ public static partial int ProcessFile(
IntPtr file_processor,
string input_path,
string output_path,
- byte[] error_message,
+ [Out] byte[] error_message,
ref int error_message_length,
ReportProgressCheckCancel reportProgress);
}
diff --git a/czishrink/netczicompress/Models/StatisticsRunObserver.cs b/czishrink/netczicompress/Models/StatisticsRunObserver.cs
index 76441ce..6ff7932 100644
--- a/czishrink/netczicompress/Models/StatisticsRunObserver.cs
+++ b/czishrink/netczicompress/Models/StatisticsRunObserver.cs
@@ -11,38 +11,28 @@ namespace netczicompress.Models;
///
/// An that forwards to an observer of these.
///
-public class StatisticsRunObserver : IFolderCompressorRunObserver
-{
- private readonly IObserver statisticsObserver;
- private readonly TimeSpan samplingInterval;
- private readonly IScheduler scheduler;
-
- public StatisticsRunObserver(
+public class StatisticsRunObserver(
IObserver statisticsObserver,
TimeSpan samplingInterval,
IScheduler scheduler)
- {
- this.statisticsObserver = statisticsObserver;
- this.samplingInterval = samplingInterval;
- this.scheduler = scheduler;
- }
-
+ : IFolderCompressorRunObserver
+{
public void ObserveRun(FolderCompressorParameters runParameters, IObservable runMessages)
{
- var start = this.scheduler.Now;
+ var start = scheduler.Now;
var emptyStats = AggregateStatistics.Empty;
- this.statisticsObserver.OnNext(emptyStats);
+ statisticsObserver.OnNext(emptyStats);
var cumulativeStatistics = runMessages
.CompleteOnError()
.Scan(
emptyStats,
- (stats, msg) => stats.AddData(msg, this.scheduler.Now - start));
+ (stats, msg) => stats.AddData(msg, scheduler.Now - start));
// Subscriptions will expire upon completion, no need for explicit disposal.
_ = cumulativeStatistics
- .Sample(this.samplingInterval)
- .ObserveOn(this.scheduler)
- .Subscribe(this.statisticsObserver);
+ .Sample(samplingInterval)
+ .ObserveOn(scheduler)
+ .Subscribe(statisticsObserver);
}
}
\ No newline at end of file
diff --git a/czishrink/netczicompress/Models/TemporaryFile.cs b/czishrink/netczicompress/Models/TemporaryFile.cs
index d4b8eea..a644ce8 100644
--- a/czishrink/netczicompress/Models/TemporaryFile.cs
+++ b/czishrink/netczicompress/Models/TemporaryFile.cs
@@ -27,13 +27,13 @@ public class TemporaryFile
/// immediately created, if possible.
/// By this is set accordingly.
///
- /// The basic output file name.
+ /// The basic output file name.
/// The maximum number or tries.
public TemporaryFile(
- IFileInfo outfile,
+ IFileInfo outFile,
int maxNumberOfTriesToCreate = 100)
{
- this.OutFile = outfile;
+ this.OutFile = outFile;
this.MaxNumberOfTriesToCreate = maxNumberOfTriesToCreate;
this.Info = this.TryCreate();
}
diff --git a/czishrink/netczicompress/Models/ThreadCount.cs b/czishrink/netczicompress/Models/ThreadCount.cs
index 1ac5d98..963f199 100644
--- a/czishrink/netczicompress/Models/ThreadCount.cs
+++ b/czishrink/netczicompress/Models/ThreadCount.cs
@@ -25,7 +25,7 @@ static ThreadCount()
///
public static int DefaultValue { get; } = Maximum;
- public int Value
+ public required int Value
{
get => this.internalValue;
init =>
diff --git a/czishrink/netczicompress/Models/TraceLoggerFactory.cs b/czishrink/netczicompress/Models/TraceLoggerFactory.cs
index 9f44d5a..59b378d 100644
--- a/czishrink/netczicompress/Models/TraceLoggerFactory.cs
+++ b/czishrink/netczicompress/Models/TraceLoggerFactory.cs
@@ -17,18 +17,13 @@ namespace netczicompress.Models;
///
/// is not supported.
///
-public sealed class TraceLoggerFactory : ILoggerFactory, ILoggerProvider
+public sealed class TraceLoggerFactory(bool useLogLevelsAsTraceLevels = false)
+ : ILoggerFactory,
+ ILoggerProvider
{
- private readonly bool useLogLevelsAsTraceLevels;
-
- public TraceLoggerFactory(bool useLogLevelsAsTraceLevels = false)
- {
- this.useLogLevelsAsTraceLevels = useLogLevelsAsTraceLevels;
- }
-
public ILogger CreateLogger(string categoryName)
{
- return new TraceLogger(categoryName, this.useLogLevelsAsTraceLevels);
+ return new TraceLogger(categoryName, useLogLevelsAsTraceLevels);
}
void ILoggerFactory.AddProvider(ILoggerProvider provider)
@@ -36,28 +31,22 @@ void ILoggerFactory.AddProvider(ILoggerProvider provider)
throw new NotSupportedException();
}
- void IDisposable.Dispose()
- {
- Trace.Flush();
- }
+ void IDisposable.Dispose() => Trace.Flush();
- private sealed class TraceLogger : ILogger
+ private sealed class TraceLogger(string categoryName, bool useLogLevelsAsTraceLevels)
+ : ILogger
{
- private readonly string categoryName;
- private readonly bool useLogLevelsAsTraceLevels;
-
- public TraceLogger(string categoryName, bool useLogLevelsAsTraceLevels)
- {
- this.categoryName = categoryName;
- this.useLogLevelsAsTraceLevels = useLogLevelsAsTraceLevels;
- }
-
- public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter)
+ public void Log(
+ LogLevel logLevel,
+ EventId eventId,
+ TState state,
+ Exception? exception,
+ Func formatter)
{
if (this.IsEnabled(logLevel))
{
- var msg = $"{DateTimeOffset.Now:O}|{this.categoryName}|{ToString(logLevel)}|{eventId}|{formatter(state, exception)}";
- if (this.useLogLevelsAsTraceLevels)
+ var msg = $"{DateTimeOffset.Now:O}|{categoryName}|{ToString(logLevel)}|{eventId}|{formatter(state, exception)}";
+ if (useLogLevelsAsTraceLevels)
{
switch (logLevel)
{
diff --git a/czishrink/netczicompress/ViewModels/AggregateStatisticsViewModel.cs b/czishrink/netczicompress/ViewModels/AggregateStatisticsViewModel.cs
index cb58355..7f97326 100644
--- a/czishrink/netczicompress/ViewModels/AggregateStatisticsViewModel.cs
+++ b/czishrink/netczicompress/ViewModels/AggregateStatisticsViewModel.cs
@@ -100,22 +100,23 @@ private void DoCopyBadgeToClipboard()
// call measure once with infinity so that we get the "desired size" populated
control.Measure(Size.Infinity);
var size = control.DesiredSize;
+ int width = (int)size.Width;
+ int height = (int)size.Height;
+ size = new Size(width, height);
control.Measure(size);
control.Arrange(new Rect(size));
- using (RenderTargetBitmap bitmap = new RenderTargetBitmap(new PixelSize(Convert.ToInt32(size.Width), Convert.ToInt32(size.Height))))
+ using var bitmap = new RenderTargetBitmap(new PixelSize(width, height));
+ bitmap.Render(control);
+ try
{
- bitmap.Render(control);
- try
- {
- this.clipboardHelper.PutBitmapIntoClipboard(bitmap);
- this.BadgeCopiedToClipboardRaised?.Invoke();
- }
- catch (Exception exception)
- {
- this.logger.LogError(exception, "putting badge into clipboard failed: {ex}", exception);
- }
+ this.clipboardHelper.PutBitmapIntoClipboard(bitmap);
+ this.BadgeCopiedToClipboardRaised?.Invoke();
+ }
+ catch (Exception exception)
+ {
+ this.logger.LogError(exception, "putting badge into clipboard failed: {ex}", exception);
}
}
}
diff --git a/czishrink/netczicompress/ViewModels/Converters/BytesToStringConverter.cs b/czishrink/netczicompress/ViewModels/Converters/BytesToStringConverter.cs
index 1416414..fa6dfa2 100644
--- a/czishrink/netczicompress/ViewModels/Converters/BytesToStringConverter.cs
+++ b/czishrink/netczicompress/ViewModels/Converters/BytesToStringConverter.cs
@@ -15,7 +15,8 @@ public class BytesToStringConverter : ForwardOnlyConverter
{
// See: https://en.wikipedia.org/wiki/Kilobyte
// Made the array future-proof in any case.
- private static readonly string[] Sizes = { "bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB" };
+ private static readonly string[] Sizes =
+ ["bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"];
public override object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
diff --git a/czishrink/netczicompress/packages.lock.json b/czishrink/netczicompress/packages.lock.json
index de72b44..3d2c9d8 100644
--- a/czishrink/netczicompress/packages.lock.json
+++ b/czishrink/netczicompress/packages.lock.json
@@ -1,7 +1,7 @@
{
"version": 2,
"dependencies": {
- "net7.0": {
+ "net8.0": {
"Avalonia": {
"type": "Direct",
"requested": "[11.0.5, )",
@@ -84,6 +84,12 @@
"Markdown.Avalonia.Tight": "11.0.2"
}
},
+ "Microsoft.DotNet.ILCompiler": {
+ "type": "Direct",
+ "requested": "[8.0.0, )",
+ "resolved": "8.0.0",
+ "contentHash": "zuTbpcWDCCvESnOAvpHuwum1C3jJIeDl+grYcRDqyoHsPAUutIB6wb7iJV3Y2Q96crKC6cObqf92eOVEiG7keQ=="
+ },
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Direct",
"requested": "[8.0.0, )",
@@ -93,6 +99,12 @@
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0"
}
},
+ "Microsoft.NET.ILLink.Tasks": {
+ "type": "Direct",
+ "requested": "[8.0.0, )",
+ "resolved": "8.0.0",
+ "contentHash": "B3etT5XQ2nlWkZGO2m/ytDYrOmSsQG1XNBaM6ZYlX5Ch/tDrMFadr0/mK6gjZwaQc55g+5+WZMw4Cz3m8VEF7g=="
+ },
"Projektanker.Icons.Avalonia.FontAwesome": {
"type": "Direct",
"requested": "[8.3.0, )",
diff --git a/czishrink/netczicompressTests/Models/CompressionLevelTests.cs b/czishrink/netczicompressTests/Models/CompressionLevelTests.cs
index 1a0cd70..a6ca958 100644
--- a/czishrink/netczicompressTests/Models/CompressionLevelTests.cs
+++ b/czishrink/netczicompressTests/Models/CompressionLevelTests.cs
@@ -10,9 +10,9 @@ namespace netczicompressTests.Models;
public class CompressionLevelTests
{
[Fact]
- public void DefaultConstructor_HasDefaultValue()
+ public void Default_HasDefaultValue()
{
- var sut = new CompressionLevel();
+ var sut = CompressionLevel.Default;
sut.Value.Should().Be(CompressionLevel.DefaultValue);
}
diff --git a/czishrink/netczicompressTests/Models/PInvokeFileProcessorTests.cs b/czishrink/netczicompressTests/Models/PInvokeFileProcessorTests.cs
index 66afb62..91b5431 100644
--- a/czishrink/netczicompressTests/Models/PInvokeFileProcessorTests.cs
+++ b/czishrink/netczicompressTests/Models/PInvokeFileProcessorTests.cs
@@ -17,7 +17,7 @@ public class PInvokeFileProcessorTests
[Fact]
public void Ctr_WhenCalledWithNoOp_Throws()
{
- Action act = () => _ = new PInvokeFileProcessor(CompressionMode.NoOp, new ProcessingOptions(new CompressionLevel()));
+ Action act = () => _ = new PInvokeFileProcessor(CompressionMode.NoOp, new ProcessingOptions(new CompressionLevel { Value = CompressionLevel.DefaultValue }));
act.Should().Throw().WithParameterName("mode");
}
@@ -39,10 +39,10 @@ public void CompressAndDecompressOneFile_FilesHaveCorrectSizeAndMetadata(
using var deleteUncompressed = Disposable.Create(() => File.Delete(uncompressed));
// ACT
- using var compressor = new PInvokeFileProcessor(mode, new ProcessingOptions(new CompressionLevel()));
+ using var compressor = new PInvokeFileProcessor(mode, new ProcessingOptions(CompressionLevel.Default));
compressor.ProcessFile(testFile, compressed, _ => { }, CancellationToken.None);
- using var decompressor = new PInvokeFileProcessor(CompressionMode.Decompress, new ProcessingOptions(new CompressionLevel()));
+ using var decompressor = new PInvokeFileProcessor(CompressionMode.Decompress, new ProcessingOptions(CompressionLevel.Default));
decompressor.ProcessFile(compressed, uncompressed, _ => { }, CancellationToken.None);
var compressedSize = GetLength(compressed);
@@ -67,7 +67,7 @@ public void CompressAndDecompressOneFile_FilesHaveCorrectSizeAndMetadata(
public void NeedsExistingOutputDirectory_ShouldBeTrue(
CompressionMode mode)
{
- using var target = new PInvokeFileProcessor(mode, new ProcessingOptions(new CompressionLevel()));
+ using var target = new PInvokeFileProcessor(mode, new ProcessingOptions(CompressionLevel.Default));
target.NeedsExistingOutputDirectory.Should().BeTrue();
}
@@ -86,7 +86,7 @@ public void ProcessFile_WhenCancelled_Throws(
using var deleteCompressed = DeleteLater(compressed);
// ACT
- using var compressor = PInvokeFileProcessor.Create(mode, new ProcessingOptions(new CompressionLevel()));
+ using var compressor = PInvokeFileProcessor.Create(mode, new ProcessingOptions(CompressionLevel.Default));
var token = new CancellationToken(true);
Action act = () => compressor.ProcessFile(testFile, compressed, _ => { }, token);
@@ -105,7 +105,7 @@ public void ProcessFile_WhenDisposed_Throws(
CompressionMode mode)
{
// ARRANGE
- using var compressor = PInvokeFileProcessor.Create(mode, new ProcessingOptions(new CompressionLevel()));
+ using var compressor = PInvokeFileProcessor.Create(mode, new ProcessingOptions(CompressionLevel.Default));
compressor.Dispose();
Action act = () => compressor.ProcessFile("foo", "bar", _ => { }, CancellationToken.None);
@@ -139,13 +139,13 @@ public void CompressWithLevel_FilesHaveCorrectSize(
// ACT
using var compressor = new PInvokeFileProcessor(
CompressionMode.CompressAll,
- new ProcessingOptions(new CompressionLevel()
+ new ProcessingOptions(new CompressionLevel
{
Value = compressionLevel,
}));
compressor.ProcessFile(testFile, compressed, _ => { }, CancellationToken.None);
- using var decompressor = new PInvokeFileProcessor(CompressionMode.Decompress, new ProcessingOptions(new CompressionLevel()));
+ using var decompressor = new PInvokeFileProcessor(CompressionMode.Decompress, new ProcessingOptions(CompressionLevel.Default));
decompressor.ProcessFile(compressed, uncompressed, _ => { }, CancellationToken.None);
var compressedSize = GetLength(compressed);
diff --git a/czishrink/netczicompressTests/Models/ProgramNameAndVersionTests.cs b/czishrink/netczicompressTests/Models/ProgramNameAndVersionTests.cs
index a2ee857..9251b45 100644
--- a/czishrink/netczicompressTests/Models/ProgramNameAndVersionTests.cs
+++ b/czishrink/netczicompressTests/Models/ProgramNameAndVersionTests.cs
@@ -4,8 +4,6 @@
namespace netczicompressTests.Models;
-using System.Text.RegularExpressions;
-
///
/// Tests for .
///
@@ -18,7 +16,7 @@ public void ToString_WhenCalled_ReturnsExpected()
var actual = new ProgramNameAndVersion().ToString();
// ASSERT
- actual.Should().MatchRegex(@"^CZI Shrink 1\.0\.\d+(\+\d+)?$");
+ actual.Should().MatchRegex(@"^CZI Shrink 1\.1\.\d+(\+\d+)?$");
}
[Fact]
@@ -38,6 +36,6 @@ public void Version_WhenCalled_ReturnsExpected()
var actual = new ProgramNameAndVersion().Version;
// ASSERT
- actual.Should().MatchRegex(@"^1\.0\.\d+(\+\d+)?$");
+ actual.Should().MatchRegex(@"^1\.1\.\d+(\+\d+)?$");
}
}
diff --git a/czishrink/netczicompressTests/Models/ThreadCountTests.cs b/czishrink/netczicompressTests/Models/ThreadCountTests.cs
index bb7466e..fd799a4 100644
--- a/czishrink/netczicompressTests/Models/ThreadCountTests.cs
+++ b/czishrink/netczicompressTests/Models/ThreadCountTests.cs
@@ -10,9 +10,9 @@ namespace netczicompressTests.Models;
public class ThreadCountTests
{
[Fact]
- public void DefaultConstructor_HasDefaultValue()
+ public void Default_HasDefaultValue()
{
- var sut = new ThreadCount();
+ var sut = ThreadCount.Default;
sut.Value.Should().Be(ThreadCount.DefaultValue);
}
@@ -31,7 +31,7 @@ public void OutOfRange_ShouldThrowOutOfRangeException(int value)
[InlineData(1)]
public void InRangeValue_ShouldBeEqual(int value)
{
- var sut = new ThreadCount() { Value = value };
+ var sut = new ThreadCount { Value = value };
sut.Value.Should().Be(value);
}
}
\ No newline at end of file
diff --git a/czishrink/netczicompressTests/packages.lock.json b/czishrink/netczicompressTests/packages.lock.json
index 5c84e03..fc11f9a 100644
--- a/czishrink/netczicompressTests/packages.lock.json
+++ b/czishrink/netczicompressTests/packages.lock.json
@@ -1,7 +1,7 @@
{
"version": 2,
"dependencies": {
- "net7.0": {
+ "net8.0": {
"AutoFixture": {
"type": "Direct",
"requested": "[4.18.0, )",