diff --git a/src/Verify.Tests/Naming/NamerTests.cs b/src/Verify.Tests/Naming/NamerTests.cs index e858bb0112..05501d7755 100644 --- a/src/Verify.Tests/Naming/NamerTests.cs +++ b/src/Verify.Tests/Naming/NamerTests.cs @@ -586,6 +586,7 @@ public Task FrameworkName() }) .UniqueForRuntimeAndVersion(); } +#if NET6_0_OR_GREATER || NETFRAMEWORK [Theory] [InlineData(true, false)] @@ -622,4 +623,5 @@ public Task HashParametersFluent(bool a, bool b) => Verify("ContentHashParametersFluent") .UseHashedParameters(a, b) .HashParameters(); +#endif } \ No newline at end of file diff --git a/src/Verify/Naming/FileNameBuilder.cs b/src/Verify/Naming/FileNameBuilder.cs index 15e2d3441e..d1d0123dfe 100644 --- a/src/Verify/Naming/FileNameBuilder.cs +++ b/src/Verify/Naming/FileNameBuilder.cs @@ -1,4 +1,6 @@ -using System.IO.Hashing; +#if NET6_0_OR_GREATER || NETFRAMEWORK +using System.IO.Hashing; +#endif static class FileNameBuilder { @@ -38,14 +40,17 @@ public static string GetParameterText(IReadOnlyList? 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)); @@ -59,4 +64,5 @@ static string HashString(string value) return builder.ToString(); } +#endif } \ No newline at end of file diff --git a/src/Verify/Naming/ParameterSettings.cs b/src/Verify/Naming/ParameterSettings.cs index e6974ddc40..0aed1a556b 100644 --- a/src/Verify/Naming/ParameterSettings.cs +++ b/src/Verify/Naming/ParameterSettings.cs @@ -52,6 +52,7 @@ public void IgnoreParametersForVerified(params object?[] parameters) ignoreParametersForVerified = true; } +#if NET6_0_OR_GREATER || NETFRAMEWORK internal bool hashParameters; /// @@ -75,4 +76,5 @@ public void UseHashedParameters(params object?[] parameters) UseParameters(parameters); HashParameters(); } +#endif } \ No newline at end of file diff --git a/src/Verify/SettingsTask.cs b/src/Verify/SettingsTask.cs index 9f4346dcdd..a102926f57 100644 --- a/src/Verify/SettingsTask.cs +++ b/src/Verify/SettingsTask.cs @@ -246,6 +246,7 @@ public SettingsTask UniqueForRuntimeAndVersion() return this; } +#if NET6_0_OR_GREATER || NETFRAMEWORK /// /// Provide parameters to hash together and pass to . /// Used to get a deterministic file name while avoiding long paths. @@ -267,6 +268,8 @@ public SettingsTask HashParameters() return this; } +#endif + /// /// 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. diff --git a/src/Verify/Verify.csproj b/src/Verify/Verify.csproj index a015d9a780..365699359a 100644 --- a/src/Verify/Verify.csproj +++ b/src/Verify/Verify.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/Verify/VerifySettings.cs b/src/Verify/VerifySettings.cs index c96e3a4c8d..7c04a915e6 100644 --- a/src/Verify/VerifySettings.cs +++ b/src/Verify/VerifySettings.cs @@ -25,7 +25,11 @@ 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;