Skip to content

Commit

Permalink
mark SettingsTask returns as pure
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Sep 18, 2023
1 parent 0adc5a3 commit 355a7fc
Show file tree
Hide file tree
Showing 58 changed files with 250 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Verify.MSTest/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Global using directives

global using System.Diagnostics.Contracts;
3 changes: 3 additions & 0 deletions src/Verify.MSTest/VerifyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,22 @@ static MethodInfo FindMethod(Type type, ReadOnlySpan<char> testName)
throw new($"Could not find method `{type.Name}.{testName.ToString()}`.");
}

[Pure]
public SettingsTask Verify(
object? target,
IEnumerable<Target> rawTargets,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.Verify(target, rawTargets));

[Pure]
public SettingsTask Verify(
IEnumerable<Target> targets,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.Verify(targets));

[Pure]
public SettingsTask Verify(
Target target,
VerifySettings? settings = null,
Expand Down
3 changes: 3 additions & 0 deletions src/Verify.MSTest/VerifyBase_Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public partial class VerifyBase
/// <summary>
/// Verifies the contents of a <see cref="ZipArchive"/>
/// </summary>
[Pure]
public SettingsTask Verify(
ZipArchive archive,
Func<ZipArchiveEntry, bool>? include = null,
Expand All @@ -19,6 +20,7 @@ public SettingsTask Verify(
/// <summary>
/// Verifies the contents of a <see cref="ZipArchive"/>
/// </summary>
[Pure]
public SettingsTask VerifyZip(
string path,
Func<ZipArchiveEntry, bool>? include = null,
Expand All @@ -31,6 +33,7 @@ public SettingsTask VerifyZip(
/// <summary>
/// Verifies the contents of a <see cref="ZipArchive"/>
/// </summary>
[Pure]
public SettingsTask VerifyZip(
Stream stream,
Func<ZipArchiveEntry, bool>? include = null,
Expand Down
4 changes: 4 additions & 0 deletions src/Verify.MSTest/VerifyBase_Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public partial class VerifyBase
/// <summary>
/// Verifies the contents of <paramref name="path"/>.
/// </summary>
[Pure]
public SettingsTask VerifyDirectory(
string path,
Func<string, bool>? include = null,
Expand All @@ -22,6 +23,7 @@ public SettingsTask VerifyDirectory(
/// Verifies the contents of <paramref name="path"/>.
/// Differs from passing <see cref="DirectoryInfo"/> to <code>Verify(object? target)</code> which will verify the full path.
/// </summary>
[Pure]
public SettingsTask VerifyDirectory(
DirectoryInfo path,
Func<string, bool>? include = null,
Expand All @@ -37,6 +39,7 @@ public SettingsTask VerifyDirectory(
/// <summary>
/// Verifies the contents of <paramref name="path"/>.
/// </summary>
[Pure]
public SettingsTask VerifyDirectory(
string path,
Func<string, bool>? include = null,
Expand All @@ -52,6 +55,7 @@ public SettingsTask VerifyDirectory(
/// Verifies the contents of <paramref name="path"/>.
/// Differs from passing <see cref="DirectoryInfo"/> to <code>Verify(object? target)</code> which will verify the full path.
/// </summary>
[Pure]
public SettingsTask VerifyDirectory(
DirectoryInfo path,
Func<string, bool>? include = null,
Expand Down
2 changes: 2 additions & 0 deletions src/Verify.MSTest/VerifyBase_File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public partial class VerifyBase
/// <summary>
/// Verifies the contents of <paramref name="path"/>.
/// </summary>
[Pure]
public SettingsTask VerifyFile(
string path,
VerifySettings? settings = null,
Expand All @@ -16,6 +17,7 @@ public SettingsTask VerifyFile(
/// Verifies the contents of <paramref name="path"/>.
/// Differs from passing <see cref="FileInfo"/> to <code>Verify(object? target)</code> which will verify the full path.
/// </summary>
[Pure]
public SettingsTask VerifyFile(
FileInfo path,
VerifySettings? settings = null,
Expand Down
6 changes: 6 additions & 0 deletions src/Verify.MSTest/VerifyBase_Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,42 @@

public partial class VerifyBase
{
[Pure]
public SettingsTask VerifyJson(
string? target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyJson(target));

[Pure]
public SettingsTask VerifyJson(
Task<string> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyJson(target));

[Pure]
public SettingsTask VerifyJson(
ValueTask<string> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyJson(target));

[Pure]
public SettingsTask VerifyJson(
Stream? target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyJson(target));

[Pure]
public SettingsTask VerifyJson(
Task<Stream> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyJson(target));

[Pure]
public SettingsTask VerifyJson(
ValueTask<Stream> target,
VerifySettings? settings = null,
Expand Down
4 changes: 4 additions & 0 deletions src/Verify.MSTest/VerifyBase_Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@

public partial class VerifyBase
{
[Pure]
public SettingsTask Verify<T>(
Task<T> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "")=>
Verify(settings, sourceFile, _ => _.Verify(target));

[Pure]
public SettingsTask Verify<T>(
ValueTask<T> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.Verify(target));

[Pure]
public SettingsTask Verify<T>(
IAsyncEnumerable<T> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "")=>
Verify(settings, sourceFile, _ => _.Verify(target));

[Pure]
public SettingsTask Verify(
object? target,
VerifySettings? settings = null,
Expand Down
10 changes: 10 additions & 0 deletions src/Verify.MSTest/VerifyBase_Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public partial class VerifyBase
{
[Pure]
public SettingsTask Verify(
byte[]? target,
string extension,
Expand All @@ -10,13 +11,15 @@ public SettingsTask Verify(
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, extension, info));

[Pure]
public SettingsTask Verify(
byte[]? target,
VerifySettings? settings = null,
object? info = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, info));

[Pure]
public SettingsTask Verify(
Task<byte[]> target,
string extension,
Expand All @@ -25,6 +28,7 @@ public SettingsTask Verify(
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, extension, info));

[Pure]
public SettingsTask Verify(
ValueTask<byte[]> target,
string extension,
Expand All @@ -33,13 +37,15 @@ public SettingsTask Verify(
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, extension, info));

[Pure]
public SettingsTask Verify(
FileStream? target,
VerifySettings? settings = null,
object? info = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, info));

[Pure]
public SettingsTask Verify(
Stream? target,
string extension,
Expand All @@ -48,13 +54,15 @@ public SettingsTask Verify(
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, extension, info));

[Pure]
public SettingsTask Verify(
Stream? target,
VerifySettings? settings = null,
object? info = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, info));

[Pure]
public SettingsTask Verify<T>(
Task<T> target,
string extension,
Expand All @@ -64,6 +72,7 @@ public SettingsTask Verify<T>(
where T : Stream =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, extension, info));

[Pure]
public SettingsTask Verify<T>(
ValueTask<T> target,
string extension,
Expand All @@ -73,6 +82,7 @@ public SettingsTask Verify<T>(
where T : Stream =>
Verify(settings, sourceFile, _ => _.VerifyStream(target, extension, info));

[Pure]
public SettingsTask Verify<T>(
IEnumerable<T> targets,
string extension,
Expand Down
4 changes: 4 additions & 0 deletions src/Verify.MSTest/VerifyBase_String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

public partial class VerifyBase
{
[Pure]
public SettingsTask Verify(
string? target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyString(target));

[Pure]
public SettingsTask Verify(
Task<string> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyString(target));

[Pure]
public SettingsTask Verify(
string? target,
string extension,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyString(target, extension));

[Pure]
public SettingsTask Verify(
Task<string> target,
string extension,
Expand Down
6 changes: 6 additions & 0 deletions src/Verify.MSTest/VerifyBase_Throws.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,42 @@

public partial class VerifyBase
{
[Pure]
public SettingsTask Throws(
Action target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.Throws(target));

[Pure]
public SettingsTask Throws(
Func<object?> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.Throws(target));

[Pure]
public SettingsTask ThrowsTask(
Func<Task> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.ThrowsTask(target));

[Pure]
public SettingsTask ThrowsTask<T>(
Func<Task<T>> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.ThrowsTask(target));

[Pure]
public SettingsTask ThrowsValueTask(
Func<ValueTask> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.ThrowsValueTask(target));

[Pure]
public SettingsTask ThrowsValueTask<T>(
Func<ValueTask<T>> target,
VerifySettings? settings = null,
Expand Down
1 change: 1 addition & 0 deletions src/Verify.MSTest/VerifyBase_Tuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace VerifyMSTest
{
public partial class VerifyBase
{
[Pure]
public SettingsTask VerifyTuple(
Expression<Func<ITuple>> target,
VerifySettings? settings = null,
Expand Down
6 changes: 6 additions & 0 deletions src/Verify.MSTest/VerifyBase_Xml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,42 @@

public partial class VerifyBase
{
[Pure]
public SettingsTask VerifyXml(
string? target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyXml(target));

[Pure]
public SettingsTask VerifyXml(
Task<string> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyXml(target));

[Pure]
public SettingsTask VerifyXml(
ValueTask<string> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyXml(target));

[Pure]
public SettingsTask VerifyXml(
Stream? target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyXml(target));

[Pure]
public SettingsTask VerifyXml(
Task<Stream> target,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "") =>
Verify(settings, sourceFile, _ => _.VerifyXml(target));

[Pure]
public SettingsTask VerifyXml(
ValueTask<Stream> target,
VerifySettings? settings = null,
Expand Down
3 changes: 3 additions & 0 deletions src/Verify.NUnit/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Global using directives

global using System.Diagnostics.Contracts;
Loading

0 comments on commit 355a7fc

Please sign in to comment.