Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 36 changed files with 78 additions and 74 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
<PackageVersion Include="Testably.Abstractions.FluentAssertions" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.163" />
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.185" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Pipeline/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ partial class Build

StringBuilder sb = new();
string[] lines = File.ReadAllLines(Solution.Directory / "README.md");
sb.AppendLine(lines.First());
sb.AppendLine(lines[0]);
sb.AppendLine(
$"[![Changelog](https://img.shields.io/badge/Changelog-v{version}-blue)](https://github.com/Testably/Testably.Abstractions/releases/tag/v{version})");
foreach (string line in lines.Skip(1))
Expand Down
2 changes: 1 addition & 1 deletion Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>1701;1702</NoWarn>
<NoWarn>$(NoWarn);1701;1702;MA0003;MA0004;MA0042;MA0076</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal static void CreateFromDirectory(IFileSystem fileSystem,
#pragma warning disable MA0074
string entryName = file.FullName
.Substring(basePath.Length + 1)
.Replace("\\", "/");
.Replace('\\', '/');
#pragma warning restore MA0074
ZipArchiveEntry entry = compressionLevel.HasValue
? archive.CreateEntry(entryName, compressionLevel.Value)
Expand Down Expand Up @@ -166,7 +166,7 @@ internal static void CreateFromDirectory(
#pragma warning disable MA0074
string entryName = file.FullName
.Substring(basePath.Length + 1)
.Replace("\\", "/");
.Replace('\\', '/');
#pragma warning restore MA0074
ZipArchiveEntry entry = compressionLevel.HasValue
? archive.CreateEntry(entryName, compressionLevel.Value)
Expand Down Expand Up @@ -268,7 +268,8 @@ internal static void ExtractToDirectory(IFileSystem fileSystem,
throw new ArgumentException("The stream is unreadable.", nameof(source));
}

using (ZipArchive archive = new(source, ZipArchiveMode.Read, true, entryNameEncoding))
using (ZipArchive archive = new(source, ZipArchiveMode.Read,
leaveOpen: true, entryNameEncoding))
{
ZipArchiveWrapper wrappedArchive = new(fileSystem, archive);
foreach (ZipArchiveEntry entry in archive.Entries)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void Delete()
public void ExtractToFile(string destinationFileName)
=> Execute.WhenRealFileSystem(FileSystem,
() => _instance.ExtractToFile(destinationFileName),
() => ExtractToFile(destinationFileName, false));
() => ExtractToFile(destinationFileName, overwrite: false));

/// <inheritdoc cref="IZipArchiveEntry.ExtractToFile(string, bool)" />
public void ExtractToFile(string destinationFileName, bool overwrite)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void ExtractToDirectory(string destinationDirectoryName)
{
foreach (IZipArchiveEntry entry in Entries)
{
entry.ExtractRelativeToDirectory(destinationDirectoryName, false);
entry.ExtractRelativeToDirectory(destinationDirectoryName, overwrite: false);
}
});
}
Expand Down
24 changes: 12 additions & 12 deletions Source/Testably.Abstractions.Testing/FileSystem/FileMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public void AppendAllLines(

#if FEATURE_FILESYSTEM_ASYNC
/// <inheritdoc cref="IFile.AppendAllLinesAsync(string, IEnumerable{string}, CancellationToken)" />
public Task AppendAllLinesAsync(string path, IEnumerable<string> contents,
public async Task AppendAllLinesAsync(string path, IEnumerable<string> contents,
CancellationToken cancellationToken = default)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.File.RegisterMethod(nameof(AppendAllLinesAsync),
path, contents, cancellationToken);

return AppendAllLinesAsync(path, contents, Encoding.Default, cancellationToken);
await AppendAllLinesAsync(path, contents, Encoding.Default, cancellationToken);
}
#endif

Expand Down Expand Up @@ -135,14 +135,14 @@ public void AppendAllText(string path, string? contents, Encoding encoding)

#if FEATURE_FILESYSTEM_ASYNC
/// <inheritdoc cref="IFile.AppendAllTextAsync(string, string?, CancellationToken)" />
public Task AppendAllTextAsync(string path, string? contents,
public async Task AppendAllTextAsync(string path, string? contents,
CancellationToken cancellationToken = default)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.File.RegisterMethod(nameof(AppendAllTextAsync),
path, contents, cancellationToken);

return AppendAllTextAsync(path, contents, Encoding.Default, cancellationToken);
await AppendAllTextAsync(path, contents, Encoding.Default, cancellationToken);
}
#endif

Expand Down Expand Up @@ -774,15 +774,15 @@ public string[] ReadAllLines(string path, Encoding encoding)

#if FEATURE_FILESYSTEM_ASYNC
/// <inheritdoc cref="IFile.ReadAllLinesAsync(string, CancellationToken)" />
public Task<string[]> ReadAllLinesAsync(
public async Task<string[]> ReadAllLinesAsync(
string path,
CancellationToken cancellationToken = default)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.File.RegisterMethod(nameof(ReadAllLinesAsync),
path, cancellationToken);

return ReadAllLinesAsync(path, Encoding.Default, cancellationToken);
return await ReadAllLinesAsync(path, Encoding.Default, cancellationToken);
}
#endif

Expand Down Expand Up @@ -839,15 +839,15 @@ public string ReadAllText(string path, Encoding encoding)

#if FEATURE_FILESYSTEM_ASYNC
/// <inheritdoc cref="IFile.ReadAllTextAsync(string, CancellationToken)" />
public Task<string> ReadAllTextAsync(
public async Task<string> ReadAllTextAsync(
string path,
CancellationToken cancellationToken = default)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.File.RegisterMethod(nameof(ReadAllTextAsync),
path, cancellationToken);

return ReadAllTextAsync(path, Encoding.Default, cancellationToken);
return await ReadAllTextAsync(path, Encoding.Default, cancellationToken);
}
#endif

Expand Down Expand Up @@ -1307,7 +1307,7 @@ public void WriteAllLines(

#if FEATURE_FILESYSTEM_ASYNC
/// <inheritdoc cref="IFile.WriteAllLinesAsync(string, IEnumerable{string}, CancellationToken)" />
public Task WriteAllLinesAsync(
public async Task WriteAllLinesAsync(
string path,
IEnumerable<string> contents,
CancellationToken cancellationToken = default)
Expand All @@ -1316,7 +1316,7 @@ public Task WriteAllLinesAsync(
.File.RegisterMethod(nameof(WriteAllLinesAsync),
path, contents, cancellationToken);

return WriteAllLinesAsync(path, contents, Encoding.Default, cancellationToken);
await WriteAllLinesAsync(path, contents, Encoding.Default, cancellationToken);
}
#endif

Expand Down Expand Up @@ -1390,14 +1390,14 @@ public void WriteAllText(string path, string? contents, Encoding encoding)

#if FEATURE_FILESYSTEM_ASYNC
/// <inheritdoc cref="IFile.WriteAllTextAsync(string, string?, CancellationToken)" />
public Task WriteAllTextAsync(string path, string? contents,
public async Task WriteAllTextAsync(string path, string? contents,
CancellationToken cancellationToken = default)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.File.RegisterMethod(nameof(WriteAllTextAsync),
path, contents, cancellationToken);

return WriteAllTextAsync(path, contents, Encoding.Default, cancellationToken);
await WriteAllTextAsync(path, contents, Encoding.Default, cancellationToken);
}
#endif

Expand Down
20 changes: 10 additions & 10 deletions Source/Testably.Abstractions.Testing/FileSystem/FileStreamMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ public override void CopyTo(Stream destination, int bufferSize)
}

/// <inheritdoc cref="FileSystemStream.CopyToAsync(Stream, int, CancellationToken)" />
public override Task CopyToAsync(Stream destination, int bufferSize,
public override async Task CopyToAsync(Stream destination, int bufferSize,
CancellationToken cancellationToken)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.FileStream.RegisterPathMethod(_location.FullPath, nameof(CopyToAsync),
destination, bufferSize, cancellationToken);

_container.AdjustTimes(TimeAdjustments.LastAccessTime);
return base.CopyToAsync(destination, bufferSize, cancellationToken);
await base.CopyToAsync(destination, bufferSize, cancellationToken);
}

/// <inheritdoc cref="FileSystemStream.EndRead(IAsyncResult)" />
Expand Down Expand Up @@ -461,7 +461,7 @@ public override int Read(Span<byte> buffer)
#endif

/// <inheritdoc cref="FileSystemStream.ReadAsync(byte[], int, int, CancellationToken)" />
public override Task<int> ReadAsync(byte[] buffer, int offset, int count,
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count,
CancellationToken cancellationToken)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
Expand All @@ -478,12 +478,12 @@ public override Task<int> ReadAsync(byte[] buffer, int offset, int count,
_container.AdjustTimes(TimeAdjustments.LastAccessTime);
}

return base.ReadAsync(buffer, offset, count, cancellationToken);
return await base.ReadAsync(buffer, offset, count, cancellationToken);
}

#if FEATURE_SPAN
/// <inheritdoc cref="FileSystemStream.ReadAsync(Memory{byte}, CancellationToken)" />
public override ValueTask<int> ReadAsync(Memory<byte> buffer,
public override async ValueTask<int> ReadAsync(Memory<byte> buffer,
CancellationToken cancellationToken = new())
{
using IDisposable registration = _fileSystem.StatisticsRegistration
Expand All @@ -500,7 +500,7 @@ public override ValueTask<int> ReadAsync(Memory<byte> buffer,
_container.AdjustTimes(TimeAdjustments.LastAccessTime);
}

return base.ReadAsync(buffer, cancellationToken);
return await base.ReadAsync(buffer, cancellationToken);
}
#endif

Expand Down Expand Up @@ -598,7 +598,7 @@ public override void Write(ReadOnlySpan<byte> buffer)
#endif

/// <inheritdoc cref="FileSystemStream.WriteAsync(byte[], int, int, CancellationToken)" />
public override Task WriteAsync(byte[] buffer, int offset, int count,
public override async Task WriteAsync(byte[] buffer, int offset, int count,
CancellationToken cancellationToken)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
Expand All @@ -611,12 +611,12 @@ public override Task WriteAsync(byte[] buffer, int offset, int count,
}

_isContentChanged = true;
return base.WriteAsync(buffer, offset, count, cancellationToken);
await base.WriteAsync(buffer, offset, count, cancellationToken);
}

#if FEATURE_SPAN
/// <inheritdoc cref="FileSystemStream.WriteAsync(ReadOnlyMemory{byte}, CancellationToken)" />
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer,
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer,
CancellationToken cancellationToken = new())
{
using IDisposable registration = _fileSystem.StatisticsRegistration
Expand All @@ -629,7 +629,7 @@ public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer,
}

_isContentChanged = true;
return base.WriteAsync(buffer, cancellationToken);
await base.WriteAsync(buffer, cancellationToken);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ public WaitForChangedResultMock(
public bool TimedOut { get; }
}

internal class ChangeDescriptionEventArgs(ChangeDescription changeDescription) : EventArgs
internal sealed class ChangeDescriptionEventArgs(ChangeDescription changeDescription) : EventArgs
{
public ChangeDescription ChangeDescription { get; } = changeDescription;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Testably.Abstractions.Testing.Helpers;

internal partial class Execute
internal sealed partial class Execute
{
private class LinuxPath(MockFileSystem fileSystem) : SimulatedPath(fileSystem)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Testably.Abstractions.Testing.Helpers;

internal partial class Execute
internal sealed partial class Execute
{
private sealed class MacPath(MockFileSystem fileSystem) : LinuxPath(fileSystem)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Testably.Abstractions.Testing.Helpers;

internal partial class Execute
internal sealed partial class Execute
{
private sealed class NativePath(MockFileSystem fileSystem) : IPath
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Testably.Abstractions.Testing.Helpers;

internal partial class Execute
internal sealed partial class Execute
{
private abstract class SimulatedPath(MockFileSystem fileSystem) : IPath
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Testably.Abstractions.Testing.Helpers;

internal partial class Execute
internal sealed partial class Execute
{
private sealed class WindowsPath(MockFileSystem fileSystem) : SimulatedPath(fileSystem)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Testably.Abstractions.Testing/Helpers/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Testably.Abstractions.Testing.Helpers;

internal partial class Execute
internal sealed partial class Execute
{
/// <summary>
/// Flag indicating if the code runs on <see cref="OSPlatform.Linux" />.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Testably.Abstractions.Testing.Helpers;

internal class FileSystemExtensibility : IFileSystemExtensibility
internal sealed class FileSystemExtensibility : IFileSystemExtensibility
{
private readonly Dictionary<string, object?> _metadata = new(StringComparer.Ordinal);

Expand Down
12 changes: 6 additions & 6 deletions Source/Testably.Abstractions.Testing/RandomSystem/RandomMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ internal sealed class RandomMock : IRandom
#if FEATURE_RANDOM_ADVANCED
/// <summary>
/// Initializes a new instance of <see cref="RandomMock" /> which allows specifying explicit generators:<br />
/// - <paramref name="intGenerator" />: The generator for <c>int</c> values.
/// - <paramref name="longGenerator" />: The generator for <c>long</c> values.
/// - <paramref name="singleGenerator" />: The generator for <c>float</c> values.
/// - <paramref name="doubleGenerator" />: The generator for <c>double</c> values.
/// - <paramref name="intGenerator" />: The generator for <see langword="int" /> values.
/// - <paramref name="longGenerator" />: The generator for <see langword="long" /> values.
/// - <paramref name="singleGenerator" />: The generator for <see langword="float" /> values.
/// - <paramref name="doubleGenerator" />: The generator for <see langword="double" /> values.
/// - <paramref name="byteGenerator" />: The generator for <c>byte[]</c> values.
/// </summary>
#else
/// <summary>
/// Initializes a new instance of <see cref="RandomMock" /> which allows specifying explicit generators:<br />
/// - <paramref name="intGenerator" />: The generator for <c>int</c> values.
/// - <paramref name="doubleGenerator" />: The generator for <c>double</c> values.
/// - <paramref name="intGenerator" />: The generator for <see langword="int" /> values.
/// - <paramref name="doubleGenerator" />: The generator for <see langword="double" /> values.
/// - <paramref name="byteGenerator" />: The generator for <c>byte[]</c> values.
/// </summary>
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Testably.Abstractions.Testing.Statistics;
public abstract class ParameterDescription
{
/// <summary>
/// Specifies, if the parameter was used as an <c>out</c> parameter.
/// Specifies, if the parameter was used as an <see langword="out" /> parameter.
/// </summary>
public bool IsOutParameter { get; }

Expand All @@ -23,7 +23,7 @@ protected ParameterDescription(bool isOutParameter)
}

/// <summary>
/// Creates a <see cref="ParameterDescription" /> from the <paramref name="value" /> used as an <c>out</c> parameter.
/// Creates a <see cref="ParameterDescription" /> from the <paramref name="value" /> used as an <see langword="out" /> parameter.
/// </summary>
public static ParameterDescription FromOutParameter<T>(T value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Testably.Abstractions.Testing.Statistics;

internal class PathStatistics<TFactory, TType> : CallStatistics<TFactory>,
internal sealed class PathStatistics<TFactory, TType> : CallStatistics<TFactory>,
IPathStatistics<TFactory, TType>
{
private readonly MockFileSystem _fileSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Testably.Abstractions.Testing.Storage;

internal class InMemoryContainer : IStorageContainer
internal sealed class InMemoryContainer : IStorageContainer
{
private FileAttributes _attributes;
private byte[] _bytes = Array.Empty<byte>();
Expand Down
Loading

0 comments on commit 3c033dd

Please sign in to comment.