Skip to content

Commit d4ee000

Browse files
committed
PR feedback
1 parent fa1f708 commit d4ee000

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/Common.Tests/PluginSettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void LocalCacheSizeInMegabytesSetting()
9595
new[] { 123u, 456u, 789u });
9696

9797
[TestMethod]
98-
public void ForceCacheMissBitMaskSetting()
98+
public void ForceCacheMissPercentageSetting()
9999
=> TestBasicSetting(
100100
nameof(PluginSettings.ForceCacheMissPercentage),
101101
pluginSettings => pluginSettings.ForceCacheMissPercentage,

src/Common/MSBuildCachePluginBase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,15 @@ private async Task<CacheResult> GetCacheResultInnerAsync(BuildRequestData buildR
355355
if (Settings.ForceCacheMissPercentage != 0)
356356
{
357357
// use a hash of the project id so that it is repeatable
358-
#pragma warning disable CA1850 // ComputeHash is not in net472
358+
359+
#if NETFRAMEWORK
359360
using SHA256 hasher = SHA256.Create();
360361
byte[] projectHash = hasher.ComputeHash(Encoding.UTF8.GetBytes(nodeContext.Id));
362+
#else
363+
byte[] projectHash = SHA256.HashData(Encoding.UTF8.GetBytes(nodeContext.Id));
364+
#endif
365+
361366
uint hashInt = BitConverter.ToUInt32(projectHash, 0);
362-
#pragma warning restore CA1850
363367
if ((hashInt % 100) < Settings.ForceCacheMissPercentage)
364368
{
365369
logger.LogMessage($"Forcing an otherwise 'cache hit' to be a 'cache miss' because of ForceCacheMissPercentage.");

0 commit comments

Comments
 (0)