From 804482dea148cceaacef0ae341f09d872e640b37 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 7 Jan 2025 20:02:44 +0100 Subject: [PATCH] Revert "Add support for user-supplied project file detection (#2684)" (#2687) This reverts commit 1aab1c0d7e8398a5e7bb3649f45a5ecab1c8a76f. --- BenchmarkDotNet.sln | 7 --- src/BenchmarkDotNet/Configs/DebugConfig.cs | 2 - src/BenchmarkDotNet/Configs/DefaultConfig.cs | 3 -- src/BenchmarkDotNet/Configs/IConfig.cs | 2 - .../Configs/ImmutableConfig.cs | 7 +-- .../Configs/ImmutableConfigBuilder.cs | 4 +- src/BenchmarkDotNet/Configs/ManualConfig.cs | 12 +---- .../Locators/FileLocatorArgs.cs | 16 ------ .../Locators/FileLocatorType.cs | 6 --- src/BenchmarkDotNet/Locators/IFileLocator.cs | 22 -------- .../Toolchains/CsProj/CsProjGenerator.cs | 42 +++------------ .../MonoAotLLVM/MonoAotLLVMGenerator.cs | 2 +- .../Toolchains/MonoWasm/WasmGenerator.cs | 2 +- .../Toolchains/NativeAot/Generator.cs | 10 ++-- .../AssemblyNameIsSetBenchmarks.cs | 13 ----- ...otNet.IntegrationTests.FileLocators.csproj | 14 ----- .../BenchmarkDotNet.IntegrationTests.csproj | 2 - .../FileLocatorTests.cs | 54 ------------------- .../Configs/ImmutableConfigTests.cs | 40 -------------- 19 files changed, 17 insertions(+), 243 deletions(-) delete mode 100644 src/BenchmarkDotNet/Locators/FileLocatorArgs.cs delete mode 100644 src/BenchmarkDotNet/Locators/FileLocatorType.cs delete mode 100644 src/BenchmarkDotNet/Locators/IFileLocator.cs delete mode 100644 tests/BenchmarkDotNet.IntegrationTests.FileLocators/AssemblyNameIsSetBenchmarks.cs delete mode 100644 tests/BenchmarkDotNet.IntegrationTests.FileLocators/BenchmarkDotNet.IntegrationTests.FileLocators.csproj delete mode 100644 tests/BenchmarkDotNet.IntegrationTests/FileLocatorTests.cs diff --git a/BenchmarkDotNet.sln b/BenchmarkDotNet.sln index f47fde8160..1df6c0aabd 100644 --- a/BenchmarkDotNet.sln +++ b/BenchmarkDotNet.sln @@ -59,8 +59,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkDotNet.Exporters.P EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkDotNet.Exporters.Plotting.Tests", "tests\BenchmarkDotNet.Exporters.Plotting.Tests\BenchmarkDotNet.Exporters.Plotting.Tests.csproj", "{199AC83E-30BD-40CD-87CE-0C838AC0320D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkDotNet.IntegrationTests.FileLocators", "tests\BenchmarkDotNet.IntegrationTests.FileLocators\BenchmarkDotNet.IntegrationTests.FileLocators.csproj", "{7AD9FCF9-69B5-4984-93AC-D6E30344DADC}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -163,10 +161,6 @@ Global {199AC83E-30BD-40CD-87CE-0C838AC0320D}.Debug|Any CPU.Build.0 = Debug|Any CPU {199AC83E-30BD-40CD-87CE-0C838AC0320D}.Release|Any CPU.ActiveCfg = Release|Any CPU {199AC83E-30BD-40CD-87CE-0C838AC0320D}.Release|Any CPU.Build.0 = Release|Any CPU - {7AD9FCF9-69B5-4984-93AC-D6E30344DADC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7AD9FCF9-69B5-4984-93AC-D6E30344DADC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7AD9FCF9-69B5-4984-93AC-D6E30344DADC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7AD9FCF9-69B5-4984-93AC-D6E30344DADC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -196,7 +190,6 @@ Global {2E2283A3-6DA6-4482-8518-99D6D9F689AB} = {D6597E3A-6892-4A68-8E14-042FC941FDA2} {B92ECCEF-7C27-4012-9E19-679F3C40A6A6} = {D6597E3A-6892-4A68-8E14-042FC941FDA2} {199AC83E-30BD-40CD-87CE-0C838AC0320D} = {14195214-591A-45B7-851A-19D3BA2413F9} - {7AD9FCF9-69B5-4984-93AC-D6E30344DADC} = {14195214-591A-45B7-851A-19D3BA2413F9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4D9AF12B-1F7F-45A7-9E8C-E4E46ADCBD1F} diff --git a/src/BenchmarkDotNet/Configs/DebugConfig.cs b/src/BenchmarkDotNet/Configs/DebugConfig.cs index 820fa423c4..0fdda7b08d 100644 --- a/src/BenchmarkDotNet/Configs/DebugConfig.cs +++ b/src/BenchmarkDotNet/Configs/DebugConfig.cs @@ -8,7 +8,6 @@ using BenchmarkDotNet.Exporters; using BenchmarkDotNet.Filters; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Order; using BenchmarkDotNet.Reports; @@ -59,7 +58,6 @@ public abstract class DebugConfig : IConfig public IEnumerable GetValidators() => Array.Empty(); public IEnumerable GetColumnProviders() => DefaultColumnProviders.Instance; public IEnumerable GetExporters() => Array.Empty(); - public IEnumerable GetFileLocators() => Array.Empty(); public IEnumerable GetLoggers() => new[] { ConsoleLogger.Default }; public IEnumerable GetDiagnosers() => Array.Empty(); public IEnumerable GetAnalysers() => Array.Empty(); diff --git a/src/BenchmarkDotNet/Configs/DefaultConfig.cs b/src/BenchmarkDotNet/Configs/DefaultConfig.cs index 6092c05114..b70333cc1d 100644 --- a/src/BenchmarkDotNet/Configs/DefaultConfig.cs +++ b/src/BenchmarkDotNet/Configs/DefaultConfig.cs @@ -11,7 +11,6 @@ using BenchmarkDotNet.Exporters.Csv; using BenchmarkDotNet.Filters; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Order; using BenchmarkDotNet.Portability; @@ -41,8 +40,6 @@ public IEnumerable GetExporters() yield return HtmlExporter.Default; } - public IEnumerable GetFileLocators() => Array.Empty(); - public IEnumerable GetLoggers() { if (LinqPadLogger.IsAvailable) diff --git a/src/BenchmarkDotNet/Configs/IConfig.cs b/src/BenchmarkDotNet/Configs/IConfig.cs index 7335641534..b311c235f5 100644 --- a/src/BenchmarkDotNet/Configs/IConfig.cs +++ b/src/BenchmarkDotNet/Configs/IConfig.cs @@ -8,7 +8,6 @@ using BenchmarkDotNet.Exporters; using BenchmarkDotNet.Filters; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Order; using BenchmarkDotNet.Reports; @@ -21,7 +20,6 @@ public interface IConfig { IEnumerable GetColumnProviders(); IEnumerable GetExporters(); - IEnumerable GetFileLocators(); IEnumerable GetLoggers(); IEnumerable GetDiagnosers(); IEnumerable GetAnalysers(); diff --git a/src/BenchmarkDotNet/Configs/ImmutableConfig.cs b/src/BenchmarkDotNet/Configs/ImmutableConfig.cs index 1526001fbf..b6e03126fd 100644 --- a/src/BenchmarkDotNet/Configs/ImmutableConfig.cs +++ b/src/BenchmarkDotNet/Configs/ImmutableConfig.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Globalization; @@ -10,7 +10,6 @@ using BenchmarkDotNet.Exporters; using BenchmarkDotNet.Filters; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Order; using BenchmarkDotNet.Reports; @@ -25,7 +24,6 @@ public sealed class ImmutableConfig : IConfig // if something is an array here instead of hashset it means it must have a guaranteed order of elements private readonly ImmutableArray columnProviders; private readonly ImmutableArray exporters; - private readonly ImmutableArray fileLocators; private readonly ImmutableHashSet loggers; private readonly ImmutableHashSet diagnosers; private readonly ImmutableHashSet analysers; @@ -43,7 +41,6 @@ internal ImmutableConfig( ImmutableHashSet uniqueHardwareCounters, ImmutableHashSet uniqueDiagnosers, ImmutableArray uniqueExporters, - ImmutableArray uniqueFileLocators, ImmutableHashSet uniqueAnalyzers, ImmutableHashSet uniqueValidators, ImmutableHashSet uniqueFilters, @@ -66,7 +63,6 @@ internal ImmutableConfig( hardwareCounters = uniqueHardwareCounters; diagnosers = uniqueDiagnosers; exporters = uniqueExporters; - fileLocators = uniqueFileLocators; analysers = uniqueAnalyzers; validators = uniqueValidators; filters = uniqueFilters; @@ -96,7 +92,6 @@ internal ImmutableConfig( public IEnumerable GetColumnProviders() => columnProviders; public IEnumerable GetExporters() => exporters; - public IEnumerable GetFileLocators() => fileLocators; public IEnumerable GetLoggers() => loggers; public IEnumerable GetDiagnosers() => diagnosers; public IEnumerable GetAnalysers() => analysers; diff --git a/src/BenchmarkDotNet/Configs/ImmutableConfigBuilder.cs b/src/BenchmarkDotNet/Configs/ImmutableConfigBuilder.cs index 6394c0e999..d7c0b5eb0f 100644 --- a/src/BenchmarkDotNet/Configs/ImmutableConfigBuilder.cs +++ b/src/BenchmarkDotNet/Configs/ImmutableConfigBuilder.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using BenchmarkDotNet.Analysers; @@ -44,7 +44,6 @@ public static ImmutableConfig Create(IConfig source) var uniqueHardwareCounters = source.GetHardwareCounters().Where(counter => counter != HardwareCounter.NotSet).ToImmutableHashSet(); var uniqueDiagnosers = GetDiagnosers(source.GetDiagnosers(), uniqueHardwareCounters); var uniqueExporters = GetExporters(source.GetExporters(), uniqueDiagnosers, configAnalyse); - var uniqueFileLocators = source.GetFileLocators().ToImmutableArray(); var uniqueAnalyzers = GetAnalysers(source.GetAnalysers(), uniqueDiagnosers); var uniqueValidators = GetValidators(source.GetValidators(), MandatoryValidators, source.Options); @@ -62,7 +61,6 @@ public static ImmutableConfig Create(IConfig source) uniqueHardwareCounters, uniqueDiagnosers, uniqueExporters, - uniqueFileLocators, uniqueAnalyzers, uniqueValidators, uniqueFilters, diff --git a/src/BenchmarkDotNet/Configs/ManualConfig.cs b/src/BenchmarkDotNet/Configs/ManualConfig.cs index c05b5c45db..5ea1be24e9 100644 --- a/src/BenchmarkDotNet/Configs/ManualConfig.cs +++ b/src/BenchmarkDotNet/Configs/ManualConfig.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -11,7 +11,6 @@ using BenchmarkDotNet.Extensions; using BenchmarkDotNet.Filters; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Order; using BenchmarkDotNet.Reports; @@ -27,7 +26,6 @@ public class ManualConfig : IConfig private readonly List columnProviders = new List(); private readonly List exporters = new List(); - private readonly List locators = new List(); private readonly List loggers = new List(); private readonly List diagnosers = new List(); private readonly List analysers = new List(); @@ -41,7 +39,6 @@ public class ManualConfig : IConfig public IEnumerable GetColumnProviders() => columnProviders; public IEnumerable GetExporters() => exporters; - public IEnumerable GetFileLocators() => locators; public IEnumerable GetLoggers() => loggers; public IEnumerable GetDiagnosers() => diagnosers; public IEnumerable GetAnalysers() => analysers; @@ -142,12 +139,6 @@ public ManualConfig AddExporter(params IExporter[] newExporters) return this; } - public ManualConfig AddFileLocator(params IFileLocator[] newLocators) - { - locators.AddRange(newLocators); - return this; - } - [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method will soon be removed, please start using .AddLogger() instead.")] public void Add(params ILogger[] newLoggers) => AddLogger(newLoggers); @@ -265,7 +256,6 @@ public void Add(IConfig config) { columnProviders.AddRange(config.GetColumnProviders()); exporters.AddRange(config.GetExporters()); - locators.AddRange(config.GetFileLocators()); loggers.AddRange(config.GetLoggers()); diagnosers.AddRange(config.GetDiagnosers()); analysers.AddRange(config.GetAnalysers()); diff --git a/src/BenchmarkDotNet/Locators/FileLocatorArgs.cs b/src/BenchmarkDotNet/Locators/FileLocatorArgs.cs deleted file mode 100644 index ddbf31d229..0000000000 --- a/src/BenchmarkDotNet/Locators/FileLocatorArgs.cs +++ /dev/null @@ -1,16 +0,0 @@ -using BenchmarkDotNet.Loggers; -using BenchmarkDotNet.Running; - -namespace BenchmarkDotNet.Locators; - -public class FileLocatorArgs -{ - public FileLocatorArgs(BenchmarkCase benchmarkCase, ILogger logger) - { - BenchmarkCase = benchmarkCase; - Logger = logger; - } - - public BenchmarkCase BenchmarkCase { get; } - public ILogger Logger { get; } -} \ No newline at end of file diff --git a/src/BenchmarkDotNet/Locators/FileLocatorType.cs b/src/BenchmarkDotNet/Locators/FileLocatorType.cs deleted file mode 100644 index 5242edfc6c..0000000000 --- a/src/BenchmarkDotNet/Locators/FileLocatorType.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BenchmarkDotNet.Locators; - -public enum FileLocatorType -{ - Project -} \ No newline at end of file diff --git a/src/BenchmarkDotNet/Locators/IFileLocator.cs b/src/BenchmarkDotNet/Locators/IFileLocator.cs deleted file mode 100644 index 4dd32417e5..0000000000 --- a/src/BenchmarkDotNet/Locators/IFileLocator.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.IO; - -namespace BenchmarkDotNet.Locators; - -/// -/// Locators can be used to extend the default behavior of finding files -/// -public interface IFileLocator -{ - /// - /// The type of locator - /// - FileLocatorType LocatorType { get; } - - /// - /// Tries to locate a file - /// - /// The arguments such as benchmark and logger - /// The file is provided by the implementation - /// True when a file was successfully found, False otherwise. - bool TryLocate(FileLocatorArgs fileLocatorArgs, out FileInfo fileInfo); -} \ No newline at end of file diff --git a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs index e0684ac9bf..7e91c36ff4 100644 --- a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs +++ b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; @@ -11,7 +11,6 @@ using BenchmarkDotNet.Extensions; using BenchmarkDotNet.Helpers; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Running; using BenchmarkDotNet.Toolchains.DotNetCli; @@ -72,7 +71,7 @@ protected override string GetIntermediateDirectoryPath(string buildArtifactsDire protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger) { var benchmark = buildPartition.RepresentativeBenchmarkCase; - var projectFile = GetProjectFilePath(benchmark, logger); + var projectFile = GetProjectFilePath(benchmark.Descriptor.Type, logger); var xmlDoc = new XmlDocument(); xmlDoc.Load(projectFile.FullName); @@ -247,29 +246,8 @@ private static string GetIndentedXmlString(XmlDocument doc) /// returns a path to the project file which defines the benchmarks /// [PublicAPI] - protected virtual FileInfo GetProjectFilePath(BenchmarkCase benchmark, ILogger logger) + protected virtual FileInfo GetProjectFilePath(Type benchmarkTarget, ILogger logger) { - var args = new FileLocatorArgs(benchmark, logger); - - // Try locators first. Logic is provided by the user for uses-cases such as they have set AssemblyName to a custom value. - var notFound = new List(); - foreach (var locator in benchmark.Config.GetFileLocators()) - { - if (locator.LocatorType != FileLocatorType.Project) - { - continue; - } - - if (locator.TryLocate(args, out var fileInfo)) - { - if (fileInfo.Exists) - return fileInfo; - - notFound.Add(fileInfo.FullName); - } - } - - // Fall back to default project detection logic if (!GetSolutionRootDirectory(out var rootDirectory) && !GetProjectRootDirectory(out rootDirectory)) { logger.WriteLineError( @@ -278,7 +256,7 @@ protected virtual FileInfo GetProjectFilePath(BenchmarkCase benchmark, ILogger l } // important assumption! project's file name === output dll name - string projectName = benchmark.Descriptor.Type.GetTypeInfo().Assembly.GetName().Name; + string projectName = benchmarkTarget.GetTypeInfo().Assembly.GetName().Name; var possibleNames = new HashSet { $"{projectName}.csproj", $"{projectName}.fsproj", $"{projectName}.vbproj" }; var projectFiles = rootDirectory @@ -288,18 +266,12 @@ protected virtual FileInfo GetProjectFilePath(BenchmarkCase benchmark, ILogger l if (projectFiles.Length == 0) { - string message; - - if (notFound.Count > 0) - message = $"Unable to find {projectName} in any of the paths: {string.Join(", ", notFound)} or in {rootDirectory.FullName} and its subfolders"; - else - message = $"Unable to find {projectName} in {rootDirectory.FullName} and its subfolders. Most probably the name of output exe is different than the name of the .(c/f)sproj. You can add an IFileLocator to the config if this is on purpose."; - - throw new FileNotFoundException(message); + throw new NotSupportedException( + $"Unable to find {projectName} in {rootDirectory.FullName} and its subfolders. Most probably the name of output exe is different than the name of the .(c/f)sproj"); } else if (projectFiles.Length > 1) { - throw new InvalidOperationException( + throw new NotSupportedException( $"Found more than one matching project file for {projectName} in {rootDirectory.FullName} and its subfolders: {string.Join(",", projectFiles.Select(pf => $"'{pf.FullName}'"))}. Benchmark project names needs to be unique."); } diff --git a/src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMGenerator.cs b/src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMGenerator.cs index 906735a425..de3cef53d3 100644 --- a/src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMGenerator.cs +++ b/src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMGenerator.cs @@ -28,7 +28,7 @@ public MonoAotLLVMGenerator(string targetFrameworkMoniker, string cliPath, strin protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger) { BenchmarkCase benchmark = buildPartition.RepresentativeBenchmarkCase; - var projectFile = GetProjectFilePath(benchmark, logger); + var projectFile = GetProjectFilePath(benchmark.Descriptor.Type, logger); string useLLVM = AotCompilerMode == MonoAotCompilerMode.llvm ? "true" : "false"; diff --git a/src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs b/src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs index e5e4262429..7c9aa8826f 100644 --- a/src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs +++ b/src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs @@ -41,7 +41,7 @@ protected override void GenerateProject(BuildPartition buildPartition, Artifacts protected void GenerateProjectFile(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, bool aot, ILogger logger) { BenchmarkCase benchmark = buildPartition.RepresentativeBenchmarkCase; - var projectFile = GetProjectFilePath(benchmark, logger); + var projectFile = GetProjectFilePath(benchmark.Descriptor.Type, logger); WasmRuntime runtime = (WasmRuntime) buildPartition.Runtime; diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs index 3c97bab265..061b64a9a8 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs @@ -151,17 +151,17 @@ private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, Artif {GetILCompilerPackageReference()} - + - {string.Join(Environment.NewLine, GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase, logger).Select(file => $""))} + {string.Join(Environment.NewLine, GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(file => $""))} {GetCustomProperties(buildPartition, logger)} "; private string GetCustomProperties(BuildPartition buildPartition, ILogger logger) { - var projectFile = GetProjectFilePath(buildPartition.RepresentativeBenchmarkCase, logger); + var projectFile = GetProjectFilePath(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger); var xmlDoc = new XmlDocument(); xmlDoc.Load(projectFile.FullName); @@ -186,11 +186,11 @@ private string GetInstructionSetSettings(BuildPartition buildPartition) return !string.IsNullOrEmpty(instructionSet) ? $"{instructionSet}" : ""; } - public IEnumerable GetRdXmlFiles(BenchmarkCase benchmark, ILogger logger) + public IEnumerable GetRdXmlFiles(Type benchmarkTarget, ILogger logger) { yield return GeneratedRdXmlFileName; - var projectFile = GetProjectFilePath(benchmark, logger); + var projectFile = GetProjectFilePath(benchmarkTarget, logger); var projectFileFolder = projectFile.DirectoryName; var rdXml = Path.Combine(projectFileFolder, "rd.xml"); if (File.Exists(rdXml)) diff --git a/tests/BenchmarkDotNet.IntegrationTests.FileLocators/AssemblyNameIsSetBenchmarks.cs b/tests/BenchmarkDotNet.IntegrationTests.FileLocators/AssemblyNameIsSetBenchmarks.cs deleted file mode 100644 index 0dc62277d9..0000000000 --- a/tests/BenchmarkDotNet.IntegrationTests.FileLocators/AssemblyNameIsSetBenchmarks.cs +++ /dev/null @@ -1,13 +0,0 @@ -using BenchmarkDotNet.Attributes; - -namespace BenchmarkDotNet.IntegrationTests.FileLocators -{ - public class AssemblyNameIsSetBenchmarks - { - [Benchmark] - public string Benchmark() - { - return "This will only run when a FileLocator is set due to in the csproj"; - } - } -} \ No newline at end of file diff --git a/tests/BenchmarkDotNet.IntegrationTests.FileLocators/BenchmarkDotNet.IntegrationTests.FileLocators.csproj b/tests/BenchmarkDotNet.IntegrationTests.FileLocators/BenchmarkDotNet.IntegrationTests.FileLocators.csproj deleted file mode 100644 index 3cfa0494e4..0000000000 --- a/tests/BenchmarkDotNet.IntegrationTests.FileLocators/BenchmarkDotNet.IntegrationTests.FileLocators.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - net462;net8.0 - - - MyCustomName - false - false - - - - - \ No newline at end of file diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index 5a08fe5a24..16f12c41b4 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -26,13 +26,11 @@ - - diff --git a/tests/BenchmarkDotNet.IntegrationTests/FileLocatorTests.cs b/tests/BenchmarkDotNet.IntegrationTests/FileLocatorTests.cs deleted file mode 100644 index d41fbf1341..0000000000 --- a/tests/BenchmarkDotNet.IntegrationTests/FileLocatorTests.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.IntegrationTests.FileLocators; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; -using BenchmarkDotNet.Toolchains.CsProj; -using Xunit; -using Xunit.Abstractions; - -namespace BenchmarkDotNet.IntegrationTests -{ - public class FileLocatorTests : BenchmarkTestExecutor - { - public FileLocatorTests(ITestOutputHelper output) : base(output) { } - - [Fact] - public void ExecutionWithoutFileLocatorShouldFail() - { - var config = ManualConfig.CreateMinimumViable() - .AddJob(Job.Dry - .WithToolchain(CsProjClassicNetToolchain.Net462) - .WithToolchain(CsProjCoreToolchain.NetCoreApp80)); - - var summary = CanExecute(config, false); - Assert.True(summary.Reports.All(r => !r.BuildResult.IsBuildSuccess)); - } - - [Fact] - public void ExecutionWithFileLocatorShouldSucceed() - { - var config = ManualConfig.CreateMinimumViable() - .AddJob(Job.Dry - .WithToolchain(CsProjClassicNetToolchain.Net462) - .WithToolchain(CsProjCoreToolchain.NetCoreApp80)) - .AddFileLocator(new CustomFileLocator()); - - CanExecute(config); - } - - private class CustomFileLocator : IFileLocator - { - public FileLocatorType LocatorType => FileLocatorType.Project; - - public bool TryLocate(FileLocatorArgs args, out FileInfo fileInfo) - { - // We manually locate the csproj file, since the default logic of using the AssemblyName does not work - fileInfo = new FileInfo(Path.Combine(Environment.CurrentDirectory, "../../../../BenchmarkDotNet.IntegrationTests.FileLocators/BenchmarkDotNet.IntegrationTests.FileLocators.csproj")); - return true; - } - } - } -} \ No newline at end of file diff --git a/tests/BenchmarkDotNet.Tests/Configs/ImmutableConfigTests.cs b/tests/BenchmarkDotNet.Tests/Configs/ImmutableConfigTests.cs index d7e17701e6..2393cb737c 100644 --- a/tests/BenchmarkDotNet.Tests/Configs/ImmutableConfigTests.cs +++ b/tests/BenchmarkDotNet.Tests/Configs/ImmutableConfigTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using BenchmarkDotNet.Analysers; using BenchmarkDotNet.Columns; @@ -9,7 +8,6 @@ using BenchmarkDotNet.Environments; using BenchmarkDotNet.Exporters; using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Locators; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Order; using BenchmarkDotNet.Reports; @@ -454,43 +452,5 @@ public void GenerateWarningWhenExporterDependencyAlreadyExistInConfig() } } - - [Fact] - public void LocatorsAreAddedCorrectly() - { - var mutable = ManualConfig.CreateEmpty(); - - var expected = new TestFileLocator(); - mutable.AddFileLocator(expected); - - var final = ImmutableConfigBuilder.Create(mutable); - - var actual = Assert.Single(final.GetFileLocators()); - Assert.Same(expected, actual); - } - - [Fact] - public void DuplicateLocatorsAreAllowed() - { - var mutable = ManualConfig.CreateEmpty(); - - var locator = new TestFileLocator(); - mutable.AddFileLocator(locator); - mutable.AddFileLocator(locator); - - var final = ImmutableConfigBuilder.Create(mutable); - - Assert.Equal(2, final.GetFileLocators().Count()); - } - - private class TestFileLocator : IFileLocator - { - public FileLocatorType LocatorType => FileLocatorType.Project; - public bool TryLocate(FileLocatorArgs fileLocatorArgs, out FileInfo fileInfo) - { - fileInfo = new FileInfo(""); - return true; - } - } } }