Skip to content

Commit 226e6a0

Browse files
authored
Remove parameter hashing from unsupported tfm (#920)
* remove parameter hashing from unsupported TFM * .
1 parent 4cde1d9 commit 226e6a0

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

src/Verify.Tests/Naming/NamerTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ public Task FrameworkName()
586586
})
587587
.UniqueForRuntimeAndVersion();
588588
}
589+
#if NET6_0_OR_GREATER || NETFRAMEWORK
589590

590591
[Theory]
591592
[InlineData(true, false)]
@@ -622,4 +623,5 @@ public Task HashParametersFluent(bool a, bool b) =>
622623
Verify("ContentHashParametersFluent")
623624
.UseHashedParameters(a, b)
624625
.HashParameters();
626+
#endif
625627
}

src/Verify/Naming/FileNameBuilder.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.IO.Hashing;
1+
#if NET6_0_OR_GREATER || NETFRAMEWORK
2+
using System.IO.Hashing;
3+
#endif
24

35
static class FileNameBuilder
46
{
@@ -38,14 +40,17 @@ public static string GetParameterText(IReadOnlyList<string>? methodParameters, V
3840
builder.Length -= 1;
3941
var parameterText = builder.ToString();
4042

43+
#if NET6_0_OR_GREATER || NETFRAMEWORK
4144
if (settings.hashParameters)
4245
{
4346
var hashed = HashString(parameterText);
4447
return $"_{hashed}";
4548
}
49+
#endif
4650
return parameterText;
4751
}
4852

53+
#if NET6_0_OR_GREATER || NETFRAMEWORK
4954
static string HashString(string value)
5055
{
5156
var data = XxHash64.Hash(Encoding.UTF8.GetBytes(value));
@@ -59,4 +64,5 @@ static string HashString(string value)
5964

6065
return builder.ToString();
6166
}
67+
#endif
6268
}

src/Verify/Naming/ParameterSettings.cs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void IgnoreParametersForVerified(params object?[] parameters)
5252
ignoreParametersForVerified = true;
5353
}
5454

55+
#if NET6_0_OR_GREATER || NETFRAMEWORK
5556
internal bool hashParameters;
5657

5758
/// <summary>
@@ -75,4 +76,5 @@ public void UseHashedParameters(params object?[] parameters)
7576
UseParameters(parameters);
7677
HashParameters();
7778
}
79+
#endif
7880
}

src/Verify/SettingsTask.cs

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public SettingsTask UniqueForRuntimeAndVersion()
246246
return this;
247247
}
248248

249+
#if NET6_0_OR_GREATER || NETFRAMEWORK
249250
/// <summary>
250251
/// Provide parameters to hash together and pass to <see cref="UseTextForParameters"/>.
251252
/// Used to get a deterministic file name while avoiding long paths.
@@ -267,6 +268,8 @@ public SettingsTask HashParameters()
267268
return this;
268269
}
269270

271+
#endif
272+
270273
/// <summary>
271274
/// Use the current processor architecture (x86/x64/arm/arm64) to make the test results unique.
272275
/// Used when a test produces different results based on processor architecture.

src/Verify/Verify.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Polyfill" Version="1.23.0" PrivateAssets="all" />
1212
<PackageReference Include="System.IO.Compression" Version="4.3.0" Condition="$(TargetFrameworkIdentifier) == '.NETFramework'" />
13-
<PackageReference Include="System.IO.Hashing" Version="7.0.0" />
13+
<PackageReference Include="System.IO.Hashing" Version="7.0.0" Condition="$(TargetFrameworkIdentifier) == '.NETFramework' or $(TargetFramework) == 'net6.0' or $(TargetFramework) == 'net7.0' or $(TargetFramework) == 'net8.0'"/>
1414
<PackageReference Include="System.Memory" Version="4.5.5" Condition="$(TargetFrameworkIdentifier) == '.NETStandard' or $(TargetFrameworkIdentifier) == '.NETFramework' or $(TargetFramework.StartsWith('netcoreapp2'))" />
1515
<Using Include="System.ReadOnlySpan&lt;System.Char&gt;" Alias="CharSpan" />
1616
<Using Include="Argon" />

src/Verify/VerifySettings.cs

+4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public VerifySettings(VerifySettings? settings)
2525
streamComparer = settings.streamComparer;
2626
parameters = settings.parameters;
2727
ignoreParametersForVerified = settings.ignoreParametersForVerified;
28+
29+
#if NET6_0_OR_GREATER || NETFRAMEWORK
2830
hashParameters = settings.hashParameters;
31+
#endif
32+
2933
parametersText = settings.parametersText;
3034
fileName = settings.fileName;
3135
UniquePrefixDisabled = settings.UniquePrefixDisabled;

0 commit comments

Comments
 (0)