Skip to content

Commit

Permalink
redundant NET6_0_OR_GREATER || NETFRAMEWORK
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Dec 27, 2023
1 parent 30914d3 commit a0214eb
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/Verify.Tests/Naming/NamerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ public Task FrameworkName()
})
.UniqueForRuntimeAndVersion();
}
#if NET6_0_OR_GREATER || NETFRAMEWORK

[Theory]
[InlineData(true, false)]
Expand Down Expand Up @@ -621,5 +620,4 @@ public Task HashParametersFluent(bool a, bool b) =>
Verify("ContentHashParametersFluent")
.UseHashedParameters(a, b)
.HashParameters();
#endif
}
1 change: 1 addition & 0 deletions src/Verify/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Global using directives

global using System.Diagnostics.Contracts;
global using System.IO.Hashing;
global using VerifyTests;
global using Argon;
global using DiffEngine;
Expand Down
11 changes: 2 additions & 9 deletions src/Verify/Naming/FileNameBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#if NET6_0_OR_GREATER || NETFRAMEWORK
using System.IO.Hashing;
#endif

static class FileNameBuilder
static class FileNameBuilder
{
public static FrameworkNameVersion? FrameworkName(this Assembly assembly)
{
Expand Down Expand Up @@ -54,17 +50,15 @@ public static string GetParameterText(IReadOnlyList<string>? methodParameters, V
builder.Length -= 1;
var parameterText = builder.ToString();

#if NET6_0_OR_GREATER || NETFRAMEWORK
if (settings.hashParameters)
{
var hashed = HashString(parameterText);
return $"_{hashed}";
}
#endif

return parameterText;
}

#if NET6_0_OR_GREATER || NETFRAMEWORK
static string HashString(string value)
{
var data = XxHash64.Hash(Encoding.UTF8.GetBytes(value));
Expand All @@ -78,5 +72,4 @@ static string HashString(string value)

return builder.ToString();
}
#endif
}
2 changes: 0 additions & 2 deletions src/Verify/Naming/ParameterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void IgnoreParametersForVerified(params object?[] parameters)
ignoreParametersForVerified = true;
}

#if NET6_0_OR_GREATER || NETFRAMEWORK
internal bool hashParameters;

/// <summary>
Expand All @@ -94,5 +93,4 @@ public void UseHashedParameters(params object?[] parameters)
UseParameters(parameters);
HashParameters();
}
#endif
}
3 changes: 0 additions & 3 deletions src/Verify/SettingsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ public SettingsTask UniqueForRuntimeAndVersion()
return this;
}

#if NET6_0_OR_GREATER || NETFRAMEWORK
/// <summary>
/// Provide parameters to hash together and pass to <see cref="UseTextForParameters" />.
/// Used to get a deterministic file name while avoiding long paths.
Expand All @@ -295,8 +294,6 @@ public SettingsTask HashParameters()
return this;
}

#endif

/// <summary>
/// Use the current processor architecture (x86/x64/arm/arm64) to make the test results unique.
/// Used when a test produces different results based on processor architecture.
Expand Down
4 changes: 0 additions & 4 deletions src/Verify/VerifySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public VerifySettings(VerifySettings? settings)
streamComparer = settings.streamComparer;
parameters = settings.parameters;
ignoreParametersForVerified = settings.ignoreParametersForVerified;

#if NET6_0_OR_GREATER || NETFRAMEWORK
hashParameters = settings.hashParameters;
#endif

parametersText = settings.parametersText;
fileName = settings.fileName;
UniquePrefixDisabled = settings.UniquePrefixDisabled;
Expand Down

0 comments on commit a0214eb

Please sign in to comment.