/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/perf/dotnet-tools/BenchmarkDotNet.Extensions/TooManyTestCasesValidator.cs
33 строки
1 KB
xtqqczze
Fix `SA1028`: Code should not contain trailing whitespace. Part 1. (#26203)
16 окт 2025, 10:58
Не верифицирован
16 окт 2025, 10:58
a10ff10
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Linq; using BenchmarkDotNet.Validators; namespace BenchmarkDotNet.Extensions { /// <summary> /// we need to tell our users that having more than 16 test cases per benchmark is a VERY BAD idea /// </summary> public class TooManyTestCasesValidator : IValidator { private const int Limit = 16; public static readonly IValidator FailOnError = new TooManyTestCasesValidator(); public bool TreatsWarningsAsErrors => true; public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters) { var byDescriptor = validationParameters.Benchmarks.GroupBy(benchmark => (benchmark.Descriptor, benchmark.Job)); // descriptor = type + method return byDescriptor.Where(benchmarkCase => benchmarkCase.Count() > Limit).Select(group => new ValidationError( isCritical: true, message: $"{group.Key.Descriptor.Type.Name}.{group.Key.Descriptor.WorkloadMethod.Name} has {group.Count()} test cases. It MUST NOT have more than {Limit} test cases. We don't have infinite amount of time to run all the benchmarks!!", benchmarkCase: group.First())); } } }